Browse code

- makefile support for mutiple gcc versions - updated required compiler in INSTALL

Andrei Pelinescu-Onciul authored on 25/02/2002 19:47:32
Showing 2 changed files
... ...
@@ -10,7 +10,8 @@ There are various configuration options defined in the Makefile.
10 10
 Requirements:
11 11
 
12 12
 
13
-- gcc
13
+- gcc >= 2.9x; 3.0.x recommended (it will work with older version but it might
14
+ require some options tweaking for best performance)
14 15
 - bison or yacc (Berkley yacc)
15 16
 - flex
16 17
 - gmake (on Linux this is the standard "make")
... ...
@@ -104,38 +104,106 @@ mode = release
104 104
 CC=gcc
105 105
 LD= $(CC)
106 106
 CC_VER= $(CC) $(shell $(CC) --version)
107
+CC_LONGVER=$(shell $(CC) -v 2>&1)
107 108
 MKDEP=gcc -MM $(DEFS)
108 109
 MKTAGS=ctags -R .
109 110
 
111
+#find-out the compiler's name
112
+
113
+ifneq (,$(findstring gcc, $(CC_LONGVER)))
114
+	CC_NAME=gcc
115
+	#transform gcc version into 2.9x or 3.0
116
+	CC_SHORTVER=$(shell $(CC) --version | \
117
+				 sed -e 's/[^0-9]*-\(.*\)/\1/'| \
118
+				 sed -e 's/2\.9.*/2.9x/' -e 's/3\..\..*/3.0/')
119
+else
120
+	CC_NAME=$(CC)
121
+	CC_SHORTVER=unknown
122
+endif
123
+
124
+
125
+# setting CFLAGS
110 126
 ifeq ($(mode), release)
127
+	#common stuff
111 128
 	CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) -Winline\
112
-			-malign-loops=4
113 129
 			#-Wmissing-prototypes \
