Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 261214
Collapse All | Expand All

(-)a/config-scripts/cups-compiler.m4 (-408 / +2 lines)
Lines 91-508 if test -n "$GCC"; then Link Here
91
	# Add GCC-specific compiler options...
91
	# Add GCC-specific compiler options...
92
	if test -z "$OPTIM"; then
92
	if test -z "$OPTIM"; then
93
		if test "x$with_optim" = x; then
93
		if test "x$with_optim" = x; then
94
			# Default to optimize-for-size and debug
94
			# Default to NOTHING!!!
95
       			OPTIM="-Os -g"
95
       			OPTIM=""
96
		else
96
		else
97
			OPTIM="$with_optim $OPTIM"
97
			OPTIM="$with_optim $OPTIM"
98
		fi
98
		fi
99
	fi
99
	fi
100
101
	# Generate position-independent code as needed...
102
	if test $PICFLAG = 1 -a $uname != AIX; then
103
    		OPTIM="-fPIC $OPTIM"
104
	fi
105
106
	# The -fstack-protector option is available with some versions of
107
	# GCC and adds "stack canaries" which detect when the return address
108
	# has been overwritten, preventing many types of exploit attacks.
109
	AC_MSG_CHECKING(if GCC supports -fstack-protector)
110
	OLDCFLAGS="$CFLAGS"
111
	CFLAGS="$CFLAGS -fstack-protector"
112
	AC_TRY_COMPILE(,,
113
		OPTIM="$OPTIM -fstack-protector"
114
		AC_MSG_RESULT(yes),
115
		AC_MSG_RESULT(no))
116
	CFLAGS="$OLDCFLAGS"
117
118
	# The -pie option is available with some versions of GCC and adds
119
	# randomization of addresses, which avoids another class of exploits
120
	# that depend on a fixed address for common functions.
121
	if test x$enable_pie = xyes; then
122
		AC_MSG_CHECKING(if GCC supports -pie)
123
		OLDCFLAGS="$CFLAGS"
124
		CFLAGS="$CFLAGS -pie -fPIE"
125
		AC_TRY_COMPILE(,,
126
			PIEFLAGS="-pie -fPIE"
127
			AC_MSG_RESULT(yes),
128
			AC_MSG_RESULT(no, ignoring --enable-pie))
129
		CFLAGS="$OLDCFLAGS"
130
	fi
131
132
	if test "x$with_optim" = x; then
133
		# Add useful warning options for tracking down problems...
134
		OPTIM="-Wall -Wno-format-y2k $OPTIM"
135
		# Additional warning options for development testing...
136
		if test -d .svn; then
137
			OPTIM="-Wshadow -Wunused $OPTIM"
138
		fi
139
	fi
140
141
	case "$uname" in
142
		Darwin*)
143
			# -D_FORTIFY_SOURCE=2 adds additional object size
144
			# checking, basically wrapping all string functions
145
			# with buffer-limited ones.  Not strictly needed for
146
			# CUPS since we already use buffer-limited calls, but
147
			# this will catch any additions that are broken.		
148
			CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
149
150
			if test x$enable_pie = xyes; then
151
				# GCC 4 on Mac OS X needs -Wl,-pie as well
152
				LDFLAGS="$LDFLAGS -Wl,-pie"
153
			fi
154
			;;
155
156
		HP-UX*)
157
			if test "x$enable_32bit" = xyes; then
158
				# Build 32-bit libraries, 64-bit base...
159
				if test -z "$with_arch32flags"; then
160
					ARCH32FLAGS="-milp32"
161
				else
162
					ARCH32FLAGS="$with_arch32flags"
163
				fi
164
165
				if test -z "$with_archflags"; then
166
					if test -z "$with_arch64flags"; then
167
						ARCHFLAGS="-mlp64"
168
					else
169
						ARCHFLAGS="$with_arch64flags"
170
					fi
171
				fi
172
			fi
173
174
			if test "x$enable_64bit" = xyes; then
175
				# Build 64-bit libraries, 32-bit base...
176
				if test -z "$with_arch64flags"; then
177
					ARCH64FLAGS="-mlp64"
178
				else
179
					ARCH64FLAGS="$with_arch64flags"
180
				fi
181
182
				if test -z "$with_archflags"; then
183
					if test -z "$with_arch32flags"; then
184
						ARCHFLAGS="-milp32"
185
					else
186
						ARCHFLAGS="$with_arch32flags"
187
					fi
188
				fi
189
			fi
190
			;;
191
192
		IRIX)
193
			if test "x$enable_32bit" = xyes; then
194
				# Build 32-bit libraries, 64-bit base...
195
				if test -z "$with_arch32flags"; then
196
					ARCH32FLAGS="-n32 -mips3"
197
				else
198
					ARCH32FLAGS="$with_arch32flags"
199
				fi
200
201
				if test -z "$with_archflags"; then
202
					if test -z "$with_arch64flags"; then
203
						ARCHFLAGS="-64 -mips4"
204
					else
205
						ARCHFLAGS="$with_arch64flags"
206
					fi
