]> git.ipfire.org Git - thirdparty/cups.git/blame - config-scripts/cups-compiler.m4
Merge CUPS 1.4svn-r7319.
[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
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...
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...
ac884b6a
MS
63CXXLIBS="${CXXLIBS:=}"
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...
d9bca400
MS
131 if test -d .svn; then
132 OPTIM="-Wshadow -Wunused $OPTIM"
133 fi
ef416fc2 134 fi
e1d6a774 135
136 case "$uname" in
a4924f6c
MS
137 Darwin*)
138 # -D_FORTIFY_SOURCE=2 adds additional object size
139 # checking, basically wrapping all string functions
140 # with buffer-limited ones. Not strictly needed for
141 # CUPS since we already use buffer-limited calls, but
142 # this will catch any additions that are broken.
143 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
144 ;;
145
b86bc4cf 146 HP-UX*)
147 if test "x$enable_32bit" = xyes; then
148 # Build 32-bit libraries, 64-bit base...
149 if test -z "$with_arch32flags"; then
150 ARCH32FLAGS="-milp32"
151 else
152 ARCH32FLAGS="$with_arch32flags"
153 fi
154
155 if test -z "$with_archflags"; then
156 if test -z "$with_arch64flags"; then
157 ARCHFLAGS="-mlp64"
158 else
159 ARCHFLAGS="$with_arch64flags"
160 fi
161 fi
162 fi
163
164 if test "x$enable_64bit" = xyes; then
165 # Build 64-bit libraries, 32-bit base...
166 if test -z "$with_arch64flags"; then
167 ARCH64FLAGS="-mlp64"
168 else
169 ARCH64FLAGS="$with_arch64flags"
170 fi
171
172 if test -z "$with_archflags"; then
173 if test -z "$with_arch32flags"; then
174 ARCHFLAGS="-milp32"
175 else
176 ARCHFLAGS="$with_arch32flags"
177 fi
178 fi
179 fi
180 ;;
181
e1d6a774 182 IRIX)
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="-n32 -mips3"
187 else
188 ARCH32FLAGS="$with_arch32flags"
189 fi
e1d6a774 190
191 if test -z "$with_archflags"; then
192 if test -z "$with_arch64flags"; then
193 ARCHFLAGS="-64 -mips4"
194 else
195 ARCHFLAGS="$with_arch64flags"
196 fi
e1d6a774 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="-64 -mips4"
204 else
205 ARCH64FLAGS="$with_arch64flags"
206 fi
e1d6a774 207
208 if test -z "$with_archflags"; then
209 if test -z "$with_arch32flags"; then
210 ARCHFLAGS="-n32 -mips3"
211 else
212 ARCHFLAGS="$with_arch32flags"
213 fi
e1d6a774 214 fi
215 fi
216 ;;
217
218 Linux*)
a4924f6c
MS
219 # The -z relro option is provided by the Linux linker command to
220 # make relocatable data read-only.
221 if test x$enable_relro = xyes; then
222 RELROFLAGS="-Wl,-z,relro"
223 fi
224
e1d6a774 225 if test "x$enable_32bit" = xyes; then
226 # Build 32-bit libraries, 64-bit base...
227 if test -z "$with_arch32flags"; then
228 ARCH32FLAGS="-m32"
229 else
230 ARCH32FLAGS="$with_arch32flags"
231 fi
e1d6a774 232
233 if test -z "$with_archflags"; then
234 if test -z "$with_arch64flags"; then
235 ARCHFLAGS="-m64"
236 else
237 ARCHFLAGS="$with_arch64flags"
238 fi
e1d6a774 239 fi
240 fi
241
242 if test "x$enable_64bit" = xyes; then
243 # Build 64-bit libraries, 32-bit base...
244 if test -z "$with_arch64flags"; then
245 ARCH64FLAGS="-m64"
246 else
247 ARCH64FLAGS="$with_arch64flags"
248 fi
e1d6a774 249
250 if test -z "$with_archflags"; then
251 if test -z "$with_arch32flags"; then
252 ARCHFLAGS="-m32"
253 else
254 ARCHFLAGS="$with_arch32flags"
255 fi
e1d6a774 256 fi
257 fi
258 ;;
259
260 SunOS*)
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 esac
ef416fc2 296else
2abf387c 297 # Add vendor-specific compiler options...
ef416fc2 298 case $uname in
299 AIX*)
300 if test -z "$OPTIM"; then
301 if test "x$with_optim" = x; then
302 OPTIM="-O2 -qmaxmem=6000"
303 else
304 OPTIM="$with_optim $OPTIM"
305 fi
306 fi
307 ;;
308 HP-UX*)
309 if test -z "$OPTIM"; then
310 if test "x$with_optim" = x; then
311 OPTIM="+O2"
312 else
313 OPTIM="$with_optim $OPTIM"
314 fi
315 fi
316
317 CFLAGS="-Ae $CFLAGS"
318
ef416fc2 319 if test $PICFLAG = 1; then
320 OPTIM="+z $OPTIM"
321 fi
c277e2f8
MS
322
323 if test "x$enable_32bit" = xyes; then
324 # Build 32-bit libraries, 64-bit base...
325 if test -z "$with_arch32flags"; then
326 ARCH32FLAGS="+DD32"
327 else
328 ARCH32FLAGS="$with_arch32flags"
329 fi
330
331 if test -z "$with_archflags"; then
332 if test -z "$with_arch64flags"; then
333 ARCHFLAGS="+DD64"
334 else
335 ARCHFLAGS="$with_arch64flags"
336 fi
337 fi
338 fi
339
340 if test "x$enable_64bit" = xyes; then
341 # Build 64-bit libraries, 32-bit base...
342 if test -z "$with_arch64flags"; then
343 ARCH64FLAGS="+DD64"
344 else
345 ARCH64FLAGS="$with_arch64flags"
346 fi
347
348 if test -z "$with_archflags"; then
349 if test -z "$with_arch32flags"; then
350 ARCHFLAGS="+DD32"
351 else
352 ARCHFLAGS="$with_arch32flags"
353 fi
354 fi
355 fi
ef416fc2 356 ;;
357 IRIX)
358 if test -z "$OPTIM"; then
359 if test "x$with_optim" = x; then
360 OPTIM="-O2"
361 else
362 OPTIM="$with_optim $OPTIM"
363 fi
364 fi
365
e1d6a774 366 if test "x$with_optim" = x; then
367 OPTIM="-fullwarn -woff 1183,1209,1349,1506,3201 $OPTIM"
ef416fc2 368 fi
369
e1d6a774 370 if test "x$enable_32bit" = xyes; then
371 # Build 32-bit libraries, 64-bit base...
372 if test -z "$with_arch32flags"; then
373 ARCH32FLAGS="-n32 -mips3"
374 else
375 ARCH32FLAGS="$with_arch32flags"
376 fi
e1d6a774 377
378 if test -z "$with_archflags"; then
379 if test -z "$with_arch64flags"; then
380 ARCHFLAGS="-64 -mips4"
381 else
382 ARCHFLAGS="$with_arch64flags"
383 fi
e1d6a774 384 fi
385 fi
386
387 if test "x$enable_64bit" = xyes; then
388 # Build 64-bit libraries, 32-bit base...
389 if test -z "$with_arch64flags"; then
390 ARCH64FLAGS="-64 -mips4"
391 else
392 ARCH64FLAGS="$with_arch64flags"
393 fi
e1d6a774 394
395 if test -z "$with_archflags"; then
396 if test -z "$with_arch32flags"; then
397 ARCHFLAGS="-n32 -mips3"
398 else
399 ARCHFLAGS="$with_arch32flags"
400 fi
ef416fc2 401 fi
402 fi
403 ;;
2abf387c 404 OSF*)
405 # Tru64 UNIX aka Digital UNIX aka OSF/1
406 if test -z "$OPTIM"; then
407 if test "x$with_optim" = x; then
408 OPTIM="-O"
409 else
410 OPTIM="$with_optim"
411 fi
412 fi
413 ;;
ef416fc2 414 SunOS*)
415 # Solaris
416 if test -z "$OPTIM"; then
417 if test "x$with_optim" = x; then
ed486911 418 OPTIM="-xO2"
ef416fc2 419 else
420 OPTIM="$with_optim $OPTIM"
421 fi
422 fi
423
ef416fc2 424 if test $PICFLAG = 1; then
425 OPTIM="-KPIC $OPTIM"
426 fi
e1d6a774 427
428 if test "x$enable_32bit" = xyes; then
429 # Compiling on a Solaris system, build 64-bit
430 # binaries with separate 32-bit libraries...
431 ARCH32FLAGS="-xarch=generic"
e1d6a774 432
433 if test "x$with_optim" = x; then
434 # Suppress all of Sun's questionable
435 # warning messages, and default to
436 # 64-bit compiles of everything else...
437 OPTIM="-w $OPTIM"
f301802f 438 fi
439
440 if test -z "$with_archflags"; then
441 if test -z "$with_arch64flags"; then
442 ARCHFLAGS="-xarch=generic64"
443 else
444 ARCHFLAGS="$with_arch64flags"
445 fi
e1d6a774 446 fi
447 else
448 if test "x$enable_64bit" = xyes; then
449 # Build 64-bit libraries...
450 ARCH64FLAGS="-xarch=generic64"
f301802f 451 fi
452
453 if test "x$with_optim" = x; then
454 # Suppress all of Sun's questionable
455 # warning messages, and default to
456 # 32-bit compiles of everything else...
457 OPTIM="-w $OPTIM"
458 fi
e1d6a774 459
f301802f 460 if test -z "$with_archflags"; then
461 if test -z "$with_arch32flags"; then
462 ARCHFLAGS="-xarch=generic"
463 else
464 ARCHFLAGS="$with_arch32flags"
e1d6a774 465 fi
e1d6a774 466 fi
467 fi
ef416fc2 468 ;;
469 UNIX_SVR*)
470 # UnixWare
471 if test -z "$OPTIM"; then
472 if test "x$with_optim" = x; then
473 OPTIM="-O"
474 else
475 OPTIM="$with_optim $OPTIM"
476 fi
477 fi
478
479 if test $PICFLAG = 1; then
480 OPTIM="-KPIC $OPTIM"
481 fi
482 ;;
483 *)
484 # Running some other operating system; inform the user they
485 # should contribute the necessary options to
486 # cups-support@cups.org...
487 echo "Building CUPS with default compiler optimizations; contact"
488 echo "cups-bugs@cups.org with uname and compiler options needed"
5bd77a73
MS
489 echo "for your platform, or set the CFLAGS and LDFLAGS environment"
490 echo "variables before running configure."
ef416fc2 491 ;;
492 esac
493fi
494
2abf387c 495# Add general compiler options per platform...
496case $uname in
497 HP-UX*)
498 # HP-UX 10.20 (at least) needs this definition to get the
499 # h_errno global...
500 OPTIM="$OPTIM -D_XOPEN_SOURCE_EXTENDED"
501
502 # HP-UX 11.00 (at least) needs this definition to get the
503 # u_short type used by the IP headers...
504 OPTIM="$OPTIM -D_INCLUDE_HPUX_SOURCE"
b94498cf 505
506 # HP-UX 11.23 (at least) needs this definition to get the
507 # IPv6 header to work...
508 OPTIM="$OPTIM -D_HPUX_SOURCE"
2abf387c 509 ;;
510
511 OSF*)
512 # Tru64 UNIX aka Digital UNIX aka OSF/1 need to be told
513 # to be POSIX-compliant...
514 OPTIM="$OPTIM -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_OSF_SOURCE"
515 ;;
516esac
ef416fc2 517
518dnl
2e4ff8af 519dnl End of "$Id: cups-compiler.m4 6975 2007-09-18 20:37:09Z mike $".
ef416fc2 520dnl