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