]> git.ipfire.org Git - thirdparty/cups.git/blame - config-scripts/cups-compiler.m4
Merge changes from CUPS 1.4svn-r7386.
[thirdparty/cups.git] / config-scripts / cups-compiler.m4
CommitLineData
ef416fc2 1dnl
2e4ff8af 2dnl "$Id: cups-compiler.m4 6975 2007-09-18 20:37:09Z mike $"
ef416fc2 3dnl
4dnl Compiler stuff for the Common UNIX Printing System (CUPS).
5dnl
5bd77a73 6dnl Copyright 2007-2008 by Apple Inc.
f7deaa1a 7dnl Copyright 1997-2007 by Easy Software Products, all rights reserved.
ef416fc2 8dnl
9dnl These coded instructions, statements, and computer programs are the
bc44d920 10dnl property of Apple Inc. and are protected by Federal copyright
11dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
12dnl which should have been included with this file. If this file is
13dnl file is missing or damaged, see the license at "http://www.cups.org/".
ef416fc2 14dnl
15
16dnl Clear the debugging and non-shared library options unless the user asks
17dnl for them...
18OPTIM=""
19AC_SUBST(OPTIM)
20
fa73b229 21AC_ARG_WITH(optim, [ --with-optim="flags" set optimization flags ])
ef416fc2 22AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging, default=no],
23 [if test x$enable_debug = xyes; then
24 OPTIM="-g"
25 fi])
26
ed486911 27dnl Setup general architecture flags...
28AC_ARG_WITH(archflags, [ --with-archflags="flags"
29 set default architecture flags ])
a603edef
MS
30AC_ARG_WITH(ldarchflags, [ --with-ldarchflags="flags"
31 set default program architecture flags ])
ed486911 32
33if test -z "$with_archflags"; then
34 ARCHFLAGS=""
35else
36 ARCHFLAGS="$with_archflags"
a603edef
MS
37fi
38
39if test -z "$with_ldarchflags"; then
09a101d6 40 if test "$uname" = Darwin; then
a603edef 41 # Only create 32-bit programs by default
09a101d6 42 LDARCHFLAGS="`echo $ARCHFLAGS | sed -e '1,$s/-arch x86_64//' -e '1,$s/-arch ppc64//'`"
43 else
44 LDARCHFLAGS="$ARCHFLAGS"
45 fi
a603edef
MS
46else
47 LDARCHFLAGS="$with_archflags"
ed486911 48fi
49
50AC_SUBST(ARCHFLAGS)
09a101d6 51AC_SUBST(LDARCHFLAGS)
ed486911 52
e1d6a774 53dnl Setup support for separate 32/64-bit library generation...
ed486911 54AC_ARG_WITH(arch32flags, [ --with-arch32flags="flags"
55 specifies 32-bit architecture flags])
e1d6a774 56ARCH32FLAGS=""
e1d6a774 57AC_SUBST(ARCH32FLAGS)
e1d6a774 58
ed486911 59AC_ARG_WITH(arch64flags, [ --with-arch64flags="flags"
60 specifies 64-bit architecture flags])
e1d6a774 61ARCH64FLAGS=""
e1d6a774 62AC_SUBST(ARCH64FLAGS)
e1d6a774 63
f7deaa1a 64dnl Read-only data/program support on Linux...
65AC_ARG_ENABLE(relro, [ --enable-relro use GCC relro option, default=no])
66
ef416fc2 67dnl Update compiler options...
ac884b6a
MS
68CXXLIBS="${CXXLIBS:=}"
69AC_SUBST(CXXLIBS)
70
a74454a7 71PIEFLAGS=""
72AC_SUBST(PIEFLAGS)
73
f7deaa1a 74RELROFLAGS=""
75AC_SUBST(RELROFLAGS)
76
355e94dc 77LIBCUPSORDER="libcups.order"
cc0d019f 78AC_ARG_WITH(libcupsorder, [ --with-libcupsorder libcups secorder file, default=libcups.order],
355e94dc
MS
79 if test -f "$withval"; then
80 LIBCUPSORDER="$withval"
81 fi)
cc0d019f
MS
82AC_SUBST(LIBCUPSORDER)
83
355e94dc
MS
84LIBCUPSIMAGEORDER="libcupsimage.order"
85AC_ARG_WITH(libcupsimageorder, [ --with-libcupsimagesorder
86 libcupsimage secorder file, default=libcupsimage.order],
87 if test -f "$withval"; then
88 LIBCUPSIMAGEORDER="$withval"
89 fi)
cc0d019f
MS
90AC_SUBST(LIBCUPSIMAGEORDER)
91
ef416fc2 92if test -n "$GCC"; then
2abf387c 93 # Add GCC-specific compiler options...
ef416fc2 94 if test -z "$OPTIM"; then
95 if test "x$with_optim" = x; then
96 # Default to optimize-for-size and debug
97 OPTIM="-Os -g"
98 else
99 OPTIM="$with_optim $OPTIM"
100 fi
101 fi
102
a4924f6c 103 # Generate position-independent code as needed...
ef416fc2 104 if test $PICFLAG = 1 -a $uname != AIX; then
105 OPTIM="-fPIC $OPTIM"
106 fi
107
a4924f6c
MS
108 # The -fstack-protector option is available with some versions of
109 # GCC and adds "stack canaries" which detect when the return address
110 # has been overwritten, preventing many types of exploit attacks.
111 AC_MSG_CHECKING(if GCC supports -fstack-protector)
112 OLDCFLAGS="$CFLAGS"
113 CFLAGS="$CFLAGS -fstack-protector"
114 AC_TRY_COMPILE(,,
115 OPTIM="$OPTIM -fstack-protector"
116 AC_MSG_RESULT(yes),
117 AC_MSG_RESULT(no))
118 CFLAGS="$OLDCFLAGS"
119
120 # The -pie option is available with some versions of GCC and adds
121 # randomization of addresses, which avoids another class of exploits
122 # that depend on a fixed address for common functions.
123 AC_MSG_CHECKING(if GCC supports -pie)
124 OLDCFLAGS="$CFLAGS"
125 CFLAGS="$CFLAGS -pie -fPIE"
126 AC_TRY_COMPILE(,,
127 PIEFLAGS="-pie -fPIE"
128 AC_MSG_RESULT(yes),
129 AC_MSG_RESULT(no))
130 CFLAGS="$OLDCFLAGS"
ef416fc2 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"
a4924f6c 135 # Additional warning options for development testing...
d9bca400
MS
136 if test -d .svn; then
137 OPTIM="-Wshadow -Wunused $OPTIM"
138 fi
ef416fc2 139 fi
e1d6a774 140
141 case "$uname" in
a4924f6c
MS
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"
568fa3fa
MS
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
a4924f6c
MS
154 ;;
155
b86bc4cf 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
e1d6a774 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
e1d6a774 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
e1d6a774 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
e1d6a774 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
e1d6a774 224 fi
225 fi
226 ;;
227
228 Linux*)
a4924f6c
MS
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
e1d6a774 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
e1d6a774 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
e1d6a774 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
e1d6a774 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
e1d6a774 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
e1d6a774 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
e1d6a774 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
e1d6a774 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
e1d6a774 302 fi
303 fi
304 ;;
305 esac
ef416fc2 306else
2abf387c 307 # Add vendor-specific compiler options...
ef416fc2 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
ef416fc2 329 if test $PICFLAG = 1; then
330 OPTIM="+z $OPTIM"
331 fi
c277e2f8
MS
332
333 if test "x$enable_32bit" = xyes; then
334 # Build 32-bit libraries, 64-bit base...
335 if test -z "$with_arch32flags"; then
336 ARCH32FLAGS="+DD32"
337 else
338 ARCH32FLAGS="$with_arch32flags"
339 fi
340
341 if test -z "$with_archflags"; then
342 if test -z "$with_arch64flags"; then
343 ARCHFLAGS="+DD64"
344 else
345 ARCHFLAGS="$with_arch64flags"
346 fi
347 fi
348 fi
349
350 if test "x$enable_64bit" = xyes; then
351 # Build 64-bit libraries, 32-bit base...
352 if test -z "$with_arch64flags"; then
353 ARCH64FLAGS="+DD64"
354 else
355 ARCH64FLAGS="$with_arch64flags"
356 fi
357
358 if test -z "$with_archflags"; then
359 if test -z "$with_arch32flags"; then
360 ARCHFLAGS="+DD32"
361 else
362 ARCHFLAGS="$with_arch32flags"
363 fi
364 fi
365 fi
ef416fc2 366 ;;
367 IRIX)
368 if test -z "$OPTIM"; then
369 if test "x$with_optim" = x; then
370 OPTIM="-O2"
371 else
372 OPTIM="$with_optim $OPTIM"
373 fi
374 fi
375
e1d6a774 376 if test "x$with_optim" = x; then
377 OPTIM="-fullwarn -woff 1183,1209,1349,1506,3201 $OPTIM"
ef416fc2 378 fi
379
e1d6a774 380 if test "x$enable_32bit" = xyes; then
381 # Build 32-bit libraries, 64-bit base...
382 if test -z "$with_arch32flags"; then
383 ARCH32FLAGS="-n32 -mips3"
384 else
385 ARCH32FLAGS="$with_arch32flags"
386 fi
e1d6a774 387
388 if test -z "$with_archflags"; then
389 if test -z "$with_arch64flags"; then
390 ARCHFLAGS="-64 -mips4"
391 else
392 ARCHFLAGS="$with_arch64flags"
393 fi
e1d6a774 394 fi
395 fi
396
397 if test "x$enable_64bit" = xyes; then
398 # Build 64-bit libraries, 32-bit base...
399 if test -z "$with_arch64flags"; then
400 ARCH64FLAGS="-64 -mips4"
401 else
402 ARCH64FLAGS="$with_arch64flags"
403 fi
e1d6a774 404
405 if test -z "$with_archflags"; then
406 if test -z "$with_arch32flags"; then
407 ARCHFLAGS="-n32 -mips3"
408 else
409 ARCHFLAGS="$with_arch32flags"
410 fi
ef416fc2 411 fi
412 fi
413 ;;
2abf387c 414 OSF*)
415 # Tru64 UNIX aka Digital UNIX aka OSF/1
416 if test -z "$OPTIM"; then
417 if test "x$with_optim" = x; then
418 OPTIM="-O"
419 else
420 OPTIM="$with_optim"
421 fi
422 fi
423 ;;
ef416fc2 424 SunOS*)
425 # Solaris
426 if test -z "$OPTIM"; then
427 if test "x$with_optim" = x; then
ed486911 428 OPTIM="-xO2"
ef416fc2 429 else
430 OPTIM="$with_optim $OPTIM"
431 fi
432 fi
433
ef416fc2 434 if test $PICFLAG = 1; then
435 OPTIM="-KPIC $OPTIM"
436 fi
e1d6a774 437
438 if test "x$enable_32bit" = xyes; then
439 # Compiling on a Solaris system, build 64-bit
440 # binaries with separate 32-bit libraries...
441 ARCH32FLAGS="-xarch=generic"
e1d6a774 442
443 if test "x$with_optim" = x; then
444 # Suppress all of Sun's questionable
445 # warning messages, and default to
446 # 64-bit compiles of everything else...
447 OPTIM="-w $OPTIM"
f301802f 448 fi
449
450 if test -z "$with_archflags"; then
451 if test -z "$with_arch64flags"; then
452 ARCHFLAGS="-xarch=generic64"
453 else
454 ARCHFLAGS="$with_arch64flags"
455 fi
e1d6a774 456 fi
457 else
458 if test "x$enable_64bit" = xyes; then
459 # Build 64-bit libraries...
460 ARCH64FLAGS="-xarch=generic64"
f301802f 461 fi
462
463 if test "x$with_optim" = x; then
464 # Suppress all of Sun's questionable
465 # warning messages, and default to
466 # 32-bit compiles of everything else...
467 OPTIM="-w $OPTIM"
468 fi
e1d6a774 469
f301802f 470 if test -z "$with_archflags"; then
471 if test -z "$with_arch32flags"; then
472 ARCHFLAGS="-xarch=generic"
473 else
474 ARCHFLAGS="$with_arch32flags"
e1d6a774 475 fi
e1d6a774 476 fi
477 fi
ef416fc2 478 ;;
479 UNIX_SVR*)
480 # UnixWare
481 if test -z "$OPTIM"; then
482 if test "x$with_optim" = x; then
483 OPTIM="-O"
484 else
485 OPTIM="$with_optim $OPTIM"
486 fi
487 fi
488
489 if test $PICFLAG = 1; then
490 OPTIM="-KPIC $OPTIM"
491 fi
492 ;;
493 *)
494 # Running some other operating system; inform the user they
495 # should contribute the necessary options to
496 # cups-support@cups.org...
497 echo "Building CUPS with default compiler optimizations; contact"
498 echo "cups-bugs@cups.org with uname and compiler options needed"
5bd77a73
MS
499 echo "for your platform, or set the CFLAGS and LDFLAGS environment"
500 echo "variables before running configure."
ef416fc2 501 ;;
502 esac
503fi
504
2abf387c 505# Add general compiler options per platform...
506case $uname in
507 HP-UX*)
508 # HP-UX 10.20 (at least) needs this definition to get the
509 # h_errno global...
510 OPTIM="$OPTIM -D_XOPEN_SOURCE_EXTENDED"
511
512 # HP-UX 11.00 (at least) needs this definition to get the
513 # u_short type used by the IP headers...
514 OPTIM="$OPTIM -D_INCLUDE_HPUX_SOURCE"
b94498cf 515
516 # HP-UX 11.23 (at least) needs this definition to get the
517 # IPv6 header to work...
518 OPTIM="$OPTIM -D_HPUX_SOURCE"
2abf387c 519 ;;
520
521 OSF*)
522 # Tru64 UNIX aka Digital UNIX aka OSF/1 need to be told
523 # to be POSIX-compliant...
524 OPTIM="$OPTIM -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_OSF_SOURCE"
525 ;;
526esac
ef416fc2 527
528dnl
2e4ff8af 529dnl End of "$Id: cups-compiler.m4 6975 2007-09-18 20:37:09Z mike $".
ef416fc2 530dnl