2 dnl "$Id: cups-compiler.m4 6562 2007-06-18 21:51:10Z mike $"
4 dnl Compiler stuff for the Common UNIX Printing System (CUPS).
6 dnl Copyright 1997-2007 by Easy Software Products, all rights reserved.
8 dnl These coded instructions, statements, and computer programs are the
9 dnl property of Easy Software Products and are protected by Federal
10 dnl copyright law. Distribution and use rights are outlined in the file
11 dnl "LICENSE.txt" which should have been included with this file. If this
12 dnl file is missing or damaged please contact Easy Software Products
15 dnl Attn: CUPS Licensing Information
16 dnl Easy Software Products
17 dnl 44141 Airport View Drive, Suite 204
18 dnl Hollywood, Maryland 20636 USA
20 dnl Voice: (301) 373-9600
21 dnl EMail: cups-info@cups.org
22 dnl WWW: http://www.cups.org
25 dnl Clear the debugging and non-shared library options unless the user asks
30 AC_ARG_WITH(optim, [ --with-optim="flags" set optimization flags ])
31 AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging, default=no],
32 [if test x$enable_debug = xyes; then
36 dnl Setup general architecture flags...
37 AC_ARG_WITH(archflags, [ --with-archflags="flags"
38 set default architecture flags ])
40 if test -z "$with_archflags"; then
44 ARCHFLAGS="$with_archflags"
45 if test "$uname" = Darwin; then
46 # Only link 32-bit programs - 64-bit is for the shared
48 LDARCHFLAGS="`echo $ARCHFLAGS | sed -e '1,$s/-arch x86_64//' -e '1,$s/-arch ppc64//'`"
50 LDARCHFLAGS="$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 Position-Independent Executable support on Linux...
69 AC_ARG_ENABLE(pie, [ --enable-pie use GCC -fPIE option, default=no])
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...
84 if test -n "$GCC"; then
85 # Add GCC-specific compiler options...
86 if test -z "$OPTIM"; then
87 if test "x$with_optim" = x; then
88 # Default to optimize-for-size and debug
91 OPTIM="$with_optim $OPTIM"
95 if test $PICFLAG = 1 -a $uname != AIX; then
101 if test x$enable_pie = xyes; then
102 PIEFLAGS="-pie -fPIE"
105 if test x$enable_relro = xyes; then
106 RELROFLAGS="-Wl,-z,relro"
111 if test x$enable_pie = xyes; then
112 echo "Sorry, --enable-pie is not supported on this OS!"
117 if test "x$with_optim" = x; then
118 # Add useful warning options for tracking down problems...
119 OPTIM="-Wall -Wno-format-y2k $OPTIM"
120 # Additional warning options for alpha testing...
121 OPTIM="-Wshadow -Wunused $OPTIM"
126 if test "x$enable_32bit" = xyes; then
127 # Build 32-bit libraries, 64-bit base...
128 if test -z "$with_arch32flags"; then
129 ARCH32FLAGS="-milp32"
131 ARCH32FLAGS="$with_arch32flags"
134 if test -z "$with_archflags"; then
135 if test -z "$with_arch64flags"; then
138 ARCHFLAGS="$with_arch64flags"
143 if test "x$enable_64bit" = xyes; then
144 # Build 64-bit libraries, 32-bit base...
145 if test -z "$with_arch64flags"; then
148 ARCH64FLAGS="$with_arch64flags"
151 if test -z "$with_archflags"; then
152 if test -z "$with_arch32flags"; then
155 ARCHFLAGS="$with_arch32flags"
162 if test "x$enable_32bit" = xyes; then
163 # Build 32-bit libraries, 64-bit base...
164 if test -z "$with_arch32flags"; then
165 ARCH32FLAGS="-n32 -mips3"
167 ARCH32FLAGS="$with_arch32flags"
170 if test -z "$with_archflags"; then
171 if test -z "$with_arch64flags"; then
172 ARCHFLAGS="-64 -mips4"
174 ARCHFLAGS="$with_arch64flags"
179 if test "x$enable_64bit" = xyes; then
180 # Build 64-bit libraries, 32-bit base...
181 if test -z "$with_arch64flags"; then
182 ARCH64FLAGS="-64 -mips4"
184 ARCH64FLAGS="$with_arch64flags"
187 if test -z "$with_archflags"; then
188 if test -z "$with_arch32flags"; then
189 ARCHFLAGS="-n32 -mips3"
191 ARCHFLAGS="$with_arch32flags"
198 if test "x$enable_32bit" = xyes; then
199 # Build 32-bit libraries, 64-bit base...
200 if test -z "$with_arch32flags"; then
203 ARCH32FLAGS="$with_arch32flags"
206 if test -z "$with_archflags"; then
207 if test -z "$with_arch64flags"; then
210 ARCHFLAGS="$with_arch64flags"
215 if test "x$enable_64bit" = xyes; then
216 # Build 64-bit libraries, 32-bit base...
217 if test -z "$with_arch64flags"; then
220 ARCH64FLAGS="$with_arch64flags"
223 if test -z "$with_archflags"; then
224 if test -z "$with_arch32flags"; then
227 ARCHFLAGS="$with_arch32flags"
234 if test "x$enable_32bit" = xyes; then
235 # Build 32-bit libraries, 64-bit base...
236 if test -z "$with_arch32flags"; then
239 ARCH32FLAGS="$with_arch32flags"
242 if test -z "$with_archflags"; then
243 if test -z "$with_arch64flags"; then
246 ARCHFLAGS="$with_arch64flags"
251 if test "x$enable_64bit" = xyes; then
252 # Build 64-bit libraries, 32-bit base...
253 if test -z "$with_arch64flags"; then
256 ARCH64FLAGS="$with_arch64flags"
259 if test -z "$with_archflags"; then
260 if test -z "$with_arch32flags"; then
263 ARCHFLAGS="$with_arch32flags"
270 # Add vendor-specific compiler options...
273 if test -z "$OPTIM"; then
274 if test "x$with_optim" = x; then
275 OPTIM="-O2 -qmaxmem=6000"
277 OPTIM="$with_optim $OPTIM"
282 if test -z "$OPTIM"; then
283 if test "x$with_optim" = x; then
286 OPTIM="$with_optim $OPTIM"
291 # Warning 336 is "empty translation unit"
292 # Warning 829 is passing constant string as char *
293 CXXFLAGS="+W336,829 $CXXFLAGS"
295 if test $PICFLAG = 1; then
300 if test -z "$OPTIM"; then
301 if test "x$with_optim" = x; then
304 OPTIM="$with_optim $OPTIM"
308 if test "x$with_optim" = x; then
309 OPTIM="-fullwarn -woff 1183,1209,1349,1506,3201 $OPTIM"
312 if test "x$enable_32bit" = xyes; then
313 # Build 32-bit libraries, 64-bit base...
314 if test -z "$with_arch32flags"; then
315 ARCH32FLAGS="-n32 -mips3"
317 ARCH32FLAGS="$with_arch32flags"
320 if test -z "$with_archflags"; then
321 if test -z "$with_arch64flags"; then
322 ARCHFLAGS="-64 -mips4"
324 ARCHFLAGS="$with_arch64flags"
329 if test "x$enable_64bit" = xyes; then
330 # Build 64-bit libraries, 32-bit base...
331 if test -z "$with_arch64flags"; then
332 ARCH64FLAGS="-64 -mips4"
334 ARCH64FLAGS="$with_arch64flags"
337 if test -z "$with_archflags"; then
338 if test -z "$with_arch32flags"; then
339 ARCHFLAGS="-n32 -mips3"
341 ARCHFLAGS="$with_arch32flags"
347 # Tru64 UNIX aka Digital UNIX aka OSF/1
348 if test -z "$OPTIM"; then
349 if test "x$with_optim" = x; then
358 if test -z "$OPTIM"; then
359 if test "x$with_optim" = x; then
362 OPTIM="$with_optim $OPTIM"
366 if test $PICFLAG = 1; then
370 if test "x$enable_32bit" = xyes; then
371 # Compiling on a Solaris system, build 64-bit
372 # binaries with separate 32-bit libraries...
373 ARCH32FLAGS="-xarch=generic"
375 if test "x$with_optim" = x; then
376 # Suppress all of Sun's questionable
377 # warning messages, and default to
378 # 64-bit compiles of everything else...
382 if test -z "$with_archflags"; then
383 if test -z "$with_arch64flags"; then
384 ARCHFLAGS="-xarch=generic64"
386 ARCHFLAGS="$with_arch64flags"
390 if test "x$enable_64bit" = xyes; then
391 # Build 64-bit libraries...
392 ARCH64FLAGS="-xarch=generic64"
395 if test "x$with_optim" = x; then
396 # Suppress all of Sun's questionable
397 # warning messages, and default to
398 # 32-bit compiles of everything else...
402 if test -z "$with_archflags"; then
403 if test -z "$with_arch32flags"; then
404 ARCHFLAGS="-xarch=generic"
406 ARCHFLAGS="$with_arch32flags"
413 if test -z "$OPTIM"; then
414 if test "x$with_optim" = x; then
417 OPTIM="$with_optim $OPTIM"
421 if test $PICFLAG = 1; then
426 # Running some other operating system; inform the user they
427 # should contribute the necessary options to
428 # cups-support@cups.org...
429 echo "Building CUPS with default compiler optimizations; contact"
430 echo "cups-bugs@cups.org with uname and compiler options needed"
431 echo "for your platform, or set the CFLAGS and CXXFLAGS"
432 echo "environment variable before running configure."
437 # Add general compiler options per platform...
440 # HP-UX 10.20 (at least) needs this definition to get the
442 OPTIM="$OPTIM -D_XOPEN_SOURCE_EXTENDED"
444 # HP-UX 11.00 (at least) needs this definition to get the
445 # u_short type used by the IP headers...
446 OPTIM="$OPTIM -D_INCLUDE_HPUX_SOURCE"
448 # HP-UX 11.23 (at least) needs this definition to get the
449 # IPv6 header to work...
450 OPTIM="$OPTIM -D_HPUX_SOURCE"
454 # Tru64 UNIX aka Digital UNIX aka OSF/1 need to be told
455 # to be POSIX-compliant...
456 OPTIM="$OPTIM -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_OSF_SOURCE"
461 dnl End of "$Id: cups-compiler.m4 6562 2007-06-18 21:51:10Z mike $".