]> git.ipfire.org Git - thirdparty/cups.git/blob - config-scripts/cups-compiler.m4
Merge CUPS 1.4svn-r7524.
[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 INSTALL_STRIP=""
19 OPTIM=""
20 AC_SUBST(INSTALL_STRIP)
21 AC_SUBST(OPTIM)
22
23 AC_ARG_WITH(optim, [ --with-optim="flags" set optimization flags ])
24 AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging, default=no])
25
26 dnl For debugging, keep symbols, otherwise strip them...
27 if test x$enable_debug = xyes; then
28 OPTIM="-g"
29 CFLAGS="$CFLAGS -DDEBUG"
30 else
31 INSTALL_STRIP="-s"
32 fi
33
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 ])
39
40 if test -z "$with_archflags"; then
41 ARCHFLAGS=""
42 else
43 ARCHFLAGS="$with_archflags"
44 fi
45
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//'`"
50 else
51 LDARCHFLAGS="$ARCHFLAGS"
52 fi
53 else
54 LDARCHFLAGS="$with_ldarchflags"
55 fi
56
57 AC_SUBST(ARCHFLAGS)
58 AC_SUBST(LDARCHFLAGS)
59
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])
63 ARCH32FLAGS=""
64 AC_SUBST(ARCH32FLAGS)
65
66 AC_ARG_WITH(arch64flags, [ --with-arch64flags="flags"
67 specifies 64-bit architecture flags])
68 ARCH64FLAGS=""
69 AC_SUBST(ARCH64FLAGS)
70
71 dnl Read-only data/program support on Linux...
72 AC_ARG_ENABLE(relro, [ --enable-relro use GCC relro option, default=no])
73
74 dnl Update compiler options...
75 CXXLIBS="${CXXLIBS:=}"
76 AC_SUBST(CXXLIBS)
77
78 PIEFLAGS=""
79 AC_SUBST(PIEFLAGS)
80
81 RELROFLAGS=""
82 AC_SUBST(RELROFLAGS)
83
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"
88 fi)
89 AC_SUBST(LIBCUPSORDER)
90
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"
96 fi)
97 AC_SUBST(LIBCUPSIMAGEORDER)
98
99 PHPOPTIONS=""
100 AC_SUBST(PHPOPTIONS)
101
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
107 OPTIM="-Os -g"
108 else
109 OPTIM="$with_optim $OPTIM"
110 fi
111 fi
112
113 # Generate position-independent code as needed...
114 if test $PICFLAG = 1 -a $uname != AIX; then
115 OPTIM="-fPIC $OPTIM"
116 fi
117
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)
122 OLDCFLAGS="$CFLAGS"
123 CFLAGS="$CFLAGS -fstack-protector"
124 AC_TRY_COMPILE(,,
125 OPTIM="$OPTIM -fstack-protector"
126 AC_MSG_RESULT(yes),
127 AC_MSG_RESULT(no))
128 CFLAGS="$OLDCFLAGS"
129
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)
134 OLDCFLAGS="$CFLAGS"
135 CFLAGS="$CFLAGS -pie -fPIE"
136 AC_TRY_COMPILE(,,
137 PIEFLAGS="-pie -fPIE"
138 AC_MSG_RESULT(yes),
139 AC_MSG_RESULT(no))
140 CFLAGS="$OLDCFLAGS"
141
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"
149 fi
150 fi
151
152 case "$uname" in
153 Darwin*)
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"
160
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"
164 fi
165 ;;
166
167 HP-UX*)
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"
172 else
173 ARCH32FLAGS="$with_arch32flags"
174 fi
175
176 if test -z "$with_archflags"; then
177 if test -z "$with_arch64flags"; then
178 ARCHFLAGS="-mlp64"
179 else
180 ARCHFLAGS="$with_arch64flags"
181 fi
182 fi
183 fi
184
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="-mlp64"
189 else
190 ARCH64FLAGS="$with_arch64flags"
191 fi
192
193 if test -z "$with_archflags"; then
194 if test -z "$with_arch32flags"; then
195 ARCHFLAGS="-milp32"
196 else
197 ARCHFLAGS="$with_arch32flags"
198 fi
199 fi
200 fi
201 ;;
202
203 IRIX)
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"
208 else
209 ARCH32FLAGS="$with_arch32flags"
210 fi
211
212 if test -z "$with_archflags"; then
213 if test -z "$with_arch64flags"; then
214 ARCHFLAGS="-64 -mips4"
215 else
216 ARCHFLAGS="$with_arch64flags"
217 fi
218 fi
219 fi
220
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"
225 else
226 ARCH64FLAGS="$with_arch64flags"
227 fi
228
229 if test -z "$with_archflags"; then
230 if test -z "$with_arch32flags"; then
231 ARCHFLAGS="-n32 -mips3"
232 else
233 ARCHFLAGS="$with_arch32flags"
234 fi
235 fi
236 fi
237 ;;
238
239 Linux*)
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"
244 fi
245
246 if test "x$enable_32bit" = xyes; then
247 # Build 32-bit libraries, 64-bit base...
248 if test -z "$with_arch32flags"; then
249 ARCH32FLAGS="-m32"
250 else
251 ARCH32FLAGS="$with_arch32flags"
252 fi
253
254 if test -z "$with_archflags"; then
255 if test -z "$with_arch64flags"; then
256 ARCHFLAGS="-m64"
257 else
258 ARCHFLAGS="$with_arch64flags"
259 fi
260 fi
261 fi
262
263 if test "x$enable_64bit" = xyes; then
264 # Build 64-bit libraries, 32-bit base...
265 if test -z "$with_arch64flags"; then
266 ARCH64FLAGS="-m64"
267 else
268 ARCH64FLAGS="$with_arch64flags"
269 fi
270
271 if test -z "$with_archflags"; then
272 if test -z "$with_arch32flags"; then
273 ARCHFLAGS="-m32"
274 else
275 ARCHFLAGS="$with_arch32flags"
276 fi
277 fi
278 fi
279 ;;
280
281 SunOS*)
282 if test "x$enable_32bit" = xyes; then
283 # Build 32-bit libraries, 64-bit base...
284 if test -z "$with_arch32flags"; then
285 ARCH32FLAGS="-m32"
286 else
287 ARCH32FLAGS="$with_arch32flags"
288 fi
289
290 if test -z "$with_archflags"; then
291 if test -z "$with_arch64flags"; then
292 ARCHFLAGS="-m64"
293 else
294 ARCHFLAGS="$with_arch64flags"
295 fi
296 fi
297 fi
298
299 if test "x$enable_64bit" = xyes; then
300 # Build 64-bit libraries, 32-bit base...
301 if test -z "$with_arch64flags"; then
302 ARCH64FLAGS="-m64"
303 else
304 ARCH64FLAGS="$with_arch64flags"
305 fi
306
307 if test -z "$with_archflags"; then
308 if test -z "$with_arch32flags"; then
309 ARCHFLAGS="-m32"
310 else
311 ARCHFLAGS="$with_arch32flags"
312 fi
313 fi
314 fi
315 ;;
316 esac
317 else
318 # Add vendor-specific compiler options...
319 case $uname in
320 AIX*)
321 if test -z "$OPTIM"; then
322 if test "x$with_optim" = x; then
323 OPTIM="-O2 -qmaxmem=6000"
324 else
325 OPTIM="$with_optim $OPTIM"
326 fi
327 fi
328 ;;
329 HP-UX*)
330 if test -z "$OPTIM"; then
331 if test "x$with_optim" = x; then
332 OPTIM="+O2"
333 else
334 OPTIM="$with_optim $OPTIM"
335 fi
336 fi
337
338 CFLAGS="-Ae $CFLAGS"
339
340 if test $PICFLAG = 1; then
341 OPTIM="+z $OPTIM"
342 fi
343
344 if test "x$enable_32bit" = xyes; then
345 # Build 32-bit libraries, 64-bit base...
346 if test -z "$with_arch32flags"; then
347 ARCH32FLAGS="+DD32"
348 else
349 ARCH32FLAGS="$with_arch32flags"
350 fi
351
352 if test -z "$with_archflags"; then
353 if test -z "$with_arch64flags"; then
354 ARCHFLAGS="+DD64"
355 else
356 ARCHFLAGS="$with_arch64flags"
357 fi
358 fi
359 fi
360
361 if test "x$enable_64bit" = xyes; then
362 # Build 64-bit libraries, 32-bit base...
363 if test -z "$with_arch64flags"; then
364 ARCH64FLAGS="+DD64"
365 else
366 ARCH64FLAGS="$with_arch64flags"
367 fi
368
369 if test -z "$with_archflags"; then
370 if test -z "$with_arch32flags"; then
371 ARCHFLAGS="+DD32"
372 else
373 ARCHFLAGS="$with_arch32flags"
374 fi
375 fi
376 fi
377 ;;
378 IRIX)
379 if test -z "$OPTIM"; then
380 if test "x$with_optim" = x; then
381 OPTIM="-O2"
382 else
383 OPTIM="$with_optim $OPTIM"
384 fi
385 fi
386
387 if test "x$with_optim" = x; then
388 OPTIM="-fullwarn -woff 1183,1209,1349,1506,3201 $OPTIM"
389 fi
390
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"
395 else
396 ARCH32FLAGS="$with_arch32flags"
397 fi
398
399 if test -z "$with_archflags"; then
400 if test -z "$with_arch64flags"; then
401 ARCHFLAGS="-64 -mips4"
402 else
403 ARCHFLAGS="$with_arch64flags"
404 fi
405 fi
406 fi
407
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"
412 else
413 ARCH64FLAGS="$with_arch64flags"
414 fi
415
416 if test -z "$with_archflags"; then
417 if test -z "$with_arch32flags"; then
418 ARCHFLAGS="-n32 -mips3"
419 else
420 ARCHFLAGS="$with_arch32flags"
421 fi
422 fi
423 fi
424 ;;
425 OSF*)
426 # Tru64 UNIX aka Digital UNIX aka OSF/1
427 if test -z "$OPTIM"; then
428 if test "x$with_optim" = x; then
429 OPTIM="-O"
430 else
431 OPTIM="$with_optim"
432 fi
433 fi
434 ;;
435 SunOS*)
436 # Solaris
437 if test -z "$OPTIM"; then
438 if test "x$with_optim" = x; then
439 OPTIM="-xO2"
440 else
441 OPTIM="$with_optim $OPTIM"
442 fi
443 fi
444
445 if test $PICFLAG = 1; then
446 OPTIM="-KPIC $OPTIM"
447 fi
448
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"
453
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...
458 OPTIM="-w $OPTIM"
459 fi
460
461 if test -z "$with_archflags"; then
462 if test -z "$with_arch64flags"; then
463 ARCHFLAGS="-xarch=generic64"
464 else
465 ARCHFLAGS="$with_arch64flags"
466 fi
467 fi
468 else
469 if test "x$enable_64bit" = xyes; then
470 # Build 64-bit libraries...
471 ARCH64FLAGS="-xarch=generic64"
472 fi
473
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...
478 OPTIM="-w $OPTIM"
479 fi
480
481 if test -z "$with_archflags"; then
482 if test -z "$with_arch32flags"; then
483 ARCHFLAGS="-xarch=generic"
484 else
485 ARCHFLAGS="$with_arch32flags"
486 fi
487 fi
488 fi
489 ;;
490 UNIX_SVR*)
491 # UnixWare
492 if test -z "$OPTIM"; then
493 if test "x$with_optim" = x; then
494 OPTIM="-O"
495 else
496 OPTIM="$with_optim $OPTIM"
497 fi
498 fi
499
500 if test $PICFLAG = 1; then
501 OPTIM="-KPIC $OPTIM"
502 fi
503 ;;
504 *)
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."
512 ;;
513 esac
514 fi
515
516 # Add general compiler options per platform...
517 case $uname in
518 HP-UX*)
519 # HP-UX 10.20 (at least) needs this definition to get the
520 # h_errno global...
521 OPTIM="$OPTIM -D_XOPEN_SOURCE_EXTENDED"
522
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"
526
527 # HP-UX 11.23 (at least) needs this definition to get the
528 # IPv6 header to work...
529 OPTIM="$OPTIM -D_HPUX_SOURCE"
530 ;;
531
532 OSF*)
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"
536 ;;
537 esac
538
539 dnl
540 dnl End of "$Id: cups-compiler.m4 6975 2007-09-18 20:37:09Z mike $".
541 dnl