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