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