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
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 [if test x$enable_debug = xyes; then
31 dnl Setup general architecture flags...
32 AC_ARG_WITH(archflags, [ --with-archflags="flags"
33 set default architecture flags ])
34 AC_ARG_WITH(ldarchflags, [ --with-ldarchflags="flags"
35 set default program architecture flags ])
37 if test -z "$with_archflags"; then
40 ARCHFLAGS="$with_archflags"
43 if test -z "$with_ldarchflags"; then
44 if test "$uname" = Darwin; then
45 # Only create 32-bit programs by default
46 LDARCHFLAGS="`echo $ARCHFLAGS | sed -e '1,$s/-arch x86_64//' -e '1,$s/-arch ppc64//'`"
48 LDARCHFLAGS="$ARCHFLAGS"
51 LDARCHFLAGS="$with_archflags"
57 dnl Setup support for separate 32/64-bit library generation...
58 AC_ARG_WITH(arch32flags, [ --with-arch32flags="flags"
59 specifies 32-bit architecture flags])
63 AC_ARG_WITH(arch64flags, [ --with-arch64flags="flags"
64 specifies 64-bit architecture flags])
68 dnl Read-only data/program support on Linux...
69 AC_ARG_ENABLE(relro, [ --enable-relro use GCC relro option, default=no])
71 dnl Update compiler options...
72 CXXLIBS="${CXXLIBS:=}"
81 LIBCUPSORDER="libcups.order"
82 AC_ARG_WITH(libcupsorder, [ --with-libcupsorder libcups secorder file, default=libcups.order],
83 if test -f "$withval"; then
84 LIBCUPSORDER="$withval"
86 AC_SUBST(LIBCUPSORDER)
88 LIBCUPSIMAGEORDER="libcupsimage.order"
89 AC_ARG_WITH(libcupsimageorder, [ --with-libcupsimagesorder
90 libcupsimage secorder file, default=libcupsimage.order],
91 if test -f "$withval"; then
92 LIBCUPSIMAGEORDER="$withval"
94 AC_SUBST(LIBCUPSIMAGEORDER)
96 if test -n "$GCC"; then
97 # Add GCC-specific compiler options...
98 if test -z "$OPTIM"; then
99 if test "x$with_optim" = x; then
100 # Default to optimize-for-size and debug
103 OPTIM="$with_optim $OPTIM"
107 # Generate position-independent code as needed...
108 if test $PICFLAG = 1 -a $uname != AIX; then
112 # The -fstack-protector option is available with some versions of
113 # GCC and adds "stack canaries" which detect when the return address
114 # has been overwritten, preventing many types of exploit attacks.
115 AC_MSG_CHECKING(if GCC supports -fstack-protector)
117 CFLAGS="$CFLAGS -fstack-protector"
119 OPTIM="$OPTIM -fstack-protector"
124 # The -pie option is available with some versions of GCC and adds
125 # randomization of addresses, which avoids another class of exploits
126 # that depend on a fixed address for common functions.
127 AC_MSG_CHECKING(if GCC supports -pie)
129 CFLAGS="$CFLAGS -pie -fPIE"
131 PIEFLAGS="-pie -fPIE"
136 if test "x$with_optim" = x; then
137 # Add useful warning options for tracking down problems...
138 OPTIM="-Wall -Wno-format-y2k $OPTIM"
139 # Additional warning options for development testing...
140 if test -d .svn; then
141 OPTIM="-Wshadow -Wunused $OPTIM"
147 # -D_FORTIFY_SOURCE=2 adds additional object size
148 # checking, basically wrapping all string functions
149 # with buffer-limited ones. Not strictly needed for
150 # CUPS since we already use buffer-limited calls, but
151 # this will catch any additions that are broken.
152 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
154 if test x$enable_pie = xyes; then
155 # GCC 4 on Mac OS X needs -Wl,-pie as well
156 LDFLAGS="$LDFLAGS -Wl,-pie"
161 if test "x$enable_32bit" = xyes; then
162 # Build 32-bit libraries, 64-bit base...
163 if test -z "$with_arch32flags"; then
164 ARCH32FLAGS="-milp32"
166 ARCH32FLAGS="$with_arch32flags"
169 if test -z "$with_archflags"; then
170 if test -z "$with_arch64flags"; then
173 ARCHFLAGS="$with_arch64flags"
178 if test "x$enable_64bit" = xyes; then
179 # Build 64-bit libraries, 32-bit base...
180 if test -z "$with_arch64flags"; then
183 ARCH64FLAGS="$with_arch64flags"
186 if test -z "$with_archflags"; then
187 if test -z "$with_arch32flags"; then
190 ARCHFLAGS="$with_arch32flags"
197 if test "x$enable_32bit" = xyes; then
198 # Build 32-bit libraries, 64-bit base...
199 if test -z "$with_arch32flags"; then
200 ARCH32FLAGS="-n32 -mips3"
202 ARCH32FLAGS="$with_arch32flags"
205 if test -z "$with_archflags"; then
206 if test -z "$with_arch64flags"; then
207 ARCHFLAGS="-64 -mips4"
209 ARCHFLAGS="$with_arch64flags"
214 if test "x$enable_64bit" = xyes; then
215 # Build 64-bit libraries, 32-bit base...
216 if test -z "$with_arch64flags"; then
217 ARCH64FLAGS="-64 -mips4"
219 ARCH64FLAGS="$with_arch64flags"
222 if test -z "$with_archflags"; then
223 if test -z "$with_arch32flags"; then
224 ARCHFLAGS="-n32 -mips3"
226 ARCHFLAGS="$with_arch32flags"
233 # The -z relro option is provided by the Linux linker command to
234 # make relocatable data read-only.
235 if test x$enable_relro = xyes; then
236 RELROFLAGS="-Wl,-z,relro"
239 if test "x$enable_32bit" = xyes; then
240 # Build 32-bit libraries, 64-bit base...
241 if test -z "$with_arch32flags"; then
244 ARCH32FLAGS="$with_arch32flags"
247 if test -z "$with_archflags"; then
248 if test -z "$with_arch64flags"; then
251 ARCHFLAGS="$with_arch64flags"
256 if test "x$enable_64bit" = xyes; then
257 # Build 64-bit libraries, 32-bit base...
258 if test -z "$with_arch64flags"; then
261 ARCH64FLAGS="$with_arch64flags"
264 if test -z "$with_archflags"; then
265 if test -z "$with_arch32flags"; then
268 ARCHFLAGS="$with_arch32flags"
275 if test "x$enable_32bit" = xyes; then
276 # Build 32-bit libraries, 64-bit base...
277 if test -z "$with_arch32flags"; then
280 ARCH32FLAGS="$with_arch32flags"
283 if test -z "$with_archflags"; then
284 if test -z "$with_arch64flags"; then
287 ARCHFLAGS="$with_arch64flags"
292 if test "x$enable_64bit" = xyes; then
293 # Build 64-bit libraries, 32-bit base...
294 if test -z "$with_arch64flags"; then
297 ARCH64FLAGS="$with_arch64flags"
300 if test -z "$with_archflags"; then
301 if test -z "$with_arch32flags"; then
304 ARCHFLAGS="$with_arch32flags"
311 # Add vendor-specific compiler options...
314 if test -z "$OPTIM"; then
315 if test "x$with_optim" = x; then
316 OPTIM="-O2 -qmaxmem=6000"
318 OPTIM="$with_optim $OPTIM"
323 if test -z "$OPTIM"; then
324 if test "x$with_optim" = x; then
327 OPTIM="$with_optim $OPTIM"
333 if test $PICFLAG = 1; then
337 if test "x$enable_32bit" = xyes; then
338 # Build 32-bit libraries, 64-bit base...
339 if test -z "$with_arch32flags"; then
342 ARCH32FLAGS="$with_arch32flags"
345 if test -z "$with_archflags"; then
346 if test -z "$with_arch64flags"; then
349 ARCHFLAGS="$with_arch64flags"
354 if test "x$enable_64bit" = xyes; then
355 # Build 64-bit libraries, 32-bit base...
356 if test -z "$with_arch64flags"; then
359 ARCH64FLAGS="$with_arch64flags"
362 if test -z "$with_archflags"; then
363 if test -z "$with_arch32flags"; then
366 ARCHFLAGS="$with_arch32flags"
372 if test -z "$OPTIM"; then
373 if test "x$with_optim" = x; then
376 OPTIM="$with_optim $OPTIM"
380 if test "x$with_optim" = x; then
381 OPTIM="-fullwarn -woff 1183,1209,1349,1506,3201 $OPTIM"
384 if test "x$enable_32bit" = xyes; then
385 # Build 32-bit libraries, 64-bit base...
386 if test -z "$with_arch32flags"; then
387 ARCH32FLAGS="-n32 -mips3"
389 ARCH32FLAGS="$with_arch32flags"
392 if test -z "$with_archflags"; then
393 if test -z "$with_arch64flags"; then
394 ARCHFLAGS="-64 -mips4"
396 ARCHFLAGS="$with_arch64flags"
401 if test "x$enable_64bit" = xyes; then
402 # Build 64-bit libraries, 32-bit base...
403 if test -z "$with_arch64flags"; then
404 ARCH64FLAGS="-64 -mips4"
406 ARCH64FLAGS="$with_arch64flags"
409 if test -z "$with_archflags"; then
410 if test -z "$with_arch32flags"; then
411 ARCHFLAGS="-n32 -mips3"
413 ARCHFLAGS="$with_arch32flags"
419 # Tru64 UNIX aka Digital UNIX aka OSF/1
420 if test -z "$OPTIM"; then
421 if test "x$with_optim" = x; then
430 if test -z "$OPTIM"; then
431 if test "x$with_optim" = x; then
434 OPTIM="$with_optim $OPTIM"
438 if test $PICFLAG = 1; then
442 if test "x$enable_32bit" = xyes; then
443 # Compiling on a Solaris system, build 64-bit
444 # binaries with separate 32-bit libraries...
445 ARCH32FLAGS="-xarch=generic"
447 if test "x$with_optim" = x; then
448 # Suppress all of Sun's questionable
449 # warning messages, and default to
450 # 64-bit compiles of everything else...
454 if test -z "$with_archflags"; then
455 if test -z "$with_arch64flags"; then
456 ARCHFLAGS="-xarch=generic64"
458 ARCHFLAGS="$with_arch64flags"
462 if test "x$enable_64bit" = xyes; then
463 # Build 64-bit libraries...
464 ARCH64FLAGS="-xarch=generic64"
467 if test "x$with_optim" = x; then
468 # Suppress all of Sun's questionable
469 # warning messages, and default to
470 # 32-bit compiles of everything else...
474 if test -z "$with_archflags"; then
475 if test -z "$with_arch32flags"; then
476 ARCHFLAGS="-xarch=generic"
478 ARCHFLAGS="$with_arch32flags"
485 if test -z "$OPTIM"; then
486 if test "x$with_optim" = x; then
489 OPTIM="$with_optim $OPTIM"
493 if test $PICFLAG = 1; then
498 # Running some other operating system; inform the user they
499 # should contribute the necessary options to
500 # cups-support@cups.org...
501 echo "Building CUPS with default compiler optimizations; contact"
502 echo "cups-bugs@cups.org with uname and compiler options needed"
503 echo "for your platform, or set the CFLAGS and LDFLAGS environment"
504 echo "variables before running configure."
509 # Add general compiler options per platform...
512 # HP-UX 10.20 (at least) needs this definition to get the
514 OPTIM="$OPTIM -D_XOPEN_SOURCE_EXTENDED"
516 # HP-UX 11.00 (at least) needs this definition to get the
517 # u_short type used by the IP headers...
518 OPTIM="$OPTIM -D_INCLUDE_HPUX_SOURCE"
520 # HP-UX 11.23 (at least) needs this definition to get the
521 # IPv6 header to work...
522 OPTIM="$OPTIM -D_HPUX_SOURCE"
526 # Tru64 UNIX aka Digital UNIX aka OSF/1 need to be told
527 # to be POSIX-compliant...
528 OPTIM="$OPTIM -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_OSF_SOURCE"
533 dnl End of "$Id: cups-compiler.m4 6975 2007-09-18 20:37:09Z mike $".