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