2 dnl "$Id: cups-compiler.m4 6975 2007-09-18 20:37:09Z mike $"
4 dnl Compiler stuff for the Common UNIX Printing System (CUPS).
6 dnl Copyright 2007-2008 by Apple Inc.
7 dnl Copyright 1997-2007 by Easy Software Products, all rights reserved.
9 dnl These coded instructions, statements, and computer programs are the
10 dnl property of Apple Inc. and are protected by Federal copyright
11 dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 dnl which should have been included with this file. If this file is
13 dnl file is missing or damaged, see the license at "http://www.cups.org/".
16 dnl Clear the debugging and non-shared library options unless the user asks
21 AC_ARG_WITH(optim, [ --with-optim="flags" set optimization flags ])
22 AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging, default=no],
23 [if test x$enable_debug = xyes; then
27 dnl Setup general architecture flags...
28 AC_ARG_WITH(archflags, [ --with-archflags="flags"
29 set default architecture flags ])
31 if test -z "$with_archflags"; then
35 ARCHFLAGS="$with_archflags"
36 if test "$uname" = Darwin; then
37 # Only link 32-bit programs - 64-bit is for the shared
39 LDARCHFLAGS="`echo $ARCHFLAGS | sed -e '1,$s/-arch x86_64//' -e '1,$s/-arch ppc64//'`"
41 LDARCHFLAGS="$ARCHFLAGS"
48 dnl Setup support for separate 32/64-bit library generation...
49 AC_ARG_WITH(arch32flags, [ --with-arch32flags="flags"
50 specifies 32-bit architecture flags])
54 AC_ARG_WITH(arch64flags, [ --with-arch64flags="flags"
55 specifies 64-bit architecture flags])
59 dnl Read-only data/program support on Linux...
60 AC_ARG_ENABLE(relro, [ --enable-relro use GCC relro option, default=no])
62 dnl Update compiler options...
69 LIBCUPSORDER="libcups.order"
70 AC_ARG_WITH(libcupsorder, [ --with-libcupsorder libcups secorder file, default=libcups.order],
71 if test -f "$withval"; then
72 LIBCUPSORDER="$withval"
74 AC_SUBST(LIBCUPSORDER)
76 LIBCUPSIMAGEORDER="libcupsimage.order"
77 AC_ARG_WITH(libcupsimageorder, [ --with-libcupsimagesorder
78 libcupsimage secorder file, default=libcupsimage.order],
79 if test -f "$withval"; then
80 LIBCUPSIMAGEORDER="$withval"
82 AC_SUBST(LIBCUPSIMAGEORDER)
84 if test -n "$GCC"; then
85 # Add GCC-specific compiler options...
86 if test -z "$OPTIM"; then
87 if test "x$with_optim" = x; then
88 # Default to optimize-for-size and debug
91 OPTIM="$with_optim $OPTIM"
95 # Generate position-independent code as needed...
96 if test $PICFLAG = 1 -a $uname != AIX; then
100 # The -fstack-protector option is available with some versions of
101 # GCC and adds "stack canaries" which detect when the return address
102 # has been overwritten, preventing many types of exploit attacks.
103 AC_MSG_CHECKING(if GCC supports -fstack-protector)
105 CFLAGS="$CFLAGS -fstack-protector"
107 OPTIM="$OPTIM -fstack-protector"
112 # The -pie option is available with some versions of GCC and adds
113 # randomization of addresses, which avoids another class of exploits
114 # that depend on a fixed address for common functions.
115 AC_MSG_CHECKING(if GCC supports -pie)
117 CFLAGS="$CFLAGS -pie -fPIE"
119 PIEFLAGS="-pie -fPIE"
124 if test "x$with_optim" = x; then
125 # Add useful warning options for tracking down problems...
126 OPTIM="-Wall -Wno-format-y2k $OPTIM"
127 # Additional warning options for development testing...
128 OPTIM="-Wshadow -Wunused $OPTIM"
133 # -D_FORTIFY_SOURCE=2 adds additional object size
134 # checking, basically wrapping all string functions
135 # with buffer-limited ones. Not strictly needed for
136 # CUPS since we already use buffer-limited calls, but
137 # this will catch any additions that are broken.
138 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
142 if test "x$enable_32bit" = xyes; then
143 # Build 32-bit libraries, 64-bit base...
144 if test -z "$with_arch32flags"; then
145 ARCH32FLAGS="-milp32"
147 ARCH32FLAGS="$with_arch32flags"
150 if test -z "$with_archflags"; then
151 if test -z "$with_arch64flags"; then
154 ARCHFLAGS="$with_arch64flags"
159 if test "x$enable_64bit" = xyes; then
160 # Build 64-bit libraries, 32-bit base...
161 if test -z "$with_arch64flags"; then
164 ARCH64FLAGS="$with_arch64flags"
167 if test -z "$with_archflags"; then
168 if test -z "$with_arch32flags"; then
171 ARCHFLAGS="$with_arch32flags"
178 if test "x$enable_32bit" = xyes; then
179 # Build 32-bit libraries, 64-bit base...
180 if test -z "$with_arch32flags"; then
181 ARCH32FLAGS="-n32 -mips3"
183 ARCH32FLAGS="$with_arch32flags"
186 if test -z "$with_archflags"; then
187 if test -z "$with_arch64flags"; then
188 ARCHFLAGS="-64 -mips4"
190 ARCHFLAGS="$with_arch64flags"
195 if test "x$enable_64bit" = xyes; then
196 # Build 64-bit libraries, 32-bit base...
197 if test -z "$with_arch64flags"; then
198 ARCH64FLAGS="-64 -mips4"
200 ARCH64FLAGS="$with_arch64flags"
203 if test -z "$with_archflags"; then
204 if test -z "$with_arch32flags"; then
205 ARCHFLAGS="-n32 -mips3"
207 ARCHFLAGS="$with_arch32flags"
214 # The -z relro option is provided by the Linux linker command to
215 # make relocatable data read-only.
216 if test x$enable_relro = xyes; then
217 RELROFLAGS="-Wl,-z,relro"
220 if test "x$enable_32bit" = xyes; then
221 # Build 32-bit libraries, 64-bit base...
222 if test -z "$with_arch32flags"; then
225 ARCH32FLAGS="$with_arch32flags"
228 if test -z "$with_archflags"; then
229 if test -z "$with_arch64flags"; then
232 ARCHFLAGS="$with_arch64flags"
237 if test "x$enable_64bit" = xyes; then
238 # Build 64-bit libraries, 32-bit base...
239 if test -z "$with_arch64flags"; then
242 ARCH64FLAGS="$with_arch64flags"
245 if test -z "$with_archflags"; then
246 if test -z "$with_arch32flags"; then
249 ARCHFLAGS="$with_arch32flags"
256 if test "x$enable_32bit" = xyes; then
257 # Build 32-bit libraries, 64-bit base...
258 if test -z "$with_arch32flags"; then
261 ARCH32FLAGS="$with_arch32flags"
264 if test -z "$with_archflags"; then
265 if test -z "$with_arch64flags"; then
268 ARCHFLAGS="$with_arch64flags"
273 if test "x$enable_64bit" = xyes; then
274 # Build 64-bit libraries, 32-bit base...
275 if test -z "$with_arch64flags"; then
278 ARCH64FLAGS="$with_arch64flags"
281 if test -z "$with_archflags"; then
282 if test -z "$with_arch32flags"; then
285 ARCHFLAGS="$with_arch32flags"
292 # Add vendor-specific compiler options...
295 if test -z "$OPTIM"; then
296 if test "x$with_optim" = x; then
297 OPTIM="-O2 -qmaxmem=6000"
299 OPTIM="$with_optim $OPTIM"
304 if test -z "$OPTIM"; then
305 if test "x$with_optim" = x; then
308 OPTIM="$with_optim $OPTIM"
314 if test $PICFLAG = 1; then
318 if test "x$enable_32bit" = xyes; then
319 # Build 32-bit libraries, 64-bit base...
320 if test -z "$with_arch32flags"; then
323 ARCH32FLAGS="$with_arch32flags"
326 if test -z "$with_archflags"; then
327 if test -z "$with_arch64flags"; then
330 ARCHFLAGS="$with_arch64flags"
335 if test "x$enable_64bit" = xyes; then
336 # Build 64-bit libraries, 32-bit base...
337 if test -z "$with_arch64flags"; then
340 ARCH64FLAGS="$with_arch64flags"
343 if test -z "$with_archflags"; then
344 if test -z "$with_arch32flags"; then
347 ARCHFLAGS="$with_arch32flags"
353 if test -z "$OPTIM"; then
354 if test "x$with_optim" = x; then
357 OPTIM="$with_optim $OPTIM"
361 if test "x$with_optim" = x; then
362 OPTIM="-fullwarn -woff 1183,1209,1349,1506,3201 $OPTIM"
365 if test "x$enable_32bit" = xyes; then
366 # Build 32-bit libraries, 64-bit base...
367 if test -z "$with_arch32flags"; then
368 ARCH32FLAGS="-n32 -mips3"
370 ARCH32FLAGS="$with_arch32flags"
373 if test -z "$with_archflags"; then
374 if test -z "$with_arch64flags"; then
375 ARCHFLAGS="-64 -mips4"
377 ARCHFLAGS="$with_arch64flags"
382 if test "x$enable_64bit" = xyes; then
383 # Build 64-bit libraries, 32-bit base...
384 if test -z "$with_arch64flags"; then
385 ARCH64FLAGS="-64 -mips4"
387 ARCH64FLAGS="$with_arch64flags"
390 if test -z "$with_archflags"; then
391 if test -z "$with_arch32flags"; then
392 ARCHFLAGS="-n32 -mips3"
394 ARCHFLAGS="$with_arch32flags"
400 # Tru64 UNIX aka Digital UNIX aka OSF/1
401 if test -z "$OPTIM"; then
402 if test "x$with_optim" = x; then
411 if test -z "$OPTIM"; then
412 if test "x$with_optim" = x; then
415 OPTIM="$with_optim $OPTIM"
419 if test $PICFLAG = 1; then
423 if test "x$enable_32bit" = xyes; then
424 # Compiling on a Solaris system, build 64-bit
425 # binaries with separate 32-bit libraries...
426 ARCH32FLAGS="-xarch=generic"
428 if test "x$with_optim" = x; then
429 # Suppress all of Sun's questionable
430 # warning messages, and default to
431 # 64-bit compiles of everything else...
435 if test -z "$with_archflags"; then
436 if test -z "$with_arch64flags"; then
437 ARCHFLAGS="-xarch=generic64"
439 ARCHFLAGS="$with_arch64flags"
443 if test "x$enable_64bit" = xyes; then
444 # Build 64-bit libraries...
445 ARCH64FLAGS="-xarch=generic64"
448 if test "x$with_optim" = x; then
449 # Suppress all of Sun's questionable
450 # warning messages, and default to
451 # 32-bit compiles of everything else...
455 if test -z "$with_archflags"; then
456 if test -z "$with_arch32flags"; then
457 ARCHFLAGS="-xarch=generic"
459 ARCHFLAGS="$with_arch32flags"
466 if test -z "$OPTIM"; then
467 if test "x$with_optim" = x; then
470 OPTIM="$with_optim $OPTIM"
474 if test $PICFLAG = 1; then
479 # Running some other operating system; inform the user they
480 # should contribute the necessary options to
481 # cups-support@cups.org...
482 echo "Building CUPS with default compiler optimizations; contact"
483 echo "cups-bugs@cups.org with uname and compiler options needed"
484 echo "for your platform, or set the CFLAGS and LDFLAGS environment"
485 echo "variables before running configure."
490 # Add general compiler options per platform...
493 # HP-UX 10.20 (at least) needs this definition to get the
495 OPTIM="$OPTIM -D_XOPEN_SOURCE_EXTENDED"
497 # HP-UX 11.00 (at least) needs this definition to get the
498 # u_short type used by the IP headers...
499 OPTIM="$OPTIM -D_INCLUDE_HPUX_SOURCE"
501 # HP-UX 11.23 (at least) needs this definition to get the
502 # IPv6 header to work...
503 OPTIM="$OPTIM -D_HPUX_SOURCE"
507 # Tru64 UNIX aka Digital UNIX aka OSF/1 need to be told
508 # to be POSIX-compliant...
509 OPTIM="$OPTIM -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_OSF_SOURCE"
514 dnl End of "$Id: cups-compiler.m4 6975 2007-09-18 20:37:09Z mike $".