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])
26 dnl For debugging, keep symbols, otherwise strip them...
27 if test x$enable_debug = xyes; then
29 CFLAGS="$CFLAGS -DDEBUG"
34 dnl Setup general architecture flags...
35 AC_ARG_WITH(archflags, [ --with-archflags="flags"
36 set default architecture flags ])
37 AC_ARG_WITH(ldarchflags, [ --with-ldarchflags="flags"
38 set default program architecture flags ])
40 if test -z "$with_archflags"; then
43 ARCHFLAGS="$with_archflags"
46 if test -z "$with_ldarchflags"; then
47 if test "$uname" = Darwin; then
48 # Only create 32-bit programs by default
49 LDARCHFLAGS="`echo $ARCHFLAGS | sed -e '1,$s/-arch x86_64//' -e '1,$s/-arch ppc64//'`"
51 LDARCHFLAGS="$ARCHFLAGS"
54 LDARCHFLAGS="$with_ldarchflags"
60 dnl Setup support for separate 32/64-bit library generation...
61 AC_ARG_WITH(arch32flags, [ --with-arch32flags="flags"
62 specifies 32-bit architecture flags])
66 AC_ARG_WITH(arch64flags, [ --with-arch64flags="flags"
67 specifies 64-bit architecture flags])
71 dnl Read-only data/program support on Linux...
72 AC_ARG_ENABLE(relro, [ --enable-relro use GCC relro option, default=no])
74 dnl Update compiler options...
75 CXXLIBS="${CXXLIBS:=}"
84 LIBCUPSORDER="libcups.order"
85 AC_ARG_WITH(libcupsorder, [ --with-libcupsorder libcups secorder file, default=libcups.order],
86 if test -f "$withval"; then
87 LIBCUPSORDER="$withval"
89 AC_SUBST(LIBCUPSORDER)
91 LIBCUPSIMAGEORDER="libcupsimage.order"
92 AC_ARG_WITH(libcupsimageorder, [ --with-libcupsimagesorder
93 libcupsimage secorder file, default=libcupsimage.order],
94 if test -f "$withval"; then
95 LIBCUPSIMAGEORDER="$withval"
97 AC_SUBST(LIBCUPSIMAGEORDER)
102 if test -n "$GCC"; then
103 # Add GCC-specific compiler options...
104 if test -z "$OPTIM"; then
105 if test "x$with_optim" = x; then
106 # Default to optimize-for-size and debug
109 OPTIM="$with_optim $OPTIM"
113 # Generate position-independent code as needed...
114 if test $PICFLAG = 1 -a $uname != AIX; then
118 # The -fstack-protector option is available with some versions of
119 # GCC and adds "stack canaries" which detect when the return address
120 # has been overwritten, preventing many types of exploit attacks.
121 AC_MSG_CHECKING(if GCC supports -fstack-protector)
123 CFLAGS="$CFLAGS -fstack-protector"
125 OPTIM="$OPTIM -fstack-protector"
130 # The -pie option is available with some versions of GCC and adds
131 # randomization of addresses, which avoids another class of exploits
132 # that depend on a fixed address for common functions.
133 AC_MSG_CHECKING(if GCC supports -pie)
135 CFLAGS="$CFLAGS -pie -fPIE"
137 PIEFLAGS="-pie -fPIE"
142 if test "x$with_optim" = x; then
143 # Add useful warning options for tracking down problems...
144 OPTIM="-Wall -Wno-format-y2k $OPTIM"
145 # Additional warning options for development testing...
146 if test -d .svn; then
147 OPTIM="-Wshadow -Wunused $OPTIM"
148 CFLAGS="-Werror-implicit-function-declaration $CFLAGS"
149 PHPOPTIONS="-Wno-shadow"
155 # -D_FORTIFY_SOURCE=2 adds additional object size
156 # checking, basically wrapping all string functions
157 # with buffer-limited ones. Not strictly needed for
158 # CUPS since we already use buffer-limited calls, but
159 # this will catch any additions that are broken.
160 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
162 if test x$enable_pie = xyes; then
163 # GCC 4 on Mac OS X needs -Wl,-pie as well
164 LDFLAGS="$LDFLAGS -Wl,-pie"
169 if test "x$enable_32bit" = xyes; then
170 # Build 32-bit libraries, 64-bit base...
171 if test -z "$with_arch32flags"; then
172 ARCH32FLAGS="-milp32"
174 ARCH32FLAGS="$with_arch32flags"
177 if test -z "$with_archflags"; then
178 if test -z "$with_arch64flags"; then
181 ARCHFLAGS="$with_arch64flags"
186 if test "x$enable_64bit" = xyes; then
187 # Build 64-bit libraries, 32-bit base...
188 if test -z "$with_arch64flags"; then
191 ARCH64FLAGS="$with_arch64flags"
194 if test -z "$with_archflags"; then
195 if test -z "$with_arch32flags"; then
198 ARCHFLAGS="$with_arch32flags"
205 if test "x$enable_32bit" = xyes; then
206 # Build 32-bit libraries, 64-bit base...
207 if test -z "$with_arch32flags"; then
208 ARCH32FLAGS="-n32 -mips3"
210 ARCH32FLAGS="$with_arch32flags"
213 if test -z "$with_archflags"; then
214 if test -z "$with_arch64flags"; then
215 ARCHFLAGS="-64 -mips4"
217 ARCHFLAGS="$with_arch64flags"
222 if test "x$enable_64bit" = xyes; then
223 # Build 64-bit libraries, 32-bit base...
224 if test -z "$with_arch64flags"; then
225 ARCH64FLAGS="-64 -mips4"
227 ARCH64FLAGS="$with_arch64flags"
230 if test -z "$with_archflags"; then
231 if test -z "$with_arch32flags"; then
232 ARCHFLAGS="-n32 -mips3"
234 ARCHFLAGS="$with_arch32flags"
241 # The -z relro option is provided by the Linux linker command to
242 # make relocatable data read-only.
243 if test x$enable_relro = xyes; then
244 RELROFLAGS="-Wl,-z,relro"
247 if test "x$enable_32bit" = xyes; then
248 # Build 32-bit libraries, 64-bit base...
249 if test -z "$with_arch32flags"; then
252 ARCH32FLAGS="$with_arch32flags"
255 if test -z "$with_archflags"; then
256 if test -z "$with_arch64flags"; then
259 ARCHFLAGS="$with_arch64flags"
264 if test "x$enable_64bit" = xyes; then
265 # Build 64-bit libraries, 32-bit base...
266 if test -z "$with_arch64flags"; then
269 ARCH64FLAGS="$with_arch64flags"
272 if test -z "$with_archflags"; then
273 if test -z "$with_arch32flags"; then
276 ARCHFLAGS="$with_arch32flags"
283 if test "x$enable_32bit" = xyes; then
284 # Build 32-bit libraries, 64-bit base...
285 if test -z "$with_arch32flags"; then
288 ARCH32FLAGS="$with_arch32flags"
291 if test -z "$with_archflags"; then
292 if test -z "$with_arch64flags"; then
295 ARCHFLAGS="$with_arch64flags"
300 if test "x$enable_64bit" = xyes; then
301 # Build 64-bit libraries, 32-bit base...
302 if test -z "$with_arch64flags"; then
305 ARCH64FLAGS="$with_arch64flags"
308 if test -z "$with_archflags"; then
309 if test -z "$with_arch32flags"; then
312 ARCHFLAGS="$with_arch32flags"
319 # Add vendor-specific compiler options...
322 if test -z "$OPTIM"; then
323 if test "x$with_optim" = x; then
324 OPTIM="-O2 -qmaxmem=6000"
326 OPTIM="$with_optim $OPTIM"
331 if test -z "$OPTIM"; then
332 if test "x$with_optim" = x; then
335 OPTIM="$with_optim $OPTIM"
341 if test $PICFLAG = 1; then
345 if test "x$enable_32bit" = xyes; then
346 # Build 32-bit libraries, 64-bit base...
347 if test -z "$with_arch32flags"; then
350 ARCH32FLAGS="$with_arch32flags"
353 if test -z "$with_archflags"; then
354 if test -z "$with_arch64flags"; then
357 ARCHFLAGS="$with_arch64flags"
362 if test "x$enable_64bit" = xyes; then
363 # Build 64-bit libraries, 32-bit base...
364 if test -z "$with_arch64flags"; then
367 ARCH64FLAGS="$with_arch64flags"
370 if test -z "$with_archflags"; then
371 if test -z "$with_arch32flags"; then
374 ARCHFLAGS="$with_arch32flags"
380 if test -z "$OPTIM"; then
381 if test "x$with_optim" = x; then
384 OPTIM="$with_optim $OPTIM"
388 if test "x$with_optim" = x; then
389 OPTIM="-fullwarn -woff 1183,1209,1349,1506,3201 $OPTIM"
392 if test "x$enable_32bit" = xyes; then
393 # Build 32-bit libraries, 64-bit base...
394 if test -z "$with_arch32flags"; then
395 ARCH32FLAGS="-n32 -mips3"
397 ARCH32FLAGS="$with_arch32flags"
400 if test -z "$with_archflags"; then
401 if test -z "$with_arch64flags"; then
402 ARCHFLAGS="-64 -mips4"
404 ARCHFLAGS="$with_arch64flags"
409 if test "x$enable_64bit" = xyes; then
410 # Build 64-bit libraries, 32-bit base...
411 if test -z "$with_arch64flags"; then
412 ARCH64FLAGS="-64 -mips4"
414 ARCH64FLAGS="$with_arch64flags"
417 if test -z "$with_archflags"; then
418 if test -z "$with_arch32flags"; then
419 ARCHFLAGS="-n32 -mips3"
421 ARCHFLAGS="$with_arch32flags"
427 # Tru64 UNIX aka Digital UNIX aka OSF/1
428 if test -z "$OPTIM"; then
429 if test "x$with_optim" = x; then
438 if test -z "$OPTIM"; then
439 if test "x$with_optim" = x; then
442 OPTIM="$with_optim $OPTIM"
446 if test $PICFLAG = 1; then
450 if test "x$enable_32bit" = xyes; then
451 # Compiling on a Solaris system, build 64-bit
452 # binaries with separate 32-bit libraries...
453 ARCH32FLAGS="-xarch=generic"
455 if test "x$with_optim" = x; then
456 # Suppress all of Sun's questionable
457 # warning messages, and default to
458 # 64-bit compiles of everything else...
462 if test -z "$with_archflags"; then
463 if test -z "$with_arch64flags"; then
464 ARCHFLAGS="-xarch=generic64"
466 ARCHFLAGS="$with_arch64flags"
470 if test "x$enable_64bit" = xyes; then
471 # Build 64-bit libraries...
472 ARCH64FLAGS="-xarch=generic64"
475 if test "x$with_optim" = x; then
476 # Suppress all of Sun's questionable
477 # warning messages, and default to
478 # 32-bit compiles of everything else...
482 if test -z "$with_archflags"; then
483 if test -z "$with_arch32flags"; then
484 ARCHFLAGS="-xarch=generic"
486 ARCHFLAGS="$with_arch32flags"
493 if test -z "$OPTIM"; then
494 if test "x$with_optim" = x; then
497 OPTIM="$with_optim $OPTIM"
501 if test $PICFLAG = 1; then
506 # Running some other operating system; inform the user they
507 # should contribute the necessary options to
508 # cups-support@cups.org...
509 echo "Building CUPS with default compiler optimizations; contact"
510 echo "cups-bugs@cups.org with uname and compiler options needed"
511 echo "for your platform, or set the CFLAGS and LDFLAGS environment"
512 echo "variables before running configure."
517 # Add general compiler options per platform...
520 # HP-UX 10.20 (at least) needs this definition to get the
522 OPTIM="$OPTIM -D_XOPEN_SOURCE_EXTENDED"
524 # HP-UX 11.00 (at least) needs this definition to get the
525 # u_short type used by the IP headers...
526 OPTIM="$OPTIM -D_INCLUDE_HPUX_SOURCE"
528 # HP-UX 11.23 (at least) needs this definition to get the
529 # IPv6 header to work...
530 OPTIM="$OPTIM -D_HPUX_SOURCE"
534 # glibc 2.8 and higher breaks peer credentials unless you
535 # define _GNU_SOURCE...
536 OPTIM="$OPTIM -D_GNU_SOURCE"
540 # Tru64 UNIX aka Digital UNIX aka OSF/1 need to be told
541 # to be POSIX-compliant...
542 OPTIM="$OPTIM -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_OSF_SOURCE"
547 dnl End of "$Id: cups-compiler.m4 7644 2008-06-16 17:15:47Z mike $".