]> git.ipfire.org Git - thirdparty/cups.git/blame - config-scripts/cups-compiler.m4
Merge changes from CUPS 1.4svn-r7626.
[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...
50fe7201 18INSTALL_STRIP=""
ef416fc2 19OPTIM=""
50fe7201 20AC_SUBST(INSTALL_STRIP)
ef416fc2 21AC_SUBST(OPTIM)
22
fa73b229 23AC_ARG_WITH(optim, [ --with-optim="flags" set optimization flags ])
839a51c8
MS
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"
ae71f5de 29 CFLAGS="$CFLAGS -DDEBUG"
839a51c8
MS
30else
31 INSTALL_STRIP="-s"
32fi
ef416fc2 33
ed486911 34dnl Setup general architecture flags...
35AC_ARG_WITH(archflags, [ --with-archflags="flags"
36 set default architecture flags ])
a603edef
MS
37AC_ARG_WITH(ldarchflags, [ --with-ldarchflags="flags"
38 set default program architecture flags ])
ed486911 39
40if test -z "$with_archflags"; then
41 ARCHFLAGS=""
42else
43 ARCHFLAGS="$with_archflags"
a603edef
MS
44fi
45
46if test -z "$with_ldarchflags"; then
09a101d6 47 if test "$uname" = Darwin; then
a603edef 48 # Only create 32-bit programs by default
09a101d6 49 LDARCHFLAGS="`echo $ARCHFLAGS | sed -e '1,$s/-arch x86_64//' -e '1,$s/-arch ppc64//'`"
50 else
51 LDARCHFLAGS="$ARCHFLAGS"
52 fi
a603edef 53else
839a51c8 54 LDARCHFLAGS="$with_ldarchflags"
ed486911 55fi
56
57AC_SUBST(ARCHFLAGS)
09a101d6 58AC_SUBST(LDARCHFLAGS)
ed486911 59
e1d6a774 60dnl Setup support for separate 32/64-bit library generation...
ed486911 61AC_ARG_WITH(arch32flags, [ --with-arch32flags="flags"
62 specifies 32-bit architecture flags])
e1d6a774 63ARCH32FLAGS=""
e1d6a774 64AC_SUBST(ARCH32FLAGS)
e1d6a774 65
ed486911 66AC_ARG_WITH(arch64flags, [ --with-arch64flags="flags"
67 specifies 64-bit architecture flags])
e1d6a774 68ARCH64FLAGS=""
e1d6a774 69AC_SUBST(ARCH64FLAGS)
e1d6a774 70
f7deaa1a 71dnl Read-only data/program support on Linux...
72AC_ARG_ENABLE(relro, [ --enable-relro use GCC relro option, default=no])
73
ef416fc2 74dnl Update compiler options...
ac884b6a
MS
75CXXLIBS="${CXXLIBS:=}"
76AC_SUBST(CXXLIBS)
77
a74454a7 78PIEFLAGS=""
79AC_SUBST(PIEFLAGS)
80
f7deaa1a 81RELROFLAGS=""
82AC_SUBST(RELROFLAGS)
83
355e94dc 84LIBCUPSORDER="libcups.order"
cc0d019f 85AC_ARG_WITH(libcupsorder, [ --with-libcupsorder libcups secorder file, default=libcups.order],
355e94dc
MS
86 if test -f "$withval"; then
87 LIBCUPSORDER="$withval"
88 fi)
cc0d019f
MS
89AC_SUBST(LIBCUPSORDER)
90
355e94dc
MS
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)
cc0d019f
MS
97AC_SUBST(LIBCUPSIMAGEORDER)
98
7a14d768
MS
99PHPOPTIONS=""
100AC_SUBST(PHPOPTIONS)
101
ef416fc2 102if test -n "$GCC"; then
2abf387c 103 # Add GCC-specific compiler options...
ef416fc2 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
a4924f6c 113 # Generate position-independent code as needed...
ef416fc2 114 if test $PICFLAG = 1 -a $uname != AIX; then
115 OPTIM="-fPIC $OPTIM"
116 fi
117
a4924f6c
MS
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"
ef416fc2 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"
a4924f6c 145 # Additional warning options for development testing...
d9bca400
MS
146 if test -d .svn; then
147 OPTIM="-Wshadow -Wunused $OPTIM"
7a14d768 148 PHPOPTIONS="-Wno-shadow"
d9bca400 149 fi
ef416fc2 150 fi
e1d6a774 151
152 case "$uname" in
a4924f6c
MS
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"
568fa3fa
MS
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
a4924f6c
MS
165 ;;
166
b86bc4cf 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
e1d6a774 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
e1d6a774 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
e1d6a774 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
e1d6a774 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
e1d6a774 235 fi
236 fi
237 ;;
238
239 Linux*)
a4924f6c
MS
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
e1d6a774 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
e1d6a774 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
e1d6a774 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
e1d6a774 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
e1d6a774 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
e1d6a774 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
e1d6a774 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
e1d6a774 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
e1d6a774 313 fi
314 fi
315 ;;
316 esac
ef416fc2 317else
2abf387c 318 # Add vendor-specific compiler options...
ef416fc2 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
ef416fc2 340 if test $PICFLAG = 1; then
341 OPTIM="+z $OPTIM"
342 fi
c277e2f8
MS
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
ef416fc2 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
e1d6a774 387 if test "x$with_optim" = x; then
388 OPTIM="-fullwarn -woff 1183,1209,1349,1506,3201 $OPTIM"
ef416fc2 389 fi
390
e1d6a774 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
e1d6a774 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
e1d6a774 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
e1d6a774 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
ef416fc2 422 fi
423 fi
424 ;;
2abf387c 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 ;;
ef416fc2 435 SunOS*)
436 # Solaris
437 if test -z "$OPTIM"; then
438 if test "x$with_optim" = x; then
ed486911 439 OPTIM="-xO2"
ef416fc2 440 else
441 OPTIM="$with_optim $OPTIM"
442 fi
443 fi
444
ef416fc2 445 if test $PICFLAG = 1; then
446 OPTIM="-KPIC $OPTIM"
447 fi
e1d6a774 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"
e1d6a774 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"
f301802f 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
e1d6a774 467 fi
468 else
469 if test "x$enable_64bit" = xyes; then
470 # Build 64-bit libraries...
471 ARCH64FLAGS="-xarch=generic64"
f301802f 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
e1d6a774 480
f301802f 481 if test -z "$with_archflags"; then
482 if test -z "$with_arch32flags"; then
483 ARCHFLAGS="-xarch=generic"
484 else
485 ARCHFLAGS="$with_arch32flags"
e1d6a774 486 fi
e1d6a774 487 fi
488 fi
ef416fc2 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"
5bd77a73
MS
510 echo "for your platform, or set the CFLAGS and LDFLAGS environment"
511 echo "variables before running configure."
ef416fc2 512 ;;
513 esac
514fi
515
2abf387c 516# Add general compiler options per platform...
517case $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"
b94498cf 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"
2abf387c 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 ;;
537esac
ef416fc2 538
539dnl
2e4ff8af 540dnl End of "$Id: cups-compiler.m4 6975 2007-09-18 20:37:09Z mike $".
ef416fc2 541dnl