2 dnl "$Id: cups-compiler.m4 7644 2008-06-16 17:15:47Z 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
20 AC_SUBST(INSTALL_STRIP)
23 AC_ARG_WITH(optim, [ --with-optim="flags" set optimization flags ])
24 AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging, default=no])
25 AC_ARG_ENABLE(debug_printfs, [ --enable-debug-printfs turn on debug printfs, default=no])
26 AC_ARG_ENABLE(unit_tests, [ --enable-unit-tests turn on unit tests, default=no])
28 dnl For debugging, keep symbols, otherwise strip them...
29 if test x$enable_debug = xyes; then
35 dnl Debug printfs can slow things down, so provide a separate option for that
36 if test x$enable_debug_printf = xyes; then
37 CFLAGS="$CFLAGS -DDEBUG"
40 dnl Unit tests take up time during a compile...
41 if test x$enable_unit_tests = xyes; then
48 dnl Setup general architecture flags...
49 AC_ARG_WITH(archflags, [ --with-archflags="flags"
50 set default architecture flags ])
51 AC_ARG_WITH(ldarchflags, [ --with-ldarchflags="flags"
52 set default program architecture flags ])
54 if test -z "$with_archflags"; then
57 ARCHFLAGS="$with_archflags"
60 if test -z "$with_ldarchflags"; then
61 if test "$uname" = Darwin; then
62 # Only create 32-bit programs by default
63 LDARCHFLAGS="`echo $ARCHFLAGS | sed -e '1,$s/-arch x86_64//' -e '1,$s/-arch ppc64//'`"
65 LDARCHFLAGS="$ARCHFLAGS"
68 LDARCHFLAGS="$with_ldarchflags"
74 dnl Setup support for separate 32/64-bit library generation...
75 AC_ARG_WITH(arch32flags, [ --with-arch32flags="flags"
76 specifies 32-bit architecture flags])
80 AC_ARG_WITH(arch64flags, [ --with-arch64flags="flags"
81 specifies 64-bit architecture flags])
85 dnl Read-only data/program support on Linux...
86 AC_ARG_ENABLE(relro, [ --enable-relro use GCC relro option, default=no])
88 dnl Update compiler options...
89 CXXLIBS="${CXXLIBS:=}"
98 LIBCUPSORDER="libcups.order"
99 AC_ARG_WITH(libcupsorder, [ --with-libcupsorder libcups secorder file, default=libcups.order],
100 if test -f "$withval"; then
101 LIBCUPSORDER="$withval"
103 AC_SUBST(LIBCUPSORDER)
105 LIBCUPSIMAGEORDER="libcupsimage.order"
106 AC_ARG_WITH(libcupsimageorder, [ --with-libcupsimagesorder
107 libcupsimage secorder file, default=libcupsimage.order],
108 if test -f "$withval"; then
109 LIBCUPSIMAGEORDER="$withval"
111 AC_SUBST(LIBCUPSIMAGEORDER)
116 if test -n "$GCC"; then
117 # Add GCC-specific compiler options...
118 if test -z "$OPTIM"; then
119 if test "x$with_optim" = x; then
120 # Default to optimize-for-size and debug
123 OPTIM="$with_optim $OPTIM"
127 # Generate position-independent code as needed...
128 if test $PICFLAG = 1 -a $uname != AIX; then
132 # The -fstack-protector option is available with some versions of
133 # GCC and adds "stack canaries" which detect when the return address
134 # has been overwritten, preventing many types of exploit attacks.
135 AC_MSG_CHECKING(if GCC supports -fstack-protector)
137 CFLAGS="$CFLAGS -fstack-protector"
139 OPTIM="$OPTIM -fstack-protector"
144 # The -pie option is available with some versions of GCC and adds
145 # randomization of addresses, which avoids another class of exploits
146 # that depend on a fixed address for common functions.
147 AC_MSG_CHECKING(if GCC supports -pie)
149 CFLAGS="$CFLAGS -pie -fPIE"
151 PIEFLAGS="-pie -fPIE"
156 if test "x$with_optim" = x; then
157 # Add useful warning options for tracking down problems...
158 OPTIM="-Wall -Wno-format-y2k $OPTIM"
159 # Additional warning options for development testing...
160 if test -d .svn; then
161 OPTIM="-Wshadow -Wunused $OPTIM"
162 CFLAGS="-Werror-implicit-function-declaration $CFLAGS"
163 PHPOPTIONS="-Wno-shadow"
169 # -D_FORTIFY_SOURCE=2 adds additional object size
170 # checking, basically wrapping all string functions
171 # with buffer-limited ones. Not strictly needed for
172 # CUPS since we already use buffer-limited calls, but
173 # this will catch any additions that are broken.
174 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
176 if test x$enable_pie = xyes; then
177 # GCC 4 on Mac OS X needs -Wl,-pie as well
178 LDFLAGS="$LDFLAGS -Wl,-pie"
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="-milp32"
188 ARCH32FLAGS="$with_arch32flags"
191 if test -z "$with_archflags"; then
192 if test -z "$with_arch64flags"; then
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
205 ARCH64FLAGS="$with_arch64flags"
208 if test -z "$with_archflags"; then
209 if test -z "$with_arch32flags"; then
212 ARCHFLAGS="$with_arch32flags"
219 if test "x$enable_32bit" = xyes; then
220 # Build 32-bit libraries, 64-bit base...
221 if test -z "$with_arch32flags"; then
222 ARCH32FLAGS="-n32 -mips3"
224 ARCH32FLAGS="$with_arch32flags"
227 if test -z "$with_archflags"; then
228 if test -z "$with_arch64flags"; then
229 ARCHFLAGS="-64 -mips4"
231 ARCHFLAGS="$with_arch64flags"
236 if test "x$enable_64bit" = xyes; then
237 # Build 64-bit libraries, 32-bit base...
238 if test -z "$with_arch64flags"; then
239 ARCH64FLAGS="-64 -mips4"
241 ARCH64FLAGS="$with_arch64flags"
244 if test -z "$with_archflags"; then
245 if test -z "$with_arch32flags"; then
246 ARCHFLAGS="-n32 -mips3"
248 ARCHFLAGS="$with_arch32flags"
255 # The -z relro option is provided by the Linux linker command to
256 # make relocatable data read-only.
257 if test x$enable_relro = xyes; then
258 RELROFLAGS="-Wl,-z,relro"
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 if test "x$enable_32bit" = xyes; then
298 # Build 32-bit libraries, 64-bit base...
299 if test -z "$with_arch32flags"; then
302 ARCH32FLAGS="$with_arch32flags"
305 if test -z "$with_archflags"; then
306 if test -z "$with_arch64flags"; then
309 ARCHFLAGS="$with_arch64flags"
314 if test "x$enable_64bit" = xyes; then
315 # Build 64-bit libraries, 32-bit base...
316 if test -z "$with_arch64flags"; then
319 ARCH64FLAGS="$with_arch64flags"
322 if test -z "$with_archflags"; then
323 if test -z "$with_arch32flags"; then
326 ARCHFLAGS="$with_arch32flags"
333 # Add vendor-specific compiler options...
336 if test -z "$OPTIM"; then
337 if test "x$with_optim" = x; then
338 OPTIM="-O2 -qmaxmem=6000"
340 OPTIM="$with_optim $OPTIM"
345 if test -z "$OPTIM"; then
346 if test "x$with_optim" = x; then
349 OPTIM="$with_optim $OPTIM"
355 if test $PICFLAG = 1; then
359 if test "x$enable_32bit" = xyes; then
360 # Build 32-bit libraries, 64-bit base...
361 if test -z "$with_arch32flags"; then
364 ARCH32FLAGS="$with_arch32flags"
367 if test -z "$with_archflags"; then
368 if test -z "$with_arch64flags"; then
371 ARCHFLAGS="$with_arch64flags"
376 if test "x$enable_64bit" = xyes; then
377 # Build 64-bit libraries, 32-bit base...
378 if test -z "$with_arch64flags"; then
381 ARCH64FLAGS="$with_arch64flags"
384 if test -z "$with_archflags"; then
385 if test -z "$with_arch32flags"; then
388 ARCHFLAGS="$with_arch32flags"
394 if test -z "$OPTIM"; then
395 if test "x$with_optim" = x; then
398 OPTIM="$with_optim $OPTIM"
402 if test "x$with_optim" = x; then
403 OPTIM="-fullwarn -woff 1183,1209,1349,1506,3201 $OPTIM"
406 if test "x$enable_32bit" = xyes; then
407 # Build 32-bit libraries, 64-bit base...
408 if test -z "$with_arch32flags"; then
409 ARCH32FLAGS="-n32 -mips3"
411 ARCH32FLAGS="$with_arch32flags"
414 if test -z "$with_archflags"; then
415 if test -z "$with_arch64flags"; then
416 ARCHFLAGS="-64 -mips4"
418 ARCHFLAGS="$with_arch64flags"
423 if test "x$enable_64bit" = xyes; then
424 # Build 64-bit libraries, 32-bit base...
425 if test -z "$with_arch64flags"; then
426 ARCH64FLAGS="-64 -mips4"
428 ARCH64FLAGS="$with_arch64flags"
431 if test -z "$with_archflags"; then
432 if test -z "$with_arch32flags"; then
433 ARCHFLAGS="-n32 -mips3"
435 ARCHFLAGS="$with_arch32flags"
441 # Tru64 UNIX aka Digital UNIX aka OSF/1
442 if test -z "$OPTIM"; then
443 if test "x$with_optim" = x; then
452 if test -z "$OPTIM"; then
453 if test "x$with_optim" = x; then
456 OPTIM="$with_optim $OPTIM"
460 if test $PICFLAG = 1; then
464 if test "x$enable_32bit" = xyes; then
465 # Compiling on a Solaris system, build 64-bit
466 # binaries with separate 32-bit libraries...
467 ARCH32FLAGS="-xarch=generic"
469 if test "x$with_optim" = x; then
470 # Suppress all of Sun's questionable
471 # warning messages, and default to
472 # 64-bit compiles of everything else...
476 if test -z "$with_archflags"; then
477 if test -z "$with_arch64flags"; then
478 ARCHFLAGS="-xarch=generic64"
480 ARCHFLAGS="$with_arch64flags"
484 if test "x$enable_64bit" = xyes; then
485 # Build 64-bit libraries...
486 ARCH64FLAGS="-xarch=generic64"
489 if test "x$with_optim" = x; then
490 # Suppress all of Sun's questionable
491 # warning messages, and default to
492 # 32-bit compiles of everything else...
496 if test -z "$with_archflags"; then
497 if test -z "$with_arch32flags"; then
498 ARCHFLAGS="-xarch=generic"
500 ARCHFLAGS="$with_arch32flags"
507 if test -z "$OPTIM"; then
508 if test "x$with_optim" = x; then
511 OPTIM="$with_optim $OPTIM"
515 if test $PICFLAG = 1; then
520 # Running some other operating system; inform the user they
521 # should contribute the necessary options to
522 # cups-support@cups.org...
523 echo "Building CUPS with default compiler optimizations; contact"
524 echo "cups-bugs@cups.org with uname and compiler options needed"
525 echo "for your platform, or set the CFLAGS and LDFLAGS environment"
526 echo "variables before running configure."
531 # Add general compiler options per platform...
534 # HP-UX 10.20 (at least) needs this definition to get the
536 OPTIM="$OPTIM -D_XOPEN_SOURCE_EXTENDED"
538 # HP-UX 11.00 (at least) needs this definition to get the
539 # u_short type used by the IP headers...
540 OPTIM="$OPTIM -D_INCLUDE_HPUX_SOURCE"
542 # HP-UX 11.23 (at least) needs this definition to get the
543 # IPv6 header to work...
544 OPTIM="$OPTIM -D_HPUX_SOURCE"
548 # glibc 2.8 and higher breaks peer credentials unless you
549 # define _GNU_SOURCE...
550 OPTIM="$OPTIM -D_GNU_SOURCE"
554 # Tru64 UNIX aka Digital UNIX aka OSF/1 need to be told
555 # to be POSIX-compliant...
556 OPTIM="$OPTIM -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_OSF_SOURCE"
561 dnl End of "$Id: cups-compiler.m4 7644 2008-06-16 17:15:47Z mike $".