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])
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 PHPOPTIONS="-Wno-shadow"
154 # -D_FORTIFY_SOURCE=2 adds additional object size
155 # checking, basically wrapping all string functions
156 # with buffer-limited ones. Not strictly needed for
157 # CUPS since we already use buffer-limited calls, but
158 # this will catch any additions that are broken.
159 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
161 if test x$enable_pie = xyes; then
162 # GCC 4 on Mac OS X needs -Wl,-pie as well
163 LDFLAGS="$LDFLAGS -Wl,-pie"
168 if test "x$enable_32bit" = xyes; then
169 # Build 32-bit libraries, 64-bit base...
170 if test -z "$with_arch32flags"; then
171 ARCH32FLAGS="-milp32"
173 ARCH32FLAGS="$with_arch32flags"
176 if test -z "$with_archflags"; then
177 if test -z "$with_arch64flags"; then
180 ARCHFLAGS="$with_arch64flags"
185 if test "x$enable_64bit" = xyes; then
186 # Build 64-bit libraries, 32-bit base...
187 if test -z "$with_arch64flags"; then
190 ARCH64FLAGS="$with_arch64flags"
193 if test -z "$with_archflags"; then
194 if test -z "$with_arch32flags"; then
197 ARCHFLAGS="$with_arch32flags"
204 if test "x$enable_32bit" = xyes; then
205 # Build 32-bit libraries, 64-bit base...
206 if test -z "$with_arch32flags"; then
207 ARCH32FLAGS="-n32 -mips3"
209 ARCH32FLAGS="$with_arch32flags"
212 if test -z "$with_archflags"; then
213 if test -z "$with_arch64flags"; then
214 ARCHFLAGS="-64 -mips4"
216 ARCHFLAGS="$with_arch64flags"
221 if test "x$enable_64bit" = xyes; then
222 # Build 64-bit libraries, 32-bit base...
223 if test -z "$with_arch64flags"; then
224 ARCH64FLAGS="-64 -mips4"
226 ARCH64FLAGS="$with_arch64flags"
229 if test -z "$with_archflags"; then
230 if test -z "$with_arch32flags"; then
231 ARCHFLAGS="-n32 -mips3"
233 ARCHFLAGS="$with_arch32flags"
240 # The -z relro option is provided by the Linux linker command to
241 # make relocatable data read-only.
242 if test x$enable_relro = xyes; then
243 RELROFLAGS="-Wl,-z,relro"
246 if test "x$enable_32bit" = xyes; then
247 # Build 32-bit libraries, 64-bit base...
248 if test -z "$with_arch32flags"; then
251 ARCH32FLAGS="$with_arch32flags"
254 if test -z "$with_archflags"; then
255 if test -z "$with_arch64flags"; then
258 ARCHFLAGS="$with_arch64flags"
263 if test "x$enable_64bit" = xyes; then
264 # Build 64-bit libraries, 32-bit base...
265 if test -z "$with_arch64flags"; then
268 ARCH64FLAGS="$with_arch64flags"
271 if test -z "$with_archflags"; then
272 if test -z "$with_arch32flags"; then
275 ARCHFLAGS="$with_arch32flags"
282 if test "x$enable_32bit" = xyes; then
283 # Build 32-bit libraries, 64-bit base...
284 if test -z "$with_arch32flags"; then
287 ARCH32FLAGS="$with_arch32flags"
290 if test -z "$with_archflags"; then
291 if test -z "$with_arch64flags"; then
294 ARCHFLAGS="$with_arch64flags"
299 if test "x$enable_64bit" = xyes; then
300 # Build 64-bit libraries, 32-bit base...
301 if test -z "$with_arch64flags"; then
304 ARCH64FLAGS="$with_arch64flags"
307 if test -z "$with_archflags"; then
308 if test -z "$with_arch32flags"; then
311 ARCHFLAGS="$with_arch32flags"
318 # Add vendor-specific compiler options...
321 if test -z "$OPTIM"; then
322 if test "x$with_optim" = x; then
323 OPTIM="-O2 -qmaxmem=6000"
325 OPTIM="$with_optim $OPTIM"
330 if test -z "$OPTIM"; then
331 if test "x$with_optim" = x; then
334 OPTIM="$with_optim $OPTIM"
340 if test $PICFLAG = 1; then
344 if test "x$enable_32bit" = xyes; then
345 # Build 32-bit libraries, 64-bit base...
346 if test -z "$with_arch32flags"; then
349 ARCH32FLAGS="$with_arch32flags"
352 if test -z "$with_archflags"; then
353 if test -z "$with_arch64flags"; then
356 ARCHFLAGS="$with_arch64flags"
361 if test "x$enable_64bit" = xyes; then
362 # Build 64-bit libraries, 32-bit base...
363 if test -z "$with_arch64flags"; then
366 ARCH64FLAGS="$with_arch64flags"
369 if test -z "$with_archflags"; then
370 if test -z "$with_arch32flags"; then
373 ARCHFLAGS="$with_arch32flags"
379 if test -z "$OPTIM"; then
380 if test "x$with_optim" = x; then
383 OPTIM="$with_optim $OPTIM"
387 if test "x$with_optim" = x; then
388 OPTIM="-fullwarn -woff 1183,1209,1349,1506,3201 $OPTIM"
391 if test "x$enable_32bit" = xyes; then
392 # Build 32-bit libraries, 64-bit base...
393 if test -z "$with_arch32flags"; then
394 ARCH32FLAGS="-n32 -mips3"
396 ARCH32FLAGS="$with_arch32flags"
399 if test -z "$with_archflags"; then
400 if test -z "$with_arch64flags"; then
401 ARCHFLAGS="-64 -mips4"
403 ARCHFLAGS="$with_arch64flags"
408 if test "x$enable_64bit" = xyes; then
409 # Build 64-bit libraries, 32-bit base...
410 if test -z "$with_arch64flags"; then
411 ARCH64FLAGS="-64 -mips4"
413 ARCH64FLAGS="$with_arch64flags"
416 if test -z "$with_archflags"; then
417 if test -z "$with_arch32flags"; then
418 ARCHFLAGS="-n32 -mips3"
420 ARCHFLAGS="$with_arch32flags"
426 # Tru64 UNIX aka Digital UNIX aka OSF/1
427 if test -z "$OPTIM"; then
428 if test "x$with_optim" = x; then
437 if test -z "$OPTIM"; then
438 if test "x$with_optim" = x; then
441 OPTIM="$with_optim $OPTIM"
445 if test $PICFLAG = 1; then
449 if test "x$enable_32bit" = xyes; then
450 # Compiling on a Solaris system, build 64-bit
451 # binaries with separate 32-bit libraries...
452 ARCH32FLAGS="-xarch=generic"
454 if test "x$with_optim" = x; then
455 # Suppress all of Sun's questionable
456 # warning messages, and default to
457 # 64-bit compiles of everything else...
461 if test -z "$with_archflags"; then
462 if test -z "$with_arch64flags"; then
463 ARCHFLAGS="-xarch=generic64"
465 ARCHFLAGS="$with_arch64flags"
469 if test "x$enable_64bit" = xyes; then
470 # Build 64-bit libraries...
471 ARCH64FLAGS="-xarch=generic64"
474 if test "x$with_optim" = x; then
475 # Suppress all of Sun's questionable
476 # warning messages, and default to
477 # 32-bit compiles of everything else...
481 if test -z "$with_archflags"; then
482 if test -z "$with_arch32flags"; then
483 ARCHFLAGS="-xarch=generic"
485 ARCHFLAGS="$with_arch32flags"
492 if test -z "$OPTIM"; then
493 if test "x$with_optim" = x; then
496 OPTIM="$with_optim $OPTIM"
500 if test $PICFLAG = 1; then
505 # Running some other operating system; inform the user they
506 # should contribute the necessary options to
507 # cups-support@cups.org...
508 echo "Building CUPS with default compiler optimizations; contact"
509 echo "cups-bugs@cups.org with uname and compiler options needed"
510 echo "for your platform, or set the CFLAGS and LDFLAGS environment"
511 echo "variables before running configure."
516 # Add general compiler options per platform...
519 # HP-UX 10.20 (at least) needs this definition to get the
521 OPTIM="$OPTIM -D_XOPEN_SOURCE_EXTENDED"
523 # HP-UX 11.00 (at least) needs this definition to get the
524 # u_short type used by the IP headers...
525 OPTIM="$OPTIM -D_INCLUDE_HPUX_SOURCE"
527 # HP-UX 11.23 (at least) needs this definition to get the
528 # IPv6 header to work...
529 OPTIM="$OPTIM -D_HPUX_SOURCE"
533 # Tru64 UNIX aka Digital UNIX aka OSF/1 need to be told
534 # to be POSIX-compliant...
535 OPTIM="$OPTIM -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_OSF_SOURCE"
540 dnl End of "$Id: cups-compiler.m4 6975 2007-09-18 20:37:09Z mike $".