207
				fi
208
			fi
209
210
			if test "x$enable_64bit" = xyes; then
211
				# Build 64-bit libraries, 32-bit base...
212
				if test -z "$with_arch64flags"; then
213
					ARCH64FLAGS="-64 -mips4"
214
				else
215
					ARCH64FLAGS="$with_arch64flags"
216
				fi
217
218
				if test -z "$with_archflags"; then
219
					if test -z "$with_arch32flags"; then
220
						ARCHFLAGS="-n32 -mips3"
221
					else
222
						ARCHFLAGS="$with_arch32flags"
223
					fi
224
				fi
225
			fi
226
			;;
227
228
		Linux*)
229
			# The -z relro option is provided by the Linux linker command to
230
			# make relocatable data read-only.
231
			if test x$enable_relro = xyes; then
232
				RELROFLAGS="-Wl,-z,relro"
233
			fi
234
235
			if test "x$enable_32bit" = xyes; then
236
				# Build 32-bit libraries, 64-bit base...
237
				if test -z "$with_arch32flags"; then
238
					ARCH32FLAGS="-m32"
239
				else
240
					ARCH32FLAGS="$with_arch32flags"
241
				fi
242
243
				if test -z "$with_archflags"; then
244
					if test -z "$with_arch64flags"; then
245
						ARCHFLAGS="-m64"
246
					else
247
						ARCHFLAGS="$with_arch64flags"
248
					fi
249
				fi
250
			fi
251
252
			if test "x$enable_64bit" = xyes; then
253
				# Build 64-bit libraries, 32-bit base...
254
				if test -z "$with_arch64flags"; then
255
					ARCH64FLAGS="-m64"
256
				else
257
					ARCH64FLAGS="$with_arch64flags"
258
				fi
259
260
				if test -z "$with_archflags"; then
261
					if test -z "$with_arch32flags"; then
262
						ARCHFLAGS="-m32"
263
					else
264
						ARCHFLAGS="$with_arch32flags"
265
					fi
266
				fi
267
			fi
268
			;;
269
270
		SunOS*)
271
			if test "x$enable_32bit" = xyes; then
272
				# Build 32-bit libraries, 64-bit base...
273
				if test -z "$with_arch32flags"; then
274
					ARCH32FLAGS="-m32"
275
				else
276
					ARCH32FLAGS="$with_arch32flags"
277
				fi
278
279
				if test -z "$with_archflags"; then
280
					if test -z "$with_arch64flags"; then
281
						ARCHFLAGS="-m64"
282
					else
283
						ARCHFLAGS="$with_arch64flags"
284
					fi
285
				fi
286
			fi
287
288
			if test "x$enable_64bit" = xyes; then
289
				# Build 64-bit libraries, 32-bit base...
290
				if test -z "$with_arch64flags"; then
291
					ARCH64FLAGS="-m64"
292
				else
293
					ARCH64FLAGS="$with_arch64flags"
294
				fi
295
296
				if test -z "$with_archflags"; then
297
					if test -z "$with_arch32flags"; then
298
						ARCHFLAGS="-m32"
299
					else
300
						ARCHFLAGS="$with_arch32flags"
301
					fi
302
				fi
303
			fi
304
			;;
305
	esac
306
else
307
	# Add vendor-specific compiler options...
308
	case $uname in
309
		AIX*)
310
			if test -z "$OPTIM"; then
311
				if test "x$with_optim" = x; then
312
					OPTIM="-O2 -qmaxmem=6000"
313
				else
314
					OPTIM="$with_optim $OPTIM"
315
				fi
316
			fi
317
			;;
318
		HP-UX*)
319
			if test -z "$OPTIM"; then
320
				if test "x$with_optim" = x; then
321
					OPTIM="+O2"
322
				else
323
					OPTIM="$with_optim $OPTIM"
324
				fi
325
			fi
326
327
			CFLAGS="-Ae $CFLAGS"
328
			# Warning 336 is "empty translation unit"
329
			# Warning 829 is passing constant string as char *
330
			CXXFLAGS="+W336,829 $CXXFLAGS"
331
332
			if test $PICFLAG = 1; then
333
				OPTIM="+z $OPTIM"
334
			fi
335
336
			if test "x$enable_32bit" = xyes; then
337
				# Build 32-bit libraries, 64-bit base...
338
				if test -z "$with_arch32flags"; then
339
					ARCH32FLAGS="+DD32"
340
				else
341
					ARCH32FLAGS="$with_arch32flags"
342
				fi
343
344
				if test -z "$with_archflags"; then
345
					if test -z "$with_arch64flags"; then
346
						ARCHFLAGS="+DD64"
347
					else
348
						ARCHFLAGS="$with_arch64flags"
349
					fi
350
				fi
351
			fi
352
353
			if test "x$enable_64bit" = xyes; then
354
				# Build 64-bit libraries, 32-bit base...
355
				if test -z "$with_arch64flags"; then
356
					ARCH64FLAGS="+DD64"
357
				else
358
					ARCH64FLAGS="$with_arch64flags"
