]>
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... | |
18 | OPTIM="" | |
19 | AC_SUBST(OPTIM) | |
20 | ||
fa73b229 | 21 | AC_ARG_WITH(optim, [ --with-optim="flags" set optimization flags ]) |
ef416fc2 | 22 | AC_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 | 27 | dnl Setup general architecture flags... |
28 | AC_ARG_WITH(archflags, [ --with-archflags="flags" | |
29 | set default architecture flags ]) | |
30 | ||
31 | if test -z "$with_archflags"; then | |
32 | ARCHFLAGS="" | |
09a101d6 | 33 | LDARCHFLAGS="" |
ed486911 | 34 | else |
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 | 43 | fi |
44 | ||
45 | AC_SUBST(ARCHFLAGS) | |
09a101d6 | 46 | AC_SUBST(LDARCHFLAGS) |
ed486911 | 47 | |
e1d6a774 | 48 | dnl Setup support for separate 32/64-bit library generation... |
ed486911 | 49 | AC_ARG_WITH(arch32flags, [ --with-arch32flags="flags" |
50 | specifies 32-bit architecture flags]) | |
e1d6a774 | 51 | ARCH32FLAGS="" |
e1d6a774 | 52 | AC_SUBST(ARCH32FLAGS) |
e1d6a774 | 53 | |
ed486911 | 54 | AC_ARG_WITH(arch64flags, [ --with-arch64flags="flags" |
55 | specifies 64-bit architecture flags]) | |
e1d6a774 | 56 | ARCH64FLAGS="" |
e1d6a774 | 57 | AC_SUBST(ARCH64FLAGS) |
e1d6a774 | 58 | |
f7deaa1a | 59 | dnl Read-only data/program support on Linux... |
60 | AC_ARG_ENABLE(relro, [ --enable-relro use GCC relro option, default=no]) | |
61 | ||
ef416fc2 | 62 | dnl Update compiler options... |
ac884b6a MS |
63 | CXXLIBS="${CXXLIBS:=}" |
64 | AC_SUBST(CXXLIBS) | |
65 | ||
a74454a7 | 66 | PIEFLAGS="" |
67 | AC_SUBST(PIEFLAGS) | |
68 | ||
f7deaa1a | 69 | RELROFLAGS="" |
70 | AC_SUBST(RELROFLAGS) | |
71 | ||
355e94dc | 72 | LIBCUPSORDER="libcups.order" |
cc0d019f | 73 | AC_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 |
77 | AC_SUBST(LIBCUPSORDER) |
78 | ||
355e94dc MS |
79 | LIBCUPSIMAGEORDER="libcupsimage.order" |
80 | AC_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 |
85 | AC_SUBST(LIBCUPSIMAGEORDER) |
86 | ||
ef416fc2 | 87 | if 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" | |
568fa3fa MS |
144 | |
145 | if test x$enable_pie = xyes; then | |
146 | # GCC 4 on Mac OS X needs -Wl,-pie as well | |
147 | LDFLAGS="$LDFLAGS -Wl,-pie" | |
148 | fi | |
a4924f6c MS |
149 | ;; |
150 | ||
b86bc4cf | 151 | HP-UX*) |
152 | if test "x$enable_32bit" = xyes; then | |
153 | # Build 32-bit libraries, 64-bit base... | |
154 | if test -z "$with_arch32flags"; then | |
155 | ARCH32FLAGS="-milp32" | |
156 | else | |
157 | ARCH32FLAGS="$with_arch32flags" | |
158 | fi | |
159 | ||
160 | if test -z "$with_archflags"; then | |
161 | if test -z "$with_arch64flags"; then | |
162 | ARCHFLAGS="-mlp64" | |
163 | else | |
164 | ARCHFLAGS="$with_arch64flags" | |
165 | fi | |
166 | fi | |
167 | fi | |
168 | ||
169 | if test "x$enable_64bit" = xyes; then | |
170 | # Build 64-bit libraries, 32-bit base... | |
171 | if test -z "$with_arch64flags"; then | |
172 | ARCH64FLAGS="-mlp64" | |
173 | else | |
174 | ARCH64FLAGS="$with_arch64flags" | |
175 | fi | |
176 | ||
177 | if test -z "$with_archflags"; then | |
178 | if test -z "$with_arch32flags"; then | |
179 | ARCHFLAGS="-milp32" | |
180 | else | |
181 | ARCHFLAGS="$with_arch32flags" | |
182 | fi | |
183 | fi | |
184 | fi | |
185 | ;; | |
186 | ||
e1d6a774 | 187 | IRIX) |
188 | if test "x$enable_32bit" = xyes; then | |
189 | # Build 32-bit libraries, 64-bit base... | |
190 | if test -z "$with_arch32flags"; then | |
191 | ARCH32FLAGS="-n32 -mips3" | |
192 | else | |
193 | ARCH32FLAGS="$with_arch32flags" | |
194 | fi | |
e1d6a774 | 195 | |
196 | if test -z "$with_archflags"; then | |
197 | if test -z "$with_arch64flags"; then | |
198 | ARCHFLAGS="-64 -mips4" | |
199 | else | |
200 | ARCHFLAGS="$with_arch64flags" | |
201 | fi | |
e1d6a774 | 202 | fi |
203 | fi | |
204 | ||
205 | if test "x$enable_64bit" = xyes; then | |
206 | # Build 64-bit libraries, 32-bit base... | |
207 | if test -z "$with_arch64flags"; then | |
208 | ARCH64FLAGS="-64 -mips4" | |
209 | else | |
210 | ARCH64FLAGS="$with_arch64flags" | |
211 | fi | |
e1d6a774 | 212 | |
213 | if test -z "$with_archflags"; then | |
214 | if test -z "$with_arch32flags"; then | |
215 | ARCHFLAGS="-n32 -mips3" | |
216 | else | |
217 | ARCHFLAGS="$with_arch32flags" | |
218 | fi | |
e1d6a774 | 219 | fi |
220 | fi | |
221 | ;; | |
222 | ||
223 | Linux*) | |
a4924f6c MS |
224 | # The -z relro option is provided by the Linux linker command to |
225 | # make relocatable data read-only. | |
226 | if test x$enable_relro = xyes; then | |
227 | RELROFLAGS="-Wl,-z,relro" | |
228 | fi | |
229 | ||
e1d6a774 | 230 | if test "x$enable_32bit" = xyes; then |
231 | # Build 32-bit libraries, 64-bit base... | |
232 | if test -z "$with_arch32flags"; then | |
233 | ARCH32FLAGS="-m32" | |
234 | else | |
235 | ARCH32FLAGS="$with_arch32flags" | |
236 | fi | |
e1d6a774 | 237 | |
238 | if test -z "$with_archflags"; then | |
239 | if test -z "$with_arch64flags"; then | |
240 | ARCHFLAGS="-m64" | |
241 | else | |
242 | ARCHFLAGS="$with_arch64flags" | |
243 | fi | |
e1d6a774 | 244 | fi |
245 | fi | |
246 | ||
247 | if test "x$enable_64bit" = xyes; then | |
248 | # Build 64-bit libraries, 32-bit base... | |
249 | if test -z "$with_arch64flags"; then | |
250 | ARCH64FLAGS="-m64" | |
251 | else | |
252 | ARCH64FLAGS="$with_arch64flags" | |
253 | fi | |
e1d6a774 | 254 | |
255 | if test -z "$with_archflags"; then | |
256 | if test -z "$with_arch32flags"; then | |
257 | ARCHFLAGS="-m32" | |
258 | else | |
259 | ARCHFLAGS="$with_arch32flags" | |
260 | fi | |
e1d6a774 | 261 | fi |
262 | fi | |
263 | ;; | |
264 | ||
265 | SunOS*) | |
266 | if test "x$enable_32bit" = xyes; then | |
267 | # Build 32-bit libraries, 64-bit base... | |
268 | if test -z "$with_arch32flags"; then | |
269 | ARCH32FLAGS="-m32" | |
270 | else | |
271 | ARCH32FLAGS="$with_arch32flags" | |
272 | fi | |
e1d6a774 | 273 | |
274 | if test -z "$with_archflags"; then | |
275 | if test -z "$with_arch64flags"; then | |
276 | ARCHFLAGS="-m64" | |
277 | else | |
278 | ARCHFLAGS="$with_arch64flags" | |
279 | fi | |
e1d6a774 | 280 | fi |
281 | fi | |
282 | ||
283 | if test "x$enable_64bit" = xyes; then | |
284 | # Build 64-bit libraries, 32-bit base... | |
285 | if test -z "$with_arch64flags"; then | |
286 | ARCH64FLAGS="-m64" | |
287 | else | |
288 | ARCH64FLAGS="$with_arch64flags" | |
289 | fi | |
e1d6a774 | 290 | |
291 | if test -z "$with_archflags"; then | |
292 | if test -z "$with_arch32flags"; then | |
293 | ARCHFLAGS="-m32" | |
294 | else | |
295 | ARCHFLAGS="$with_arch32flags" | |
296 | fi | |
e1d6a774 | 297 | fi |
298 | fi | |
299 | ;; | |
300 | esac | |
ef416fc2 | 301 | else |
2abf387c | 302 | # Add vendor-specific compiler options... |
ef416fc2 | 303 | case $uname in |
304 | AIX*) | |
305 | if test -z "$OPTIM"; then | |
306 | if test "x$with_optim" = x; then | |
307 | OPTIM="-O2 -qmaxmem=6000" | |
308 | else | |
309 | OPTIM="$with_optim $OPTIM" | |
310 | fi | |
311 | fi | |
312 | ;; | |
313 | HP-UX*) | |
314 | if test -z "$OPTIM"; then | |
315 | if test "x$with_optim" = x; then | |
316 | OPTIM="+O2" | |
317 | else | |
318 | OPTIM="$with_optim $OPTIM" | |
319 | fi | |
320 | fi | |
321 | ||
322 | CFLAGS="-Ae $CFLAGS" | |
323 | ||
ef416fc2 | 324 | if test $PICFLAG = 1; then |
325 | OPTIM="+z $OPTIM" | |
326 | fi | |
c277e2f8 MS |
327 | |
328 | if test "x$enable_32bit" = xyes; then | |
329 | # Build 32-bit libraries, 64-bit base... | |
330 | if test -z "$with_arch32flags"; then | |
331 | ARCH32FLAGS="+DD32" | |
332 | else | |
333 | ARCH32FLAGS="$with_arch32flags" | |
334 | fi | |
335 | ||
336 | if test -z "$with_archflags"; then | |
337 | if test -z "$with_arch64flags"; then | |
338 | ARCHFLAGS="+DD64" | |
339 | else | |
340 | ARCHFLAGS="$with_arch64flags" | |
341 | fi | |
342 | fi | |
343 | fi | |
344 | ||
345 | if test "x$enable_64bit" = xyes; then | |
346 | # Build 64-bit libraries, 32-bit base... | |
347 | if test -z "$with_arch64flags"; then | |
348 | ARCH64FLAGS="+DD64" | |
349 | else | |
350 | ARCH64FLAGS="$with_arch64flags" | |
351 | fi | |
352 | ||
353 | if test -z "$with_archflags"; then | |
354 | if test -z "$with_arch32flags"; then | |
355 | ARCHFLAGS="+DD32" | |
356 | else | |
357 | ARCHFLAGS="$with_arch32flags" | |
358 | fi | |
359 | fi | |
360 | fi | |
ef416fc2 | 361 | ;; |
362 | IRIX) | |
363 | if test -z "$OPTIM"; then | |
364 | if test "x$with_optim" = x; then | |
365 | OPTIM="-O2" | |
366 | else | |
367 | OPTIM="$with_optim $OPTIM" | |
368 | fi | |
369 | fi | |
370 | ||
e1d6a774 | 371 | if test "x$with_optim" = x; then |
372 | OPTIM="-fullwarn -woff 1183,1209,1349,1506,3201 $OPTIM" | |
ef416fc2 | 373 | fi |
374 | ||
e1d6a774 | 375 | if test "x$enable_32bit" = xyes; then |
376 | # Build 32-bit libraries, 64-bit base... | |
377 | if test -z "$with_arch32flags"; then | |
378 | ARCH32FLAGS="-n32 -mips3" | |
379 | else | |
380 | ARCH32FLAGS="$with_arch32flags" | |
381 | fi | |
e1d6a774 | 382 | |
383 | if test -z "$with_archflags"; then | |
384 | if test -z "$with_arch64flags"; then | |
385 | ARCHFLAGS="-64 -mips4" | |
386 | else | |
387 | ARCHFLAGS="$with_arch64flags" | |
388 | fi | |
e1d6a774 | 389 | fi |
390 | fi | |
391 | ||
392 | if test "x$enable_64bit" = xyes; then | |
393 | # Build 64-bit libraries, 32-bit base... | |
394 | if test -z "$with_arch64flags"; then | |
395 | ARCH64FLAGS="-64 -mips4" | |
396 | else | |
397 | ARCH64FLAGS="$with_arch64flags" | |
398 | fi | |
e1d6a774 | 399 | |
400 | if test -z "$with_archflags"; then | |
401 | if test -z "$with_arch32flags"; then | |
402 | ARCHFLAGS="-n32 -mips3" | |
403 | else | |
404 | ARCHFLAGS="$with_arch32flags" | |
405 | fi | |
ef416fc2 | 406 | fi |
407 | fi | |
408 | ;; | |
2abf387c | 409 | OSF*) |
410 | # Tru64 UNIX aka Digital UNIX aka OSF/1 | |
411 | if test -z "$OPTIM"; then | |
412 | if test "x$with_optim" = x; then | |
413 | OPTIM="-O" | |
414 | else | |
415 | OPTIM="$with_optim" | |
416 | fi | |
417 | fi | |
418 | ;; | |
ef416fc2 | 419 | SunOS*) |
420 | # Solaris | |
421 | if test -z "$OPTIM"; then | |
422 | if test "x$with_optim" = x; then | |
ed486911 | 423 | OPTIM="-xO2" |
ef416fc2 | 424 | else |
425 | OPTIM="$with_optim $OPTIM" | |
426 | fi | |
427 | fi | |
428 | ||
ef416fc2 | 429 | if test $PICFLAG = 1; then |
430 | OPTIM="-KPIC $OPTIM" | |
431 | fi | |
e1d6a774 | 432 | |
433 | if test "x$enable_32bit" = xyes; then | |
434 | # Compiling on a Solaris system, build 64-bit | |
435 | # binaries with separate 32-bit libraries... | |
436 | ARCH32FLAGS="-xarch=generic" | |
e1d6a774 | 437 | |
438 | if test "x$with_optim" = x; then | |
439 | # Suppress all of Sun's questionable | |
440 | # warning messages, and default to | |
441 | # 64-bit compiles of everything else... | |
442 | OPTIM="-w $OPTIM" | |
f301802f | 443 | fi |
444 | ||
445 | if test -z "$with_archflags"; then | |
446 | if test -z "$with_arch64flags"; then | |
447 | ARCHFLAGS="-xarch=generic64" | |
448 | else | |
449 | ARCHFLAGS="$with_arch64flags" | |
450 | fi | |
e1d6a774 | 451 | fi |
452 | else | |
453 | if test "x$enable_64bit" = xyes; then | |
454 | # Build 64-bit libraries... | |
455 | ARCH64FLAGS="-xarch=generic64" | |
f301802f | 456 | fi |
457 | ||
458 | if test "x$with_optim" = x; then | |
459 | # Suppress all of Sun's questionable | |
460 | # warning messages, and default to | |
461 | # 32-bit compiles of everything else... | |
462 | OPTIM="-w $OPTIM" | |
463 | fi | |
e1d6a774 | 464 | |
f301802f | 465 | if test -z "$with_archflags"; then |
466 | if test -z "$with_arch32flags"; then | |
467 | ARCHFLAGS="-xarch=generic" | |
468 | else | |
469 | ARCHFLAGS="$with_arch32flags" | |
e1d6a774 | 470 | fi |
e1d6a774 | 471 | fi |
472 | fi | |
ef416fc2 | 473 | ;; |
474 | UNIX_SVR*) | |
475 | # UnixWare | |
476 | if test -z "$OPTIM"; then | |
477 | if test "x$with_optim" = x; then | |
478 | OPTIM="-O" | |
479 | else | |
480 | OPTIM="$with_optim $OPTIM" | |
481 | fi | |
482 | fi | |
483 | ||
484 | if test $PICFLAG = 1; then | |
485 | OPTIM="-KPIC $OPTIM" | |
486 | fi | |
487 | ;; | |
488 | *) | |
489 | # Running some other operating system; inform the user they | |
490 | # should contribute the necessary options to | |
491 | # cups-support@cups.org... | |
492 | echo "Building CUPS with default compiler optimizations; contact" | |
493 | echo "cups-bugs@cups.org with uname and compiler options needed" | |
5bd77a73 MS |
494 | echo "for your platform, or set the CFLAGS and LDFLAGS environment" |
495 | echo "variables before running configure." | |
ef416fc2 | 496 | ;; |
497 | esac | |
498 | fi | |
499 | ||
2abf387c | 500 | # Add general compiler options per platform... |
501 | case $uname in | |
502 | HP-UX*) | |
503 | # HP-UX 10.20 (at least) needs this definition to get the | |
504 | # h_errno global... | |
505 | OPTIM="$OPTIM -D_XOPEN_SOURCE_EXTENDED" | |
506 | ||
507 | # HP-UX 11.00 (at least) needs this definition to get the | |
508 | # u_short type used by the IP headers... | |
509 | OPTIM="$OPTIM -D_INCLUDE_HPUX_SOURCE" | |
b94498cf | 510 | |
511 | # HP-UX 11.23 (at least) needs this definition to get the | |
512 | # IPv6 header to work... | |
513 | OPTIM="$OPTIM -D_HPUX_SOURCE" | |
2abf387c | 514 | ;; |
515 | ||
516 | OSF*) | |
517 | # Tru64 UNIX aka Digital UNIX aka OSF/1 need to be told | |
518 | # to be POSIX-compliant... | |
519 | OPTIM="$OPTIM -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_OSF_SOURCE" | |
520 | ;; | |
521 | esac | |
ef416fc2 | 522 | |
523 | dnl | |
2e4ff8af | 524 | dnl End of "$Id: cups-compiler.m4 6975 2007-09-18 20:37:09Z mike $". |
ef416fc2 | 525 | dnl |