]> git.ipfire.org Git - thirdparty/cups.git/blob - config-scripts/cups-compiler.m4
Load cups into easysw/current.
[thirdparty/cups.git] / config-scripts / cups-compiler.m4
1 dnl
2 dnl "$Id: cups-compiler.m4 6447 2007-04-10 18:02:00Z mike $"
3 dnl
4 dnl Compiler stuff for the Common UNIX Printing System (CUPS).
5 dnl
6 dnl Copyright 1997-2007 by Easy Software Products, all rights reserved.
7 dnl
8 dnl These coded instructions, statements, and computer programs are the
9 dnl property of Easy Software Products and are protected by Federal
10 dnl copyright law. Distribution and use rights are outlined in the file
11 dnl "LICENSE.txt" which should have been included with this file. If this
12 dnl file is missing or damaged please contact Easy Software Products
13 dnl at:
14 dnl
15 dnl Attn: CUPS Licensing Information
16 dnl Easy Software Products
17 dnl 44141 Airport View Drive, Suite 204
18 dnl Hollywood, Maryland 20636 USA
19 dnl
20 dnl Voice: (301) 373-9600
21 dnl EMail: cups-info@cups.org
22 dnl WWW: http://www.cups.org
23 dnl
24
25 dnl Clear the debugging and non-shared library options unless the user asks
26 dnl for them...
27 OPTIM=""
28 AC_SUBST(OPTIM)
29
30 AC_ARG_WITH(optim, [ --with-optim="flags" set optimization flags ])
31 AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging, default=no],
32 [if test x$enable_debug = xyes; then
33 OPTIM="-g"
34 fi])
35
36 dnl Setup general architecture flags...
37 AC_ARG_WITH(archflags, [ --with-archflags="flags"
38 set default architecture flags ])
39
40 if test -z "$with_archflags"; then
41 ARCHFLAGS=""
42 else
43 ARCHFLAGS="$with_archflags"
44 fi
45
46 AC_SUBST(ARCHFLAGS)
47
48 dnl Setup support for separate 32/64-bit library generation...
49 AC_ARG_WITH(arch32flags, [ --with-arch32flags="flags"
50 specifies 32-bit architecture flags])
51 ARCH32FLAGS=""
52 AC_SUBST(ARCH32FLAGS)
53
54 AC_ARG_WITH(arch64flags, [ --with-arch64flags="flags"
55 specifies 64-bit architecture flags])
56 ARCH64FLAGS=""
57 AC_SUBST(ARCH64FLAGS)
58
59 dnl Position-Independent Executable support on Linux...
60 AC_ARG_ENABLE(pie, [ --enable-pie use GCC -fPIE option, default=no])
61
62 dnl Read-only data/program support on Linux...
63 AC_ARG_ENABLE(relro, [ --enable-relro use GCC relro option, default=no])
64
65 dnl Update compiler options...
66 CXXLIBS=""
67 AC_SUBST(CXXLIBS)
68
69 PIEFLAGS=""
70 AC_SUBST(PIEFLAGS)
71
72 RELROFLAGS=""
73 AC_SUBST(RELROFLAGS)
74
75 if test -n "$GCC"; then
76 # Add GCC-specific compiler options...
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
91 Linux*)
92 if test x$enable_pie = xyes; then
93 PIEFLAGS="-pie -fPIE"
94 fi
95
96 if test x$enable_relro = xyes; then
97 RELROFLAGS="-Wl,-z,relro"
98 fi
99 ;;
100
101 *)
102 if test x$enable_pie = xyes; then
103 echo "Sorry, --enable-pie is not supported on this OS!"
104 fi
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
114
115 case "$uname" in
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
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
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
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
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
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
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
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
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
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
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
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
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
256 fi
257 fi
258 ;;
259 esac
260 else
261 # Add vendor-specific compiler options...
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"
282 # Warning 336 is "empty translation unit"
283 # Warning 829 is passing constant string as char *
284 CXXFLAGS="+W336,829 $CXXFLAGS"
285
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
299 if test "x$with_optim" = x; then
300 OPTIM="-fullwarn -woff 1183,1209,1349,1506,3201 $OPTIM"
301 fi
302
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
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
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
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
334 fi
335 fi
336 ;;
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 ;;
347 SunOS*)
348 # Solaris
349 if test -z "$OPTIM"; then
350 if test "x$with_optim" = x; then
351 OPTIM="-xO2"
352 else
353 OPTIM="$with_optim $OPTIM"
354 fi
355 fi
356
357 if test $PICFLAG = 1; then
358 OPTIM="-KPIC $OPTIM"
359 fi
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"
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"
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
379 fi
380 else
381 if test "x$enable_64bit" = xyes; then
382 # Build 64-bit libraries...
383 ARCH64FLAGS="-xarch=generic64"
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
392
393 if test -z "$with_archflags"; then
394 if test -z "$with_arch32flags"; then
395 ARCHFLAGS="-xarch=generic"
396 else
397 ARCHFLAGS="$with_arch32flags"
398 fi
399 fi
400 fi
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
426 fi
427
428 # Add general compiler options per platform...
429 case $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"
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"
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 ;;
449 esac
450
451 dnl
452 dnl End of "$Id: cups-compiler.m4 6447 2007-04-10 18:02:00Z mike $".
453 dnl