359
				fi
360
361
				if test -z "$with_archflags"; then
362
					if test -z "$with_arch32flags"; then
363
						ARCHFLAGS="+DD32"
364
					else
365
						ARCHFLAGS="$with_arch32flags"
366
					fi
367
				fi
368
			fi
369
			;;
370
        	IRIX)
371
			if test -z "$OPTIM"; then
372
				if test "x$with_optim" = x; then
373
					OPTIM="-O2"
374
				else
375
					OPTIM="$with_optim $OPTIM"
376
				fi
377
			fi
378
379
			if test "x$with_optim" = x; then
380
				OPTIM="-fullwarn -woff 1183,1209,1349,1506,3201 $OPTIM"
381
			fi
382
383
			if test "x$enable_32bit" = xyes; then
384
				# Build 32-bit libraries, 64-bit base...
385
				if test -z "$with_arch32flags"; then
386
					ARCH32FLAGS="-n32 -mips3"
387
				else
388
					ARCH32FLAGS="$with_arch32flags"
389
				fi
390
391
				if test -z "$with_archflags"; then
392
					if test -z "$with_arch64flags"; then
393
						ARCHFLAGS="-64 -mips4"
394
					else
395
						ARCHFLAGS="$with_arch64flags"
396
					fi
397
				fi
398
			fi
399
400
			if test "x$enable_64bit" = xyes; then
401
				# Build 64-bit libraries, 32-bit base...
402
				if test -z "$with_arch64flags"; then
403
					ARCH64FLAGS="-64 -mips4"
404
				else
405
					ARCH64FLAGS="$with_arch64flags"
406
				fi
407
408
				if test -z "$with_archflags"; then
409
					if test -z "$with_arch32flags"; then
410
						ARCHFLAGS="-n32 -mips3"
411
					else
412
						ARCHFLAGS="$with_arch32flags"
413
					fi
414
				fi
415
			fi
416
			;;
417
		OSF*)
418
			# Tru64 UNIX aka Digital UNIX aka OSF/1
419
			if test -z "$OPTIM"; then
420
				if test "x$with_optim" = x; then
421
					OPTIM="-O"
422
				else
423
					OPTIM="$with_optim"
424
				fi
425
			fi
426
			;;
427
		SunOS*)
428
			# Solaris
429
			if test -z "$OPTIM"; then
430
				if test "x$with_optim" = x; then
431
					OPTIM="-xO2"
432
				else
433
					OPTIM="$with_optim $OPTIM"
434
				fi
435
			fi
436
437
			if test $PICFLAG = 1; then
438
				OPTIM="-KPIC $OPTIM"
439
			fi
440
441
			if test "x$enable_32bit" = xyes; then
442
				# Compiling on a Solaris system, build 64-bit
443
				# binaries with separate 32-bit libraries...
444
				ARCH32FLAGS="-xarch=generic"
445
446
				if test "x$with_optim" = x; then
447
					# Suppress all of Sun's questionable
448
					# warning messages, and default to
449
					# 64-bit compiles of everything else...
450
					OPTIM="-w $OPTIM"
451
				fi
452
453
				if test -z "$with_archflags"; then
454
					if test -z "$with_arch64flags"; then
455
						ARCHFLAGS="-xarch=generic64"
456
					else
457
						ARCHFLAGS="$with_arch64flags"
458
					fi
459
				fi
460
			else
461
				if test "x$enable_64bit" = xyes; then
462
					# Build 64-bit libraries...
463
					ARCH64FLAGS="-xarch=generic64"
464
				fi
465
466
				if test "x$with_optim" = x; then
467
					# Suppress all of Sun's questionable
468
					# warning messages, and default to
469
					# 32-bit compiles of everything else...
470
					OPTIM="-w $OPTIM"
471
				fi
472
473
				if test -z "$with_archflags"; then
474
					if test -z "$with_arch32flags"; then
475
						ARCHFLAGS="-xarch=generic"
476
					else
477
						ARCHFLAGS="$with_arch32flags"
478
					fi
479
				fi
480
			fi
481
			;;
482
		UNIX_SVR*)
483
			# UnixWare
484
			if test -z "$OPTIM"; then
485
				if test "x$with_optim" = x; then
486
					OPTIM="-O"
487
				else
488
					OPTIM="$with_optim $OPTIM"
489
				fi
490
			fi
491
492
			if test $PICFLAG = 1; then
493
				OPTIM="-KPIC $OPTIM"
494
			fi
495
			;;
496
		*)
497
			# Running some other operating system; inform the user they
498
			# should contribute the necessary options to
499
			# cups-support@cups.org...
500
			echo "Building CUPS with default compiler optimizations; contact"
501
			echo "cups-bugs@cups.org with uname and compiler options needed"
502
			echo "for your platform, or set the CFLAGS, CXXFLAGS, and LDFLAGS"
503
			echo "environment variables before running configure."
504
			;;
505
	esac
506
fi
100
fi
507
101
508
# Add general compiler options per platform...
102
# Add general compiler options per platform...

Return to bug 261214