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...
63 CXXLIBS="${CXXLIBS:=}"
72 LIBCUPSORDER="libcups.order"
73 AC_ARG_WITH(libcupsorder, [ --with-libcupsorder libcups secorder file, default=libcups.order],
74 if test -f "$withval"; then
75 LIBCUPSORDER="$withval"
77 AC_SUBST(LIBCUPSORDER)
79 LIBCUPSIMAGEORDER="libcupsimage.order"
80 AC_ARG_WITH(libcupsimageorder, [ --with-libcupsimagesorder
81 libcupsimage secorder file, default=libcupsimage.order],
82 if test -f "$withval"; then
83 LIBCUPSIMAGEORDER="$withval"
85 AC_SUBST(LIBCUPSIMAGEORDER)
87 if test -n "$GCC"; then
88 # Add GCC-specific compiler options...
89 if test -z "$OPTIM"; then
90 if test "x$with_optim" = x; then
91 # Default to optimize-for-size and debug
94 OPTIM="$with_optim $OPTIM"
98 # Generate position-independent code as needed...
99 if test $PICFLAG = 1 -a $uname != AIX; then
103 # The -fstack-protector option is available with some versions of
104 # GCC and adds "stack canaries" which detect when the return address
105 # has been overwritten, preventing many types of exploit attacks.
106 AC_MSG_CHECKING(if GCC supports -fstack-protector)
108 CFLAGS="$CFLAGS -fstack-protector"
110 OPTIM="$OPTIM -fstack-protector"
115 # The -pie option is available with some versions of GCC and adds
116 # randomization of addresses, which avoids another class of exploits
117 # that depend on a fixed address for common functions.
118 AC_MSG_CHECKING(if GCC supports -pie)
120 CFLAGS="$CFLAGS -pie -fPIE"
122 PIEFLAGS="-pie -fPIE"
127 if test "x$with_optim" = x; then
128 # Add useful warning options for tracking down problems...
129 OPTIM="-Wall -Wno-format-y2k $OPTIM"
130 # Additional warning options for development testing...
131 if test -d .svn; then
132 OPTIM="-Wshadow -Wunused $OPTIM"
138 # -D_FORTIFY_SOURCE=2 adds additional object size
139 # checking, basically wrapping all string functions
140 # with buffer-limited ones. Not strictly needed for
141 # CUPS since we already use buffer-limited calls, but
142 # this will catch any additions that are broken.
143 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
147 if test "x$enable_32bit" = xyes; then
148 # Build 32-bit libraries, 64-bit base...
149 if test -z "$with_arch32flags"; then
150 ARCH32FLAGS="-milp32"
152 ARCH32FLAGS="$with_arch32flags"
155 if test -z "$with_archflags"; then
156 if test -z "$with_arch64flags"; then
159 ARCHFLAGS="$with_arch64flags"
164 if test "x$enable_64bit" = xyes; then
165 # Build 64-bit libraries, 32-bit base...
166 if test -z "$with_arch64flags"; then
169 ARCH64FLAGS="$with_arch64flags"
172 if test -z "$with_archflags"; then
173 if test -z "$with_arch32flags"; then
176 ARCHFLAGS="$with_arch32flags"
183 if test "x$enable_32bit" = xyes; then
184 # Build 32-bit libraries, 64-bit base...
185 if test -z "$with_arch32flags"; then
186 ARCH32FLAGS="-n32 -mips3"
188 ARCH32FLAGS="$with_arch32flags"
191 if test -z "$with_archflags"; then
192 if test -z "$with_arch64flags"; then
193 ARCHFLAGS="-64 -mips4"
195 ARCHFLAGS="$with_arch64flags"
200 if test "x$enable_64bit" = xyes; then
201 # Build 64-bit libraries, 32-bit base...
202 if test -z "$with_arch64flags"; then
203 ARCH64FLAGS="-64 -mips4"
205 ARCH64FLAGS="$with_arch64flags"
208 if test -z "$with_archflags"; then
209 if test -z "$with_arch32flags"; then
210 ARCHFLAGS="-n32 -mips3"
212 ARCHFLAGS="$with_arch32flags"
219 # The -z relro option is provided by the Linux linker command to
220 # make relocatable data read-only.
221 if test x$enable_relro = xyes; then
222 RELROFLAGS="-Wl,-z,relro"
225 if test "x$enable_32bit" = xyes; then
226 # Build 32-bit libraries, 64-bit base...
227 if test -z "$with_arch32flags"; then
230 ARCH32FLAGS="$with_arch32flags"
233 if test -z "$with_archflags"; then
234 if test -z "$with_arch64flags"; then
237 ARCHFLAGS="$with_arch64flags"
242 if test "x$enable_64bit" = xyes; then
243 # Build 64-bit libraries, 32-bit base...
244 if test -z "$with_arch64flags"; then
247 ARCH64FLAGS="$with_arch64flags"
250 if test -z "$with_archflags"; then
251 if test -z "$with_arch32flags"; then
254 ARCHFLAGS="$with_arch32flags"
261 if test "x$enable_32bit" = xyes; then
262 # Build 32-bit libraries, 64-bit base...
263 if test -z "$with_arch32flags"; then
266 ARCH32FLAGS="$with_arch32flags"
269 if test -z "$with_archflags"; then
270 if test -z "$with_arch64flags"; then
273 ARCHFLAGS="$with_arch64flags"
278 if test "x$enable_64bit" = xyes; then
279 # Build 64-bit libraries, 32-bit base...
280 if test -z "$with_arch64flags"; then
283 ARCH64FLAGS="$with_arch64flags"
286 if test -z "$with_archflags"; then
287 if test -z "$with_arch32flags"; then
290 ARCHFLAGS="$with_arch32flags"
297 # Add vendor-specific compiler options...
300 if test -z "$OPTIM"; then
301 if test "x$with_optim" = x; then
302 OPTIM="-O2 -qmaxmem=6000"
304 OPTIM="$with_optim $OPTIM"
309 if test -z "$OPTIM"; then
310 if test "x$with_optim" = x; then
313 OPTIM="$with_optim $OPTIM"
319 if test $PICFLAG = 1; then
323 if test "x$enable_32bit" = xyes; then
324 # Build 32-bit libraries, 64-bit base...
325 if test -z "$with_arch32flags"; then
328 ARCH32FLAGS="$with_arch32flags"
331 if test -z "$with_archflags"; then
332 if test -z "$with_arch64flags"; then
335 ARCHFLAGS="$with_arch64flags"
340 if test "x$enable_64bit" = xyes; then
341 # Build 64-bit libraries, 32-bit base...
342 if test -z "$with_arch64flags"; then
345 ARCH64FLAGS="$with_arch64flags"
348 if test -z "$with_archflags"; then
349 if test -z "$with_arch32flags"; then
352 ARCHFLAGS="$with_arch32flags"
358 if test -z "$OPTIM"; then
359 if test "x$with_optim" = x; then
362 OPTIM="$with_optim $OPTIM"
366 if test "x$with_optim" = x; then
367 OPTIM="-fullwarn -woff 1183,1209,1349,1506,3201 $OPTIM"
370 if test "x$enable_32bit" = xyes; then
371 # Build 32-bit libraries, 64-bit base...
372 if test -z "$with_arch32flags"; then
373 ARCH32FLAGS="-n32 -mips3"
375 ARCH32FLAGS="$with_arch32flags"
378 if test -z "$with_archflags"; then
379 if test -z "$with_arch64flags"; then
380 ARCHFLAGS="-64 -mips4"
382 ARCHFLAGS="$with_arch64flags"
387 if test "x$enable_64bit" = xyes; then
388 # Build 64-bit libraries, 32-bit base...
389 if test -z "$with_arch64flags"; then
390 ARCH64FLAGS="-64 -mips4"
392 ARCH64FLAGS="$with_arch64flags"
395 if test -z "$with_archflags"; then
396 if test -z "$with_arch32flags"; then
397 ARCHFLAGS="-n32 -mips3"
399 ARCHFLAGS="$with_arch32flags"
405 # Tru64 UNIX aka Digital UNIX aka OSF/1
406 if test -z "$OPTIM"; then
407 if test "x$with_optim" = x; then
416 if test -z "$OPTIM"; then
417 if test "x$with_optim" = x; then
420 OPTIM="$with_optim $OPTIM"
424 if test $PICFLAG = 1; then
428 if test "x$enable_32bit" = xyes; then
429 # Compiling on a Solaris system, build 64-bit
430 # binaries with separate 32-bit libraries...
431 ARCH32FLAGS="-xarch=generic"
433 if test "x$with_optim" = x; then
434 # Suppress all of Sun's questionable
435 # warning messages, and default to
436 # 64-bit compiles of everything else...
440 if test -z "$with_archflags"; then
441 if test -z "$with_arch64flags"; then
442 ARCHFLAGS="-xarch=generic64"
444 ARCHFLAGS="$with_arch64flags"
448 if test "x$enable_64bit" = xyes; then
449 # Build 64-bit libraries...
450 ARCH64FLAGS="-xarch=generic64"
453 if test "x$with_optim" = x; then
454 # Suppress all of Sun's questionable
455 # warning messages, and default to
456 # 32-bit compiles of everything else...
460 if test -z "$with_archflags"; then
461 if test -z "$with_arch32flags"; then
462 ARCHFLAGS="-xarch=generic"
464 ARCHFLAGS="$with_arch32flags"
471 if test -z "$OPTIM"; then
472 if test "x$with_optim" = x; then
475 OPTIM="$with_optim $OPTIM"
479 if test $PICFLAG = 1; then
484 # Running some other operating system; inform the user they
485 # should contribute the necessary options to
486 # cups-support@cups.org...
487 echo "Building CUPS with default compiler optimizations; contact"
488 echo "cups-bugs@cups.org with uname and compiler options needed"
489 echo "for your platform, or set the CFLAGS and LDFLAGS environment"
490 echo "variables before running configure."
495 # Add general compiler options per platform...
498 # HP-UX 10.20 (at least) needs this definition to get the
500 OPTIM="$OPTIM -D_XOPEN_SOURCE_EXTENDED"
502 # HP-UX 11.00 (at least) needs this definition to get the
503 # u_short type used by the IP headers...
504 OPTIM="$OPTIM -D_INCLUDE_HPUX_SOURCE"
506 # HP-UX 11.23 (at least) needs this definition to get the
507 # IPv6 header to work...
508 OPTIM="$OPTIM -D_HPUX_SOURCE"
512 # Tru64 UNIX aka Digital UNIX aka OSF/1 need to be told
513 # to be POSIX-compliant...
514 OPTIM="$OPTIM -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_OSF_SOURCE"
519 dnl End of "$Id: cups-compiler.m4 6975 2007-09-18 20:37:09Z mike $".