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