2 dnl "$Id: cups-compiler.m4 6698 2007-07-20 14:15:44Z mike $"
4 dnl Compiler stuff for the Common UNIX Printing System (CUPS).
6 dnl Copyright 2007 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 Position-Independent Executable support on Linux...
60 AC_ARG_ENABLE(pie, [ --enable-pie use GCC -fPIE option, default=no])
62 dnl Read-only data/program support on Linux...
63 AC_ARG_ENABLE(relro, [ --enable-relro use GCC relro option, default=no])
65 dnl Update compiler options...
75 LIBCUPSORDER="libcups.order"
76 AC_ARG_WITH(libcupsorder, [ --with-libcupsorder libcups secorder file, default=libcups.order],
77 if test -f "$withval"; then
78 LIBCUPSORDER="$withval"
80 AC_SUBST(LIBCUPSORDER)
82 LIBCUPSIMAGEORDER="libcupsimage.order"
83 AC_ARG_WITH(libcupsimageorder, [ --with-libcupsimagesorder
84 libcupsimage secorder file, default=libcupsimage.order],
85 if test -f "$withval"; then
86 LIBCUPSIMAGEORDER="$withval"
88 AC_SUBST(LIBCUPSIMAGEORDER)
90 if test -n "$GCC"; then
91 # Add GCC-specific compiler options...
92 if test -z "$OPTIM"; then
93 if test "x$with_optim" = x; then
94 # Default to optimize-for-size and debug
97 OPTIM="$with_optim $OPTIM"
101 if test $PICFLAG = 1 -a $uname != AIX; then
107 if test x$enable_pie = xyes; then
108 PIEFLAGS="-pie -fPIE"
111 if test x$enable_relro = xyes; then
112 RELROFLAGS="-Wl,-z,relro"
117 if test x$enable_pie = xyes; then
118 echo "Sorry, --enable-pie is not supported on this OS!"
123 if test "x$with_optim" = x; then
124 # Add useful warning options for tracking down problems...
125 OPTIM="-Wall -Wno-format-y2k $OPTIM"
126 # Additional warning options for alpha testing...
127 OPTIM="-Wshadow -Wunused $OPTIM"
132 if test "x$enable_32bit" = xyes; then
133 # Build 32-bit libraries, 64-bit base...
134 if test -z "$with_arch32flags"; then
135 ARCH32FLAGS="-milp32"
137 ARCH32FLAGS="$with_arch32flags"
140 if test -z "$with_archflags"; then
141 if test -z "$with_arch64flags"; then
144 ARCHFLAGS="$with_arch64flags"
149 if test "x$enable_64bit" = xyes; then
150 # Build 64-bit libraries, 32-bit base...
151 if test -z "$with_arch64flags"; then
154 ARCH64FLAGS="$with_arch64flags"
157 if test -z "$with_archflags"; then
158 if test -z "$with_arch32flags"; then
161 ARCHFLAGS="$with_arch32flags"
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="-n32 -mips3"
173 ARCH32FLAGS="$with_arch32flags"
176 if test -z "$with_archflags"; then
177 if test -z "$with_arch64flags"; then
178 ARCHFLAGS="-64 -mips4"
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
188 ARCH64FLAGS="-64 -mips4"
190 ARCH64FLAGS="$with_arch64flags"
193 if test -z "$with_archflags"; then
194 if test -z "$with_arch32flags"; then
195 ARCHFLAGS="-n32 -mips3"
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
209 ARCH32FLAGS="$with_arch32flags"
212 if test -z "$with_archflags"; then
213 if test -z "$with_arch64flags"; then
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
226 ARCH64FLAGS="$with_arch64flags"
229 if test -z "$with_archflags"; then
230 if test -z "$with_arch32flags"; then
233 ARCHFLAGS="$with_arch32flags"
240 if test "x$enable_32bit" = xyes; then
241 # Build 32-bit libraries, 64-bit base...
242 if test -z "$with_arch32flags"; then
245 ARCH32FLAGS="$with_arch32flags"
248 if test -z "$with_archflags"; then
249 if test -z "$with_arch64flags"; then
252 ARCHFLAGS="$with_arch64flags"
257 if test "x$enable_64bit" = xyes; then
258 # Build 64-bit libraries, 32-bit base...
259 if test -z "$with_arch64flags"; then
262 ARCH64FLAGS="$with_arch64flags"
265 if test -z "$with_archflags"; then
266 if test -z "$with_arch32flags"; then
269 ARCHFLAGS="$with_arch32flags"
276 # Add vendor-specific compiler options...
279 if test -z "$OPTIM"; then
280 if test "x$with_optim" = x; then
281 OPTIM="-O2 -qmaxmem=6000"
283 OPTIM="$with_optim $OPTIM"
288 if test -z "$OPTIM"; then
289 if test "x$with_optim" = x; then
292 OPTIM="$with_optim $OPTIM"
297 # Warning 336 is "empty translation unit"
298 # Warning 829 is passing constant string as char *
299 CXXFLAGS="+W336,829 $CXXFLAGS"
301 if test $PICFLAG = 1; then
306 if test -z "$OPTIM"; then
307 if test "x$with_optim" = x; then
310 OPTIM="$with_optim $OPTIM"
314 if test "x$with_optim" = x; then
315 OPTIM="-fullwarn -woff 1183,1209,1349,1506,3201 $OPTIM"
318 if test "x$enable_32bit" = xyes; then
319 # Build 32-bit libraries, 64-bit base...
320 if test -z "$with_arch32flags"; then
321 ARCH32FLAGS="-n32 -mips3"
323 ARCH32FLAGS="$with_arch32flags"
326 if test -z "$with_archflags"; then
327 if test -z "$with_arch64flags"; then
328 ARCHFLAGS="-64 -mips4"
330 ARCHFLAGS="$with_arch64flags"
335 if test "x$enable_64bit" = xyes; then
336 # Build 64-bit libraries, 32-bit base...
337 if test -z "$with_arch64flags"; then
338 ARCH64FLAGS="-64 -mips4"
340 ARCH64FLAGS="$with_arch64flags"
343 if test -z "$with_archflags"; then
344 if test -z "$with_arch32flags"; then
345 ARCHFLAGS="-n32 -mips3"
347 ARCHFLAGS="$with_arch32flags"
353 # Tru64 UNIX aka Digital UNIX aka OSF/1
354 if test -z "$OPTIM"; then
355 if test "x$with_optim" = x; then
364 if test -z "$OPTIM"; then
365 if test "x$with_optim" = x; then
368 OPTIM="$with_optim $OPTIM"
372 if test $PICFLAG = 1; then
376 if test "x$enable_32bit" = xyes; then
377 # Compiling on a Solaris system, build 64-bit
378 # binaries with separate 32-bit libraries...
379 ARCH32FLAGS="-xarch=generic"
381 if test "x$with_optim" = x; then
382 # Suppress all of Sun's questionable
383 # warning messages, and default to
384 # 64-bit compiles of everything else...
388 if test -z "$with_archflags"; then
389 if test -z "$with_arch64flags"; then
390 ARCHFLAGS="-xarch=generic64"
392 ARCHFLAGS="$with_arch64flags"
396 if test "x$enable_64bit" = xyes; then
397 # Build 64-bit libraries...
398 ARCH64FLAGS="-xarch=generic64"
401 if test "x$with_optim" = x; then
402 # Suppress all of Sun's questionable
403 # warning messages, and default to
404 # 32-bit compiles of everything else...
408 if test -z "$with_archflags"; then
409 if test -z "$with_arch32flags"; then
410 ARCHFLAGS="-xarch=generic"
412 ARCHFLAGS="$with_arch32flags"
419 if test -z "$OPTIM"; then
420 if test "x$with_optim" = x; then
423 OPTIM="$with_optim $OPTIM"
427 if test $PICFLAG = 1; then
432 # Running some other operating system; inform the user they
433 # should contribute the necessary options to
434 # cups-support@cups.org...
435 echo "Building CUPS with default compiler optimizations; contact"
436 echo "cups-bugs@cups.org with uname and compiler options needed"
437 echo "for your platform, or set the CFLAGS and CXXFLAGS"
438 echo "environment variable before running configure."
443 # Add general compiler options per platform...
446 # HP-UX 10.20 (at least) needs this definition to get the
448 OPTIM="$OPTIM -D_XOPEN_SOURCE_EXTENDED"
450 # HP-UX 11.00 (at least) needs this definition to get the
451 # u_short type used by the IP headers...
452 OPTIM="$OPTIM -D_INCLUDE_HPUX_SOURCE"
454 # HP-UX 11.23 (at least) needs this definition to get the
455 # IPv6 header to work...
456 OPTIM="$OPTIM -D_HPUX_SOURCE"
460 # Tru64 UNIX aka Digital UNIX aka OSF/1 need to be told
461 # to be POSIX-compliant...
462 OPTIM="$OPTIM -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_OSF_SOURCE"
467 dnl End of "$Id: cups-compiler.m4 6698 2007-07-20 14:15:44Z mike $".