114
-	
115
-ifneq (,$(findstring 3.0, $(CC_VER)))
116
-# gcc 3.0.x specific optimizations
117
-	ifeq ($(ARCH), i386)
118
-		CFLAGS+=-minline-all-stringops -malign-double -march=athlon \
119
-				#-mcpu=athlon
120
-	endif
121
-	ifeq ($(ARCH), sparc64)
122
-		# sparc64 specific options, using 32bit for now
123
-		CFLAGS+= -mcpu=v9 -mtune=ultrasparc  -m32  \
124
-				# -mcpu=v9 or ultrasparc? # -mtune implied by -mcpu
125
-				#-mno-epilogue #try to inline function exit code
126
-				#-mflat # omit save/restore
127
-				#-,faster-structs #faster non Sparc ABI structure copy ops
128
-				
129
-	endif
130
-endif
130
+	#if i386
131
+ifeq	($(ARCH), i386)
132
+		# if gcc 
133
+ifeq		($(CC_NAME), gcc)
134
+			#if gcc 3.0
135
+ifeq			($(CC_SHORTVER), 3.0)
136
+					CFLAGS+=-minline-all-stringops -malign-double \
137
+							-malign-loops=4 \
138
+							-march=athlon \
139
+							#-mcpu=athlon
140
+else
141
+ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
142
+$(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
143
+					for better results)
144
+					
145
+					CFLAGS+=-m486 \
146
+							-malign-loops=4
147
+else
148
+				#really old version
149
+$(warning			You are using an old and unsupported gcc \
150
+					 version ($(CC_SHORTVER)), compile at your own risk!)
151
+
152
+endif			# CC_SHORTVER, 2.9x
153
+endif			# CC_SHORTVER, 3.0
154
+
155
+else		# CC_NAME, gcc
156
+				#other compilers
157
+$(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
158
+endif		#CC_NAME, gcc
159
+endif	#ARCH, i386
160
+
161
+
162
+	#if sparc64
163
+ifeq	($(ARCH), sparc64)
164
+			#if gcc
165
+ifeq		($(CC_NAME), gcc)
166
+				#if gcc 3.0
167
+ifeq			($(CC_SHORTVER), 3.0)
168
+					#use 32bit for now
169
+					CFLAGS+= -mcpu=v9 -mtune=ultrasparc  -m32  \
170
+					# -mcpu=v9 or ultrasparc? # -mtune implied by -mcpu
171
+					#-mno-epilogue #try to inline function exit code
172
+					#-mflat # omit save/restore
173
+					#-,faster-structs #faster non Sparc ABI structure copy ops
174
+else			# CC_SHORTVER, 3.0
175
+ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
176
+$(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
177
+					for better results)
178
+					
179
+					CFLAGS+= -mv8 -Wa,-xarch=v8plus
180
+else			#CC_SHORTVER, 2.9x
181
+				#really old version
182
+$(warning			You are using an old and unsupported gcc \
183
+					 version ($(CC_SHORTVER)), compile at your own risk!)
184
+					
185
+					CFLAGS+= -mv8 -Wa,-xarch=v8plus
186
+endif			#CC_SHORTVER, 2.9x
187
+endif			#CC_SHORTVER, 3.0
188
+
189
+else		#CC_NAME, gcc
190
+				#other compilers
191
+$(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
192
+endif		#CC_NAME, gcc
193
+endif	#ARCH, sparc64
194
+
195
+
196
+
197
+# setting LDFLAGS
131 198
 	LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE)
132 199
 	# we need -fPIC -DPIC only for shared objects, we don't need them for
133 200
 	# the executable file, because it's always loaded at a fixed address
134 201
 	# -andrei
135
-else
202
+else	#mode,release
136 203
 	CFLAGS=-g -Wcast-align -Winline $(PROFILE)
137 204
 	LDFLAGS+=-g -Wl,-E $(PROFILE)
138
-endif
205
+endif #mode=release
206
+
139 207
 
140 208
 #*FLAGS used for compiling the modules
141 209
 MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
... ...
@@ -149,10 +217,11 @@ YACC_FLAGS=-d -b cfg
149 217
 LIBS=-lfl -ldl
150 218
 
151 219
 
152
-#arch specific stuff
220
+#os specific stuff
153 221
 ifeq ($(OS), Linux)
154
-
222
+	#same as common
155 223
 endif
224
+
156 225
 ifeq  ($(OS), SunOS)
157 226
 	ifeq ($(mode), release)
158 227
 		LDFLAGS=-O2 $(PROFILE)
... ...
@@ -161,24 +230,20 @@ ifeq  ($(OS), SunOS)
161 230
 		LDFLAGS=-g $(PROFILE)
162 231
 		MOD_LDFLAGS=-g -G
163 232
 	endif
164
-	ifeq ($(ARCH), sparc64)
165
-		CFLAGS+= -mv8 -Wa,-xarch=v8plus
166
-	endif
167
-
168
-YACC=yacc
169
-LIBS+=-L/usr/local/lib -lxnet -lrt # or -lnsl -lsocket or -lglibc ?
170
-# -lrt needed for sched_yield
171 233
 
234
+	YACC=yacc
235
+	LIBS+=-L/usr/local/lib -lxnet -lrt # or -lnsl -lsocket or -lglibc ?
236
+	# -lrt needed for sched_yield
172 237
 endif
238
+
173 239
 ifeq ($(OS), FreeBSD)
174 240
 
175
-YACC=yacc
176
-LIBS= -lfl  #dlopen is in libc
241
+	YACC=yacc
242
+	LIBS= -lfl  #dlopen is in libc
177 243
 
178 244
 endif
179
-ifneq (,$(findstring CYGWIN, $(OS)))
180
-
181
-#cygwin is the same as common
182 245
 
246
+ifneq (,$(findstring CYGWIN, $(OS)))
247
+	#cygwin is the same as common
183 248
 endif
184 249