]> git.ipfire.org Git - thirdparty/cups.git/blame - config-scripts/cups-compiler.m4
Update to CUPS trunk r6695.
[thirdparty/cups.git] / config-scripts / cups-compiler.m4
CommitLineData
ef416fc2 1dnl
cc0d019f 2dnl "$Id: cups-compiler.m4 6687 2007-07-18 19:49:45Z mike $"
ef416fc2 3dnl
4dnl Compiler stuff for the Common UNIX Printing System (CUPS).
5dnl
bc44d920 6dnl Copyright 2007 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...
18OPTIM=""
19AC_SUBST(OPTIM)
20
fa73b229 21AC_ARG_WITH(optim, [ --with-optim="flags" set optimization flags ])
ef416fc2 22AC_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 27dnl Setup general architecture flags...
28AC_ARG_WITH(archflags, [ --with-archflags="flags"
29 set default architecture flags ])
30
31if test -z "$with_archflags"; then
32 ARCHFLAGS=""
09a101d6 33 LDARCHFLAGS=""
ed486911 34else
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 43fi
44
45AC_SUBST(ARCHFLAGS)
09a101d6 46AC_SUBST(LDARCHFLAGS)
ed486911 47
e1d6a774 48dnl Setup support for separate 32/64-bit library generation...
ed486911 49AC_ARG_WITH(arch32flags, [ --with-arch32flags="flags"
50 specifies 32-bit architecture flags])
e1d6a774 51ARCH32FLAGS=""
e1d6a774 52AC_SUBST(ARCH32FLAGS)
e1d6a774 53
ed486911 54AC_ARG_WITH(arch64flags, [ --with-arch64flags="flags"
55 specifies 64-bit architecture flags])
e1d6a774 56ARCH64FLAGS=""
e1d6a774 57AC_SUBST(ARCH64FLAGS)
e1d6a774 58
f7deaa1a 59dnl Position-Independent Executable support on Linux...
a74454a7 60AC_ARG_ENABLE(pie, [ --enable-pie use GCC -fPIE option, default=no])
ef416fc2 61
f7deaa1a 62dnl Read-only data/program support on Linux...
63AC_ARG_ENABLE(relro, [ --enable-relro use GCC relro option, default=no])
64
ef416fc2 65dnl Update compiler options...
66CXXLIBS=""
67AC_SUBST(CXXLIBS)
68
a74454a7 69PIEFLAGS=""
70AC_SUBST(PIEFLAGS)
71
f7deaa1a 72RELROFLAGS=""
73AC_SUBST(RELROFLAGS)
74
cc0d019f
MS
75AC_ARG_WITH(libcupsorder, [ --with-libcupsorder libcups secorder file, default=libcups.order],
76 LIBCUPSORDER="$withval",
77 LIBCUPSORDER="libcups.order")
78AC_SUBST(LIBCUPSORDER)
79
80AC_ARG_WITH(libcupsimageorder, [ --with-libcupimagesorder libcupsimage secorder file, default=libcups.order],
81 LIBCUPSIMAGEORDER="$withval",
82 LIBCUPSIMAGEORDER="libcupsimage.order")
83AC_SUBST(LIBCUPSIMAGEORDER)
84
ef416fc2 85if test -n "$GCC"; then
2abf387c 86 # Add GCC-specific compiler options...
ef416fc2 87 if test -z "$OPTIM"; then
88 if test "x$with_optim" = x; then
89 # Default to optimize-for-size and debug
90 OPTIM="-Os -g"
91 else
92 OPTIM="$with_optim $OPTIM"
93 fi
94 fi
95
96 if test $PICFLAG = 1 -a $uname != AIX; then
97 OPTIM="-fPIC $OPTIM"
98 fi
99
100 case $uname in
ef416fc2 101 Linux*)
fa73b229 102 if test x$enable_pie = xyes; then
a74454a7 103 PIEFLAGS="-pie -fPIE"
104 fi
f7deaa1a 105
106 if test x$enable_relro = xyes; then
107 RELROFLAGS="-Wl,-z,relro"
108 fi
a74454a7 109 ;;
110
111 *)
112 if test x$enable_pie = xyes; then
113 echo "Sorry, --enable-pie is not supported on this OS!"
fa73b229 114 fi
ef416fc2 115 ;;
116 esac
117
118 if test "x$with_optim" = x; then
119 # Add useful warning options for tracking down problems...
120 OPTIM="-Wall -Wno-format-y2k $OPTIM"
121 # Additional warning options for alpha testing...
122 OPTIM="-Wshadow -Wunused $OPTIM"
123 fi
e1d6a774 124
125 case "$uname" in
b86bc4cf 126 HP-UX*)
127 if test "x$enable_32bit" = xyes; then
128 # Build 32-bit libraries, 64-bit base...
129 if test -z "$with_arch32flags"; then
130 ARCH32FLAGS="-milp32"
131 else
132 ARCH32FLAGS="$with_arch32flags"
133 fi
134
135 if test -z "$with_archflags"; then
136 if test -z "$with_arch64flags"; then
137 ARCHFLAGS="-mlp64"
138 else
139 ARCHFLAGS="$with_arch64flags"
140 fi
141 fi
142 fi
143
144 if test "x$enable_64bit" = xyes; then
145 # Build 64-bit libraries, 32-bit base...
146 if test -z "$with_arch64flags"; then
147 ARCH64FLAGS="-mlp64"
148 else
149 ARCH64FLAGS="$with_arch64flags"
150 fi
151
152 if test -z "$with_archflags"; then
153 if test -z "$with_arch32flags"; then
154 ARCHFLAGS="-milp32"
155 else
156 ARCHFLAGS="$with_arch32flags"
157 fi
158 fi
159 fi
160 ;;
161
e1d6a774 162 IRIX)
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="-n32 -mips3"
167 else
168 ARCH32FLAGS="$with_arch32flags"
169 fi
e1d6a774 170
171 if test -z "$with_archflags"; then
172 if test -z "$with_arch64flags"; then
173 ARCHFLAGS="-64 -mips4"
174 else
175 ARCHFLAGS="$with_arch64flags"
176 fi
e1d6a774 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="-64 -mips4"
184 else
185 ARCH64FLAGS="$with_arch64flags"
186 fi
e1d6a774 187
188 if test -z "$with_archflags"; then
189 if test -z "$with_arch32flags"; then
190 ARCHFLAGS="-n32 -mips3"
191 else
192 ARCHFLAGS="$with_arch32flags"
193 fi
e1d6a774 194 fi
195 fi
196 ;;
197
198 Linux*)
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="-m32"
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="-m64"
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="-m64"
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="-m32"
227 else
228 ARCHFLAGS="$with_arch32flags"
229 fi
e1d6a774 230 fi
231 fi
232 ;;
233
234 SunOS*)
235 if test "x$enable_32bit" = xyes; then
236 # Build 32-bit libraries, 64-bit base...
237 if test -z "$with_arch32flags"; then
238 ARCH32FLAGS="-m32"
239 else
240 ARCH32FLAGS="$with_arch32flags"
241 fi
e1d6a774 242
243 if test -z "$with_archflags"; then
244 if test -z "$with_arch64flags"; then
245 ARCHFLAGS="-m64"
246 else
247 ARCHFLAGS="$with_arch64flags"
248 fi
e1d6a774 249 fi
250 fi
251
252 if test "x$enable_64bit" = xyes; then
253 # Build 64-bit libraries, 32-bit base...
254 if test -z "$with_arch64flags"; then
255 ARCH64FLAGS="-m64"
256 else
257 ARCH64FLAGS="$with_arch64flags"
258 fi
e1d6a774 259
260 if test -z "$with_archflags"; then
261 if test -z "$with_arch32flags"; then
262 ARCHFLAGS="-m32"
263 else
264 ARCHFLAGS="$with_arch32flags"
265 fi
e1d6a774 266 fi
267 fi
268 ;;
269 esac
ef416fc2 270else
2abf387c 271 # Add vendor-specific compiler options...
ef416fc2 272 case $uname in
273 AIX*)
274 if test -z "$OPTIM"; then
275 if test "x$with_optim" = x; then
276 OPTIM="-O2 -qmaxmem=6000"
277 else
278 OPTIM="$with_optim $OPTIM"
279 fi
280 fi
281 ;;
282 HP-UX*)
283 if test -z "$OPTIM"; then
284 if test "x$with_optim" = x; then
285 OPTIM="+O2"
286 else
287 OPTIM="$with_optim $OPTIM"
288 fi
289 fi
290
291 CFLAGS="-Ae $CFLAGS"
e1d6a774 292 # Warning 336 is "empty translation unit"
293 # Warning 829 is passing constant string as char *
294 CXXFLAGS="+W336,829 $CXXFLAGS"
ef416fc2 295
ef416fc2 296 if test $PICFLAG = 1; then
297 OPTIM="+z $OPTIM"
298 fi
299 ;;
300 IRIX)
301 if test -z "$OPTIM"; then
302 if test "x$with_optim" = x; then
303 OPTIM="-O2"
304 else
305 OPTIM="$with_optim $OPTIM"
306 fi
307 fi
308
e1d6a774 309 if test "x$with_optim" = x; then
310 OPTIM="-fullwarn -woff 1183,1209,1349,1506,3201 $OPTIM"
ef416fc2 311 fi
312
e1d6a774 313 if test "x$enable_32bit" = xyes; then
314 # Build 32-bit libraries, 64-bit base...
315 if test -z "$with_arch32flags"; then
316 ARCH32FLAGS="-n32 -mips3"
317 else
318 ARCH32FLAGS="$with_arch32flags"
319 fi
e1d6a774 320
321 if test -z "$with_archflags"; then
322 if test -z "$with_arch64flags"; then
323 ARCHFLAGS="-64 -mips4"
324 else
325 ARCHFLAGS="$with_arch64flags"
326 fi
e1d6a774 327 fi
328 fi
329
330 if test "x$enable_64bit" = xyes; then
331 # Build 64-bit libraries, 32-bit base...
332 if test -z "$with_arch64flags"; then
333 ARCH64FLAGS="-64 -mips4"
334 else
335 ARCH64FLAGS="$with_arch64flags"
336 fi
e1d6a774 337
338 if test -z "$with_archflags"; then
339 if test -z "$with_arch32flags"; then
340 ARCHFLAGS="-n32 -mips3"
341 else
342 ARCHFLAGS="$with_arch32flags"
343 fi
ef416fc2 344 fi
345 fi
346 ;;
2abf387c 347 OSF*)
348 # Tru64 UNIX aka Digital UNIX aka OSF/1
349 if test -z "$OPTIM"; then
350 if test "x$with_optim" = x; then
351 OPTIM="-O"
352 else
353 OPTIM="$with_optim"
354 fi
355 fi
356 ;;
ef416fc2 357 SunOS*)
358 # Solaris
359 if test -z "$OPTIM"; then
360 if test "x$with_optim" = x; then
ed486911 361 OPTIM="-xO2"
ef416fc2 362 else
363 OPTIM="$with_optim $OPTIM"
364 fi
365 fi
366
ef416fc2 367 if test $PICFLAG = 1; then
368 OPTIM="-KPIC $OPTIM"
369 fi
e1d6a774 370
371 if test "x$enable_32bit" = xyes; then
372 # Compiling on a Solaris system, build 64-bit
373 # binaries with separate 32-bit libraries...
374 ARCH32FLAGS="-xarch=generic"
e1d6a774 375
376 if test "x$with_optim" = x; then
377 # Suppress all of Sun's questionable
378 # warning messages, and default to
379 # 64-bit compiles of everything else...
380 OPTIM="-w $OPTIM"
f301802f 381 fi
382
383 if test -z "$with_archflags"; then
384 if test -z "$with_arch64flags"; then
385 ARCHFLAGS="-xarch=generic64"
386 else
387 ARCHFLAGS="$with_arch64flags"
388 fi
e1d6a774 389 fi
390 else
391 if test "x$enable_64bit" = xyes; then
392 # Build 64-bit libraries...
393 ARCH64FLAGS="-xarch=generic64"
f301802f 394 fi
395
396 if test "x$with_optim" = x; then
397 # Suppress all of Sun's questionable
398 # warning messages, and default to
399 # 32-bit compiles of everything else...
400 OPTIM="-w $OPTIM"
401 fi
e1d6a774 402
f301802f 403 if test -z "$with_archflags"; then
404 if test -z "$with_arch32flags"; then
405 ARCHFLAGS="-xarch=generic"
406 else
407 ARCHFLAGS="$with_arch32flags"
e1d6a774 408 fi
e1d6a774 409 fi
410 fi
ef416fc2 411 ;;
412 UNIX_SVR*)
413 # UnixWare
414 if test -z "$OPTIM"; then
415 if test "x$with_optim" = x; then
416 OPTIM="-O"
417 else
418 OPTIM="$with_optim $OPTIM"
419 fi
420 fi
421
422 if test $PICFLAG = 1; then
423 OPTIM="-KPIC $OPTIM"
424 fi
425 ;;
426 *)
427 # Running some other operating system; inform the user they
428 # should contribute the necessary options to
429 # cups-support@cups.org...
430 echo "Building CUPS with default compiler optimizations; contact"
431 echo "cups-bugs@cups.org with uname and compiler options needed"
432 echo "for your platform, or set the CFLAGS and CXXFLAGS"
433 echo "environment variable before running configure."
434 ;;
435 esac
436fi
437
2abf387c 438# Add general compiler options per platform...
439case $uname in
440 HP-UX*)
441 # HP-UX 10.20 (at least) needs this definition to get the
442 # h_errno global...
443 OPTIM="$OPTIM -D_XOPEN_SOURCE_EXTENDED"
444
445 # HP-UX 11.00 (at least) needs this definition to get the
446 # u_short type used by the IP headers...
447 OPTIM="$OPTIM -D_INCLUDE_HPUX_SOURCE"
b94498cf 448
449 # HP-UX 11.23 (at least) needs this definition to get the
450 # IPv6 header to work...
451 OPTIM="$OPTIM -D_HPUX_SOURCE"
2abf387c 452 ;;
453
454 OSF*)
455 # Tru64 UNIX aka Digital UNIX aka OSF/1 need to be told
456 # to be POSIX-compliant...
457 OPTIM="$OPTIM -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_OSF_SOURCE"
458 ;;
459esac
ef416fc2 460
461dnl
cc0d019f 462dnl End of "$Id: cups-compiler.m4 6687 2007-07-18 19:49:45Z mike $".
ef416fc2 463dnl