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