]> git.ipfire.org Git - thirdparty/cups.git/blame - config-scripts/cups-compiler.m4
Load cups into easysw/current.
[thirdparty/cups.git] / config-scripts / cups-compiler.m4
CommitLineData
ef416fc2 1dnl
bc44d920 2dnl "$Id: cups-compiler.m4 6649 2007-07-11 21:46:42Z 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
ef416fc2 75if test -n "$GCC"; then
2abf387c 76 # Add GCC-specific compiler options...
ef416fc2 77 if test -z "$OPTIM"; then
78 if test "x$with_optim" = x; then
79 # Default to optimize-for-size and debug
80 OPTIM="-Os -g"
81 else
82 OPTIM="$with_optim $OPTIM"
83 fi
84 fi
85
86 if test $PICFLAG = 1 -a $uname != AIX; then
87 OPTIM="-fPIC $OPTIM"
88 fi
89
90 case $uname in
ef416fc2 91 Linux*)
fa73b229 92 if test x$enable_pie = xyes; then
a74454a7 93 PIEFLAGS="-pie -fPIE"
94 fi
f7deaa1a 95
96 if test x$enable_relro = xyes; then
97 RELROFLAGS="-Wl,-z,relro"
98 fi
a74454a7 99 ;;
100
101 *)
102 if test x$enable_pie = xyes; then
103 echo "Sorry, --enable-pie is not supported on this OS!"
fa73b229 104 fi
ef416fc2 105 ;;
106 esac
107
108 if test "x$with_optim" = x; then
109 # Add useful warning options for tracking down problems...
110 OPTIM="-Wall -Wno-format-y2k $OPTIM"
111 # Additional warning options for alpha testing...
112 OPTIM="-Wshadow -Wunused $OPTIM"
113 fi
e1d6a774 114
115 case "$uname" in
b86bc4cf 116 HP-UX*)
117 if test "x$enable_32bit" = xyes; then
118 # Build 32-bit libraries, 64-bit base...
119 if test -z "$with_arch32flags"; then
120 ARCH32FLAGS="-milp32"
121 else
122 ARCH32FLAGS="$with_arch32flags"
123 fi
124
125 if test -z "$with_archflags"; then
126 if test -z "$with_arch64flags"; then
127 ARCHFLAGS="-mlp64"
128 else
129 ARCHFLAGS="$with_arch64flags"
130 fi
131 fi
132 fi
133
134 if test "x$enable_64bit" = xyes; then
135 # Build 64-bit libraries, 32-bit base...
136 if test -z "$with_arch64flags"; then
137 ARCH64FLAGS="-mlp64"
138 else
139 ARCH64FLAGS="$with_arch64flags"
140 fi
141
142 if test -z "$with_archflags"; then
143 if test -z "$with_arch32flags"; then
144 ARCHFLAGS="-milp32"
145 else
146 ARCHFLAGS="$with_arch32flags"
147 fi
148 fi
149 fi
150 ;;
151
e1d6a774 152 IRIX)
153 if test "x$enable_32bit" = xyes; then
154 # Build 32-bit libraries, 64-bit base...
155 if test -z "$with_arch32flags"; then
156 ARCH32FLAGS="-n32 -mips3"
157 else
158 ARCH32FLAGS="$with_arch32flags"
159 fi
e1d6a774 160
161 if test -z "$with_archflags"; then
162 if test -z "$with_arch64flags"; then
163 ARCHFLAGS="-64 -mips4"
164 else
165 ARCHFLAGS="$with_arch64flags"
166 fi
e1d6a774 167 fi
168 fi
169
170 if test "x$enable_64bit" = xyes; then
171 # Build 64-bit libraries, 32-bit base...
172 if test -z "$with_arch64flags"; then
173 ARCH64FLAGS="-64 -mips4"
174 else
175 ARCH64FLAGS="$with_arch64flags"
176 fi
e1d6a774 177
178 if test -z "$with_archflags"; then
179 if test -z "$with_arch32flags"; then
180 ARCHFLAGS="-n32 -mips3"
181 else
182 ARCHFLAGS="$with_arch32flags"
183 fi
e1d6a774 184 fi
185 fi
186 ;;
187
188 Linux*)
189 if test "x$enable_32bit" = xyes; then
190 # Build 32-bit libraries, 64-bit base...
191 if test -z "$with_arch32flags"; then
192 ARCH32FLAGS="-m32"
193 else
194 ARCH32FLAGS="$with_arch32flags"
195 fi
e1d6a774 196
197 if test -z "$with_archflags"; then
198 if test -z "$with_arch64flags"; then
199 ARCHFLAGS="-m64"
200 else
201 ARCHFLAGS="$with_arch64flags"
202 fi
e1d6a774 203 fi
204 fi
205
206 if test "x$enable_64bit" = xyes; then
207 # Build 64-bit libraries, 32-bit base...
208 if test -z "$with_arch64flags"; then
209 ARCH64FLAGS="-m64"
210 else
211 ARCH64FLAGS="$with_arch64flags"
212 fi
e1d6a774 213
214 if test -z "$with_archflags"; then
215 if test -z "$with_arch32flags"; then
216 ARCHFLAGS="-m32"
217 else
218 ARCHFLAGS="$with_arch32flags"
219 fi
e1d6a774 220 fi
221 fi
222 ;;
223
224 SunOS*)
225 if test "x$enable_32bit" = xyes; then
226 # Build 32-bit libraries, 64-bit base...
227 if test -z "$with_arch32flags"; then
228 ARCH32FLAGS="-m32"
229 else
230 ARCH32FLAGS="$with_arch32flags"
231 fi
e1d6a774 232
233 if test -z "$with_archflags"; then
234 if test -z "$with_arch64flags"; then
235 ARCHFLAGS="-m64"
236 else
237 ARCHFLAGS="$with_arch64flags"
238 fi
e1d6a774 239 fi
240 fi
241
242 if test "x$enable_64bit" = xyes; then
243 # Build 64-bit libraries, 32-bit base...
244 if test -z "$with_arch64flags"; then
245 ARCH64FLAGS="-m64"
246 else
247 ARCH64FLAGS="$with_arch64flags"
248 fi
e1d6a774 249
250 if test -z "$with_archflags"; then
251 if test -z "$with_arch32flags"; then
252 ARCHFLAGS="-m32"
253 else
254 ARCHFLAGS="$with_arch32flags"
255 fi
e1d6a774 256 fi
257 fi
258 ;;
259 esac
ef416fc2 260else
2abf387c 261 # Add vendor-specific compiler options...
ef416fc2 262 case $uname in
263 AIX*)
264 if test -z "$OPTIM"; then
265 if test "x$with_optim" = x; then
266 OPTIM="-O2 -qmaxmem=6000"
267 else
268 OPTIM="$with_optim $OPTIM"
269 fi
270 fi
271 ;;
272 HP-UX*)
273 if test -z "$OPTIM"; then
274 if test "x$with_optim" = x; then
275 OPTIM="+O2"
276 else
277 OPTIM="$with_optim $OPTIM"
278 fi
279 fi
280
281 CFLAGS="-Ae $CFLAGS"
e1d6a774 282 # Warning 336 is "empty translation unit"
283 # Warning 829 is passing constant string as char *
284 CXXFLAGS="+W336,829 $CXXFLAGS"
ef416fc2 285
ef416fc2 286 if test $PICFLAG = 1; then
287 OPTIM="+z $OPTIM"
288 fi
289 ;;
290 IRIX)
291 if test -z "$OPTIM"; then
292 if test "x$with_optim" = x; then
293 OPTIM="-O2"
294 else
295 OPTIM="$with_optim $OPTIM"
296 fi
297 fi
298
e1d6a774 299 if test "x$with_optim" = x; then
300 OPTIM="-fullwarn -woff 1183,1209,1349,1506,3201 $OPTIM"
ef416fc2 301 fi
302
e1d6a774 303 if test "x$enable_32bit" = xyes; then
304 # Build 32-bit libraries, 64-bit base...
305 if test -z "$with_arch32flags"; then
306 ARCH32FLAGS="-n32 -mips3"
307 else
308 ARCH32FLAGS="$with_arch32flags"
309 fi
e1d6a774 310
311 if test -z "$with_archflags"; then
312 if test -z "$with_arch64flags"; then
313 ARCHFLAGS="-64 -mips4"
314 else
315 ARCHFLAGS="$with_arch64flags"
316 fi
e1d6a774 317 fi
318 fi
319
320 if test "x$enable_64bit" = xyes; then
321 # Build 64-bit libraries, 32-bit base...
322 if test -z "$with_arch64flags"; then
323 ARCH64FLAGS="-64 -mips4"
324 else
325 ARCH64FLAGS="$with_arch64flags"
326 fi
e1d6a774 327
328 if test -z "$with_archflags"; then
329 if test -z "$with_arch32flags"; then
330 ARCHFLAGS="-n32 -mips3"
331 else
332 ARCHFLAGS="$with_arch32flags"
333 fi
ef416fc2 334 fi
335 fi
336 ;;
2abf387c 337 OSF*)
338 # Tru64 UNIX aka Digital UNIX aka OSF/1
339 if test -z "$OPTIM"; then
340 if test "x$with_optim" = x; then
341 OPTIM="-O"
342 else
343 OPTIM="$with_optim"
344 fi
345 fi
346 ;;
ef416fc2 347 SunOS*)
348 # Solaris
349 if test -z "$OPTIM"; then
350 if test "x$with_optim" = x; then
ed486911 351 OPTIM="-xO2"
ef416fc2 352 else
353 OPTIM="$with_optim $OPTIM"
354 fi
355 fi
356
ef416fc2 357 if test $PICFLAG = 1; then
358 OPTIM="-KPIC $OPTIM"
359 fi
e1d6a774 360
361 if test "x$enable_32bit" = xyes; then
362 # Compiling on a Solaris system, build 64-bit
363 # binaries with separate 32-bit libraries...
364 ARCH32FLAGS="-xarch=generic"
e1d6a774 365
366 if test "x$with_optim" = x; then
367 # Suppress all of Sun's questionable
368 # warning messages, and default to
369 # 64-bit compiles of everything else...
370 OPTIM="-w $OPTIM"
f301802f 371 fi
372
373 if test -z "$with_archflags"; then
374 if test -z "$with_arch64flags"; then
375 ARCHFLAGS="-xarch=generic64"
376 else
377 ARCHFLAGS="$with_arch64flags"
378 fi
e1d6a774 379 fi
380 else
381 if test "x$enable_64bit" = xyes; then
382 # Build 64-bit libraries...
383 ARCH64FLAGS="-xarch=generic64"
f301802f 384 fi
385
386 if test "x$with_optim" = x; then
387 # Suppress all of Sun's questionable
388 # warning messages, and default to
389 # 32-bit compiles of everything else...
390 OPTIM="-w $OPTIM"
391 fi
e1d6a774 392
f301802f 393 if test -z "$with_archflags"; then
394 if test -z "$with_arch32flags"; then
395 ARCHFLAGS="-xarch=generic"
396 else
397 ARCHFLAGS="$with_arch32flags"
e1d6a774 398 fi
e1d6a774 399 fi
400 fi
ef416fc2 401 ;;
402 UNIX_SVR*)
403 # UnixWare
404 if test -z "$OPTIM"; then
405 if test "x$with_optim" = x; then
406 OPTIM="-O"
407 else
408 OPTIM="$with_optim $OPTIM"
409 fi
410 fi
411
412 if test $PICFLAG = 1; then
413 OPTIM="-KPIC $OPTIM"
414 fi
415 ;;
416 *)
417 # Running some other operating system; inform the user they
418 # should contribute the necessary options to
419 # cups-support@cups.org...
420 echo "Building CUPS with default compiler optimizations; contact"
421 echo "cups-bugs@cups.org with uname and compiler options needed"
422 echo "for your platform, or set the CFLAGS and CXXFLAGS"
423 echo "environment variable before running configure."
424 ;;
425 esac
426fi
427
2abf387c 428# Add general compiler options per platform...
429case $uname in
430 HP-UX*)
431 # HP-UX 10.20 (at least) needs this definition to get the
432 # h_errno global...
433 OPTIM="$OPTIM -D_XOPEN_SOURCE_EXTENDED"
434
435 # HP-UX 11.00 (at least) needs this definition to get the
436 # u_short type used by the IP headers...
437 OPTIM="$OPTIM -D_INCLUDE_HPUX_SOURCE"
b94498cf 438
439 # HP-UX 11.23 (at least) needs this definition to get the
440 # IPv6 header to work...
441 OPTIM="$OPTIM -D_HPUX_SOURCE"
2abf387c 442 ;;
443
444 OSF*)
445 # Tru64 UNIX aka Digital UNIX aka OSF/1 need to be told
446 # to be POSIX-compliant...
447 OPTIM="$OPTIM -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_OSF_SOURCE"
448 ;;
449esac
ef416fc2 450
451dnl
bc44d920 452dnl End of "$Id: cups-compiler.m4 6649 2007-07-11 21:46:42Z mike $".
ef416fc2 453dnl