]> git.ipfire.org Git - thirdparty/cups.git/blame - config-scripts/cups-compiler.m4
Ignore generated testprint.
[thirdparty/cups.git] / config-scripts / cups-compiler.m4
CommitLineData
ef416fc2 1dnl
b19ccc9e 2dnl "$Id: cups-compiler.m4 7871 2008-08-27 21:12:43Z mike $"
ef416fc2 3dnl
4dnl Compiler stuff for the Common UNIX Printing System (CUPS).
5dnl
5bd77a73 6dnl Copyright 2007-2008 by Apple Inc.
f7deaa1a 7dnl Copyright 1997-2007 by Easy Software Products, all rights reserved.
ef416fc2 8dnl
9dnl These coded instructions, statements, and computer programs are the
bc44d920 10dnl property of Apple Inc. and are protected by Federal copyright
11dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
12dnl which should have been included with this file. If this file is
13dnl file is missing or damaged, see the license at "http://www.cups.org/".
ef416fc2 14dnl
15
16dnl Clear the debugging and non-shared library options unless the user asks
17dnl for them...
50fe7201 18INSTALL_STRIP=""
ef416fc2 19OPTIM=""
50fe7201 20AC_SUBST(INSTALL_STRIP)
ef416fc2 21AC_SUBST(OPTIM)
22
fa73b229 23AC_ARG_WITH(optim, [ --with-optim="flags" set optimization flags ])
839a51c8 24AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging, default=no])
5f64df29
MS
25AC_ARG_ENABLE(debug_printfs, [ --enable-debug-printfs turn on debug printfs, default=no])
26AC_ARG_ENABLE(unit_tests, [ --enable-unit-tests turn on unit tests, default=no])
839a51c8
MS
27
28dnl For debugging, keep symbols, otherwise strip them...
29if test x$enable_debug = xyes; then
30 OPTIM="-g"
31else
32 INSTALL_STRIP="-s"
33fi
ef416fc2 34
5f64df29
MS
35dnl Debug printfs can slow things down, so provide a separate option for that
36if test x$enable_debug_printf = xyes; then
37 CFLAGS="$CFLAGS -DDEBUG"
38fi
39
40dnl Unit tests take up time during a compile...
41if test x$enable_unit_tests = xyes; then
42 UNITTESTS="unittests"
43else
44 UNITTESTS=""
45fi
46AC_SUBST(UNITTESTS)
47
ed486911 48dnl Setup general architecture flags...
49AC_ARG_WITH(archflags, [ --with-archflags="flags"
50 set default architecture flags ])
a603edef
MS
51AC_ARG_WITH(ldarchflags, [ --with-ldarchflags="flags"
52 set default program architecture flags ])
ed486911 53
54if test -z "$with_archflags"; then
55 ARCHFLAGS=""
56else
57 ARCHFLAGS="$with_archflags"
a603edef
MS
58fi
59
60if test -z "$with_ldarchflags"; then
09a101d6 61 if test "$uname" = Darwin; then
a603edef 62 # Only create 32-bit programs by default
09a101d6 63 LDARCHFLAGS="`echo $ARCHFLAGS | sed -e '1,$s/-arch x86_64//' -e '1,$s/-arch ppc64//'`"
64 else
65 LDARCHFLAGS="$ARCHFLAGS"
66 fi
a603edef 67else
839a51c8 68 LDARCHFLAGS="$with_ldarchflags"
ed486911 69fi
70
71AC_SUBST(ARCHFLAGS)
09a101d6 72AC_SUBST(LDARCHFLAGS)
ed486911 73
e1d6a774 74dnl Setup support for separate 32/64-bit library generation...
ed486911 75AC_ARG_WITH(arch32flags, [ --with-arch32flags="flags"
76 specifies 32-bit architecture flags])
e1d6a774 77ARCH32FLAGS=""
e1d6a774 78AC_SUBST(ARCH32FLAGS)
e1d6a774 79
ed486911 80AC_ARG_WITH(arch64flags, [ --with-arch64flags="flags"
81 specifies 64-bit architecture flags])
e1d6a774 82ARCH64FLAGS=""
e1d6a774 83AC_SUBST(ARCH64FLAGS)
e1d6a774 84
f7deaa1a 85dnl Read-only data/program support on Linux...
86AC_ARG_ENABLE(relro, [ --enable-relro use GCC relro option, default=no])
87
ef416fc2 88dnl Update compiler options...
ac884b6a
MS
89CXXLIBS="${CXXLIBS:=}"
90AC_SUBST(CXXLIBS)
91
a74454a7 92PIEFLAGS=""
93AC_SUBST(PIEFLAGS)
94
f7deaa1a 95RELROFLAGS=""
96AC_SUBST(RELROFLAGS)
97
355e94dc 98LIBCUPSORDER="libcups.order"
cc0d019f 99AC_ARG_WITH(libcupsorder, [ --with-libcupsorder libcups secorder file, default=libcups.order],
355e94dc
MS
100 if test -f "$withval"; then
101 LIBCUPSORDER="$withval"
102 fi)
cc0d019f
MS
103AC_SUBST(LIBCUPSORDER)
104
355e94dc
MS
105LIBCUPSIMAGEORDER="libcupsimage.order"
106AC_ARG_WITH(libcupsimageorder, [ --with-libcupsimagesorder
107 libcupsimage secorder file, default=libcupsimage.order],
108 if test -f "$withval"; then
109 LIBCUPSIMAGEORDER="$withval"
110 fi)
cc0d019f
MS
111AC_SUBST(LIBCUPSIMAGEORDER)
112
7a14d768
MS
113PHPOPTIONS=""
114AC_SUBST(PHPOPTIONS)
115
ef416fc2 116if test -n "$GCC"; then
2abf387c 117 # Add GCC-specific compiler options...
ef416fc2 118 if test -z "$OPTIM"; then
119 if test "x$with_optim" = x; then
120 # Default to optimize-for-size and debug
121 OPTIM="-Os -g"
122 else
123 OPTIM="$with_optim $OPTIM"
124 fi
125 fi
126
a4924f6c 127 # Generate position-independent code as needed...
ef416fc2 128 if test $PICFLAG = 1 -a $uname != AIX; then
129 OPTIM="-fPIC $OPTIM"
130 fi
131
a4924f6c
MS
132 # The -fstack-protector option is available with some versions of
133 # GCC and adds "stack canaries" which detect when the return address
134 # has been overwritten, preventing many types of exploit attacks.
135 AC_MSG_CHECKING(if GCC supports -fstack-protector)
136 OLDCFLAGS="$CFLAGS"
137 CFLAGS="$CFLAGS -fstack-protector"
138 AC_TRY_COMPILE(,,
139 OPTIM="$OPTIM -fstack-protector"
140 AC_MSG_RESULT(yes),
141 AC_MSG_RESULT(no))
142 CFLAGS="$OLDCFLAGS"
143
144 # The -pie option is available with some versions of GCC and adds
145 # randomization of addresses, which avoids another class of exploits
146 # that depend on a fixed address for common functions.
147 AC_MSG_CHECKING(if GCC supports -pie)
148 OLDCFLAGS="$CFLAGS"
149 CFLAGS="$CFLAGS -pie -fPIE"
150 AC_TRY_COMPILE(,,
151 PIEFLAGS="-pie -fPIE"
152 AC_MSG_RESULT(yes),
153 AC_MSG_RESULT(no))
154 CFLAGS="$OLDCFLAGS"
ef416fc2 155
156 if test "x$with_optim" = x; then
157 # Add useful warning options for tracking down problems...
158 OPTIM="-Wall -Wno-format-y2k $OPTIM"
a4924f6c 159 # Additional warning options for development testing...
d9bca400
MS
160 if test -d .svn; then
161 OPTIM="-Wshadow -Wunused $OPTIM"
749b1e90 162 CFLAGS="-Werror-implicit-function-declaration $CFLAGS"
7a14d768 163 PHPOPTIONS="-Wno-shadow"
d9bca400 164 fi
ef416fc2 165 fi
e1d6a774 166
167 case "$uname" in
a4924f6c
MS
168 Darwin*)
169 # -D_FORTIFY_SOURCE=2 adds additional object size
170 # checking, basically wrapping all string functions
171 # with buffer-limited ones. Not strictly needed for
172 # CUPS since we already use buffer-limited calls, but
173 # this will catch any additions that are broken.
174 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
568fa3fa
MS
175
176 if test x$enable_pie = xyes; then
177 # GCC 4 on Mac OS X needs -Wl,-pie as well
178 LDFLAGS="$LDFLAGS -Wl,-pie"
179 fi
a4924f6c
MS
180 ;;
181
b86bc4cf 182 HP-UX*)
183 if test "x$enable_32bit" = xyes; then
184 # Build 32-bit libraries, 64-bit base...
185 if test -z "$with_arch32flags"; then
186 ARCH32FLAGS="-milp32"
187 else
188 ARCH32FLAGS="$with_arch32flags"
189 fi
190
191 if test -z "$with_archflags"; then
192 if test -z "$with_arch64flags"; then
193 ARCHFLAGS="-mlp64"
194 else
195 ARCHFLAGS="$with_arch64flags"
196 fi
197 fi
198 fi
199
200 if test "x$enable_64bit" = xyes; then
201 # Build 64-bit libraries, 32-bit base...
202 if test -z "$with_arch64flags"; then
203 ARCH64FLAGS="-mlp64"
204 else
205 ARCH64FLAGS="$with_arch64flags"
206 fi
207
208 if test -z "$with_archflags"; then
209 if test -z "$with_arch32flags"; then
210 ARCHFLAGS="-milp32"
211 else
212 ARCHFLAGS="$with_arch32flags"
213 fi
214 fi
215 fi
216 ;;
217
e1d6a774 218 IRIX)
219 if test "x$enable_32bit" = xyes; then
220 # Build 32-bit libraries, 64-bit base...
221 if test -z "$with_arch32flags"; then
222 ARCH32FLAGS="-n32 -mips3"
223 else
224 ARCH32FLAGS="$with_arch32flags"
225 fi
e1d6a774 226
227 if test -z "$with_archflags"; then
228 if test -z "$with_arch64flags"; then
229 ARCHFLAGS="-64 -mips4"
230 else
231 ARCHFLAGS="$with_arch64flags"
232 fi
e1d6a774 233 fi
234 fi
235
236 if test "x$enable_64bit" = xyes; then
237 # Build 64-bit libraries, 32-bit base...
238 if test -z "$with_arch64flags"; then
239 ARCH64FLAGS="-64 -mips4"
240 else
241 ARCH64FLAGS="$with_arch64flags"
242 fi
e1d6a774 243
244 if test -z "$with_archflags"; then
245 if test -z "$with_arch32flags"; then
246 ARCHFLAGS="-n32 -mips3"
247 else
248 ARCHFLAGS="$with_arch32flags"
249 fi
e1d6a774 250 fi
251 fi
252 ;;
253
254 Linux*)
a4924f6c
MS
255 # The -z relro option is provided by the Linux linker command to
256 # make relocatable data read-only.
257 if test x$enable_relro = xyes; then
258 RELROFLAGS="-Wl,-z,relro"
259 fi
260
e1d6a774 261 if test "x$enable_32bit" = xyes; then
262 # Build 32-bit libraries, 64-bit base...
263 if test -z "$with_arch32flags"; then
264 ARCH32FLAGS="-m32"
265 else
266 ARCH32FLAGS="$with_arch32flags"
267 fi
e1d6a774 268
269 if test -z "$with_archflags"; then
270 if test -z "$with_arch64flags"; then
271 ARCHFLAGS="-m64"
272 else
273 ARCHFLAGS="$with_arch64flags"
274 fi
e1d6a774 275 fi
276 fi
277
278 if test "x$enable_64bit" = xyes; then
279 # Build 64-bit libraries, 32-bit base...
280 if test -z "$with_arch64flags"; then
281 ARCH64FLAGS="-m64"
282 else
283 ARCH64FLAGS="$with_arch64flags"
284 fi
e1d6a774 285
286 if test -z "$with_archflags"; then
287 if test -z "$with_arch32flags"; then
288 ARCHFLAGS="-m32"
289 else
290 ARCHFLAGS="$with_arch32flags"
291 fi
e1d6a774 292 fi
293 fi
294 ;;
295
296 SunOS*)
297 if test "x$enable_32bit" = xyes; then
298 # Build 32-bit libraries, 64-bit base...
299 if test -z "$with_arch32flags"; then
300 ARCH32FLAGS="-m32"
301 else
302 ARCH32FLAGS="$with_arch32flags"
303 fi
e1d6a774 304
305 if test -z "$with_archflags"; then
306 if test -z "$with_arch64flags"; then
307 ARCHFLAGS="-m64"
308 else
309 ARCHFLAGS="$with_arch64flags"
310 fi
e1d6a774 311 fi
312 fi
313
314 if test "x$enable_64bit" = xyes; then
315 # Build 64-bit libraries, 32-bit base...
316 if test -z "$with_arch64flags"; then
317 ARCH64FLAGS="-m64"
318 else
319 ARCH64FLAGS="$with_arch64flags"
320 fi
e1d6a774 321
322 if test -z "$with_archflags"; then
323 if test -z "$with_arch32flags"; then
324 ARCHFLAGS="-m32"
325 else
326 ARCHFLAGS="$with_arch32flags"
327 fi
e1d6a774 328 fi
329 fi
330 ;;
331 esac
ef416fc2 332else
2abf387c 333 # Add vendor-specific compiler options...
ef416fc2 334 case $uname in
335 AIX*)
336 if test -z "$OPTIM"; then
337 if test "x$with_optim" = x; then
338 OPTIM="-O2 -qmaxmem=6000"
339 else
340 OPTIM="$with_optim $OPTIM"
341 fi
342 fi
343 ;;
344 HP-UX*)
345 if test -z "$OPTIM"; then
346 if test "x$with_optim" = x; then
347 OPTIM="+O2"
348 else
349 OPTIM="$with_optim $OPTIM"
350 fi
351 fi
352
353 CFLAGS="-Ae $CFLAGS"
354
ef416fc2 355 if test $PICFLAG = 1; then
356 OPTIM="+z $OPTIM"
357 fi
c277e2f8
MS
358
359 if test "x$enable_32bit" = xyes; then
360 # Build 32-bit libraries, 64-bit base...
361 if test -z "$with_arch32flags"; then
362 ARCH32FLAGS="+DD32"
363 else
364 ARCH32FLAGS="$with_arch32flags"
365 fi
366
367 if test -z "$with_archflags"; then
368 if test -z "$with_arch64flags"; then
369 ARCHFLAGS="+DD64"
370 else
371 ARCHFLAGS="$with_arch64flags"
372 fi
373 fi
374 fi
375
376 if test "x$enable_64bit" = xyes; then
377 # Build 64-bit libraries, 32-bit base...
378 if test -z "$with_arch64flags"; then
379 ARCH64FLAGS="+DD64"
380 else
381 ARCH64FLAGS="$with_arch64flags"
382 fi
383
384 if test -z "$with_archflags"; then
385 if test -z "$with_arch32flags"; then
386 ARCHFLAGS="+DD32"
387 else
388 ARCHFLAGS="$with_arch32flags"
389 fi
390 fi
391 fi
ef416fc2 392 ;;
393 IRIX)
394 if test -z "$OPTIM"; then
395 if test "x$with_optim" = x; then
396 OPTIM="-O2"
397 else
398 OPTIM="$with_optim $OPTIM"
399 fi
400 fi
401
e1d6a774 402 if test "x$with_optim" = x; then
403 OPTIM="-fullwarn -woff 1183,1209,1349,1506,3201 $OPTIM"
ef416fc2 404 fi
405
e1d6a774 406 if test "x$enable_32bit" = xyes; then
407 # Build 32-bit libraries, 64-bit base...
408 if test -z "$with_arch32flags"; then
409 ARCH32FLAGS="-n32 -mips3"
410 else
411 ARCH32FLAGS="$with_arch32flags"
412 fi
e1d6a774 413
414 if test -z "$with_archflags"; then
415 if test -z "$with_arch64flags"; then
416 ARCHFLAGS="-64 -mips4"
417 else
418 ARCHFLAGS="$with_arch64flags"
419 fi
e1d6a774 420 fi
421 fi
422
423 if test "x$enable_64bit" = xyes; then
424 # Build 64-bit libraries, 32-bit base...
425 if test -z "$with_arch64flags"; then
426 ARCH64FLAGS="-64 -mips4"
427 else
428 ARCH64FLAGS="$with_arch64flags"
429 fi
e1d6a774 430
431 if test -z "$with_archflags"; then
432 if test -z "$with_arch32flags"; then
433 ARCHFLAGS="-n32 -mips3"
434 else
435 ARCHFLAGS="$with_arch32flags"
436 fi
ef416fc2 437 fi
438 fi
439 ;;
2abf387c 440 OSF*)
441 # Tru64 UNIX aka Digital UNIX aka OSF/1
442 if test -z "$OPTIM"; then
443 if test "x$with_optim" = x; then
444 OPTIM="-O"
445 else
446 OPTIM="$with_optim"
447 fi
448 fi
449 ;;
ef416fc2 450 SunOS*)
451 # Solaris
452 if test -z "$OPTIM"; then
453 if test "x$with_optim" = x; then
ed486911 454 OPTIM="-xO2"
ef416fc2 455 else
456 OPTIM="$with_optim $OPTIM"
457 fi
458 fi
459
ef416fc2 460 if test $PICFLAG = 1; then
461 OPTIM="-KPIC $OPTIM"
462 fi
e1d6a774 463
464 if test "x$enable_32bit" = xyes; then
465 # Compiling on a Solaris system, build 64-bit
466 # binaries with separate 32-bit libraries...
467 ARCH32FLAGS="-xarch=generic"
e1d6a774 468
469 if test "x$with_optim" = x; then
470 # Suppress all of Sun's questionable
471 # warning messages, and default to
472 # 64-bit compiles of everything else...
473 OPTIM="-w $OPTIM"
f301802f 474 fi
475
476 if test -z "$with_archflags"; then
477 if test -z "$with_arch64flags"; then
478 ARCHFLAGS="-xarch=generic64"
479 else
480 ARCHFLAGS="$with_arch64flags"
481 fi
e1d6a774 482 fi
483 else
484 if test "x$enable_64bit" = xyes; then
485 # Build 64-bit libraries...
486 ARCH64FLAGS="-xarch=generic64"
f301802f 487 fi
488
489 if test "x$with_optim" = x; then
490 # Suppress all of Sun's questionable
491 # warning messages, and default to
492 # 32-bit compiles of everything else...
493 OPTIM="-w $OPTIM"
494 fi
e1d6a774 495
f301802f 496 if test -z "$with_archflags"; then
497 if test -z "$with_arch32flags"; then
498 ARCHFLAGS="-xarch=generic"
499 else
500 ARCHFLAGS="$with_arch32flags"
e1d6a774 501 fi
e1d6a774 502 fi
503 fi
ef416fc2 504 ;;
505 UNIX_SVR*)
506 # UnixWare
507 if test -z "$OPTIM"; then
508 if test "x$with_optim" = x; then
509 OPTIM="-O"
510 else
511 OPTIM="$with_optim $OPTIM"
512 fi
513 fi
514
515 if test $PICFLAG = 1; then
516 OPTIM="-KPIC $OPTIM"
517 fi
518 ;;
519 *)
520 # Running some other operating system; inform the user they
521 # should contribute the necessary options to
522 # cups-support@cups.org...
523 echo "Building CUPS with default compiler optimizations; contact"
524 echo "cups-bugs@cups.org with uname and compiler options needed"
5bd77a73
MS
525 echo "for your platform, or set the CFLAGS and LDFLAGS environment"
526 echo "variables before running configure."
ef416fc2 527 ;;
528 esac
529fi
530
2abf387c 531# Add general compiler options per platform...
532case $uname in
533 HP-UX*)
534 # HP-UX 10.20 (at least) needs this definition to get the
535 # h_errno global...
536 OPTIM="$OPTIM -D_XOPEN_SOURCE_EXTENDED"
537
538 # HP-UX 11.00 (at least) needs this definition to get the
539 # u_short type used by the IP headers...
540 OPTIM="$OPTIM -D_INCLUDE_HPUX_SOURCE"
b94498cf 541
542 # HP-UX 11.23 (at least) needs this definition to get the
543 # IPv6 header to work...
544 OPTIM="$OPTIM -D_HPUX_SOURCE"
2abf387c 545 ;;
546
dd1abb6b
MS
547 Linux*)
548 # glibc 2.8 and higher breaks peer credentials unless you
549 # define _GNU_SOURCE...
550 OPTIM="$OPTIM -D_GNU_SOURCE"
551 ;;
552
2abf387c 553 OSF*)
554 # Tru64 UNIX aka Digital UNIX aka OSF/1 need to be told
555 # to be POSIX-compliant...
556 OPTIM="$OPTIM -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_OSF_SOURCE"
557 ;;
558esac
ef416fc2 559
560dnl
b19ccc9e 561dnl End of "$Id: cups-compiler.m4 7871 2008-08-27 21:12:43Z mike $".
ef416fc2 562dnl