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