1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
--- Makefile.linux.orig Sat Apr 22 12:10:56 2006
+++ Makefile.linux Sat May 27 12:41:15 2006
@@ -4,14 +4,25 @@
# by Slawomir Mazurek <homer13@o2.pl>
#
-CC := gcc
-_E := @
+# this nice line comes from the linux kernel makefile
+ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc/ -e s/sparc64/sparc/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/alpha/axp/)
+OSTYPE := $(shell uname -s)
-################
+CC ?= gcc
+#_E := @
+LOCALBASE ?= /usr/local
+LOCALBASE ?= /usr/X11R6
+USE_OPTIMIZED_CFLAGS ?= YES
-default_target: glx
+ifeq ($(ARCH),i386)
+USE_X86_ASM ?= YES
+else
+USE_X86_ASM = NO
+endif
-all: glx x11 svga
+################
+
+all:
################################
# Directories for object files #
@@ -43,11 +54,12 @@
$(GLX_DIR) $(X11_DIR) $(SVGA_DIR):
$(MKDIR)
-CFLAGS += -Did386 -funsigned-char -O6 \
- -D__linux__ -march=pentiumpro -Wall \
- -funroll-loops -fomit-frame-pointer -DNDEBUG \
- -ffast-math -fno-strength-reduce -fexpensive-optimizations \
- -I/usr/include
+CFLAGS += -DNDEBUG -DDATADIR='"$(Q1DIR)"'
+
+ifeq ($(strip $(USE_OPTIMIZED_CFLAGS)),YES)
+CFLAGS += -O1 -funsigned-char -funroll-loops -fomit-frame-pointer \
+ -ffast-math -fno-strength-reduce -fexpensive-optimizations
+endif
LDFLAGS := -lm
@@ -75,19 +87,25 @@
image version security iplog \
cl_slist
+ifeq ($(strip $(USE_X86_ASM)),YES)
GLX_S_FILES := \
math snd_mixa sys_x86
+endif
GLX_C_OBJS := $(addprefix $(GLX_DIR)/, $(addsuffix .o, $(GLX_C_FILES)))
GLX_S_OBJS := $(addprefix $(GLX_DIR)/, $(addsuffix .o, $(GLX_S_FILES)))
GLX_CFLAGS := $(CFLAGS) \
- -DGLQUAKE -I/usr/X11R6/include
+ -DGLQUAKE -I$(LOCALBASE)/include
+
+ifeq ($(strip $(USE_X86_ASM)),YES)
+GLX_CFLAGS += -Did386
+endif
GLX_LDFLAGS := $(LDFLAGS) \
- -lGL -L/usr/X11R6/lib -lX11 \
- -lXext -lXxf86dga -lXxf86vm \
- -lpng -ljpeg
+ -L$(LOCALBASE)/lib -lGL -lX11 \
+ -lXext -lXxf86dga -lXxf86vm \
+ -L$(LOCALBASE)/lib -lpng -ljpeg
glx: _DIR := $(GLX_DIR)
glx: _OBJS := $(GLX_C_OBJS) $(GLX_S_OBJS)
@@ -138,21 +156,27 @@
snd_linux image version security \
iplog cl_slist
+ifeq ($(strip $(USE_X86_ASM)),YES)
X11_S_FILES := \
d_copy d_draw d_draw16 d_parta \
d_polysa d_scana d_spr8 d_varsa \
math r_aclipa r_aliasa r_drawa \
r_edgea r_varsa snd_mixa surf8 \
sys_x86
+endif
X11_C_OBJS := $(addprefix $(X11_DIR)/, $(addsuffix .o, $(X11_C_FILES)))
X11_S_OBJS := $(addprefix $(X11_DIR)/, $(addsuffix .o, $(X11_S_FILES)))
-X11_CFLAGS := $(CFLAGS)
+X11_CFLAGS := $(CFLAGS) -I$(LOCALBASE)/include
+
+ifeq ($(strip $(USE_X86_ASM)),YES)
+X11_CFLAGS += -Did386
+endif
X11_LDFLAGS := $(LDFLAGS) \
- -L/usr/X11R6/lib -lX11 -lXext \
- -lpng
+ -L$(LOCALBASE)/lib -lX11 -lXext \
+ -L$(LOCALBASE)/lib -lpng
x11: _DIR := $(X11_DIR)
x11: _OBJS := $(X11_C_OBJS) $(X11_S_OBJS)
@@ -213,17 +237,25 @@
SVGA_C_OBJS := $(addprefix $(SVGA_DIR)/, $(addsuffix .o, $(SVGA_C_FILES)))
SVGA_S_OBJS := $(addprefix $(SVGA_DIR)/, $(addsuffix .o, $(SVGA_S_FILES)))
-SVGA_CFLAGS := $(CFLAGS)
+SVGA_CFLAGS := $(CFLAGS) -Did386 -I$(LOCALBASE)/include
SVGA_LDFLAGS := $(LDFLAGS) \
- -L/usr/X11R6/lib -lX11 -lpthread \
- -lvga -lpng
+ -L$(LOCALBASE)/lib -lX11 -lpthread \
+ -L$(LOCALBASE)/lib -lvga -lpng
+ifeq ($(OSTYPE),Linux)
+ ifeq ($(ARCH),i386)
svga: _DIR := $(SVGA_DIR)
svga: _OBJS := $(SVGA_C_OBJS) $(SVGA_S_OBJS)
svga: _LDFLAGS := $(SVGA_LDFLAGS)
svga: _CFLAGS := $(SVGA_CFLAGS)
svga: $(SVGA_TARGET)
+ else
+svga:
+ endif
+else
+svga:
+endif
$(SVGA_TARGET): $(SVGA_DIR) $(SVGA_C_OBJS) $(SVGA_S_OBJS)
$(BUILD)
|