]> git.ipfire.org Git - thirdparty/cups.git/blame - config-scripts/cups-compiler.m4
Change kIOPMAssertRemoteAccess to kIOPMAssertNetworkClientActive...
[thirdparty/cups.git] / config-scripts / cups-compiler.m4
CommitLineData
ef416fc2 1dnl
b19ccc9e 2dnl "$Id: cups-compiler.m4 7871 2008-08-27 21:12:43Z mike $"
ef416fc2 3dnl
22c9029b 4dnl Compiler stuff for CUPS.
ef416fc2 5dnl
db8b865d 6dnl Copyright 2007-2013 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...
50fe7201 18INSTALL_STRIP=""
ef416fc2 19OPTIM=""
50fe7201 20AC_SUBST(INSTALL_STRIP)
ef416fc2 21AC_SUBST(OPTIM)
22
bf3816c7
MS
23AC_ARG_WITH(optim, [ --with-optim set optimization flags ])
24AC_ARG_ENABLE(debug, [ --enable-debug build with debugging symbols])
25AC_ARG_ENABLE(debug_guards, [ --enable-debug-guards build with memory allocation guards])
26AC_ARG_ENABLE(debug_printfs, [ --enable-debug-printfs build with CUPS_DEBUG_LOG support])
27AC_ARG_ENABLE(unit_tests, [ --enable-unit-tests build and run unit tests])
839a51c8
MS
28
29dnl For debugging, keep symbols, otherwise strip them...
30if test x$enable_debug = xyes; then
31 OPTIM="-g"
32else
33 INSTALL_STRIP="-s"
34fi
ef416fc2 35
5f64df29 36dnl Debug printfs can slow things down, so provide a separate option for that
52f6f666 37if test x$enable_debug_printfs = xyes; then
5f64df29 38 CFLAGS="$CFLAGS -DDEBUG"
94da7e34 39 CXXFLAGS="$CXXFLAGS -DDEBUG"
5f64df29
MS
40fi
41
745129be
MS
42dnl Debug guards use an extra 4 bytes for some structures like strings in the
43dnl string pool, so provide a separate option for that
44if test x$enable_debug_guards = xyes; then
45 CFLAGS="$CFLAGS -DDEBUG_GUARDS"
94da7e34 46 CXXFLAGS="$CXXFLAGS -DDEBUG_GUARDS"
745129be
MS
47fi
48
5f64df29
MS
49dnl Unit tests take up time during a compile...
50if test x$enable_unit_tests = xyes; then
51 UNITTESTS="unittests"
52else
53 UNITTESTS=""
54fi
55AC_SUBST(UNITTESTS)
56
ed486911 57dnl Setup general architecture flags...
bf3816c7
MS
58AC_ARG_WITH(archflags, [ --with-archflags set default architecture flags ])
59AC_ARG_WITH(ldarchflags, [ --with-ldarchflags set program architecture flags ])
ed486911 60
61if test -z "$with_archflags"; then
62 ARCHFLAGS=""
63else
64 ARCHFLAGS="$with_archflags"
a603edef
MS
65fi
66
67if test -z "$with_ldarchflags"; then
09a101d6 68 if test "$uname" = Darwin; then
12f89d24
MS
69 # Only create Intel programs by default
70 LDARCHFLAGS="`echo $ARCHFLAGS | sed -e '1,$s/-arch ppc64//'`"
09a101d6 71 else
72 LDARCHFLAGS="$ARCHFLAGS"
73 fi
a603edef 74else
839a51c8 75 LDARCHFLAGS="$with_ldarchflags"
ed486911 76fi
77
78AC_SUBST(ARCHFLAGS)
09a101d6 79AC_SUBST(LDARCHFLAGS)
ed486911 80
f7deaa1a 81dnl Read-only data/program support on Linux...
bf3816c7 82AC_ARG_ENABLE(relro, [ --enable-relro build with the GCC relro option])
f7deaa1a 83
ef416fc2 84dnl Update compiler options...
ac884b6a
MS
85CXXLIBS="${CXXLIBS:=}"
86AC_SUBST(CXXLIBS)
87
a74454a7 88PIEFLAGS=""
89AC_SUBST(PIEFLAGS)
90
f7deaa1a 91RELROFLAGS=""
92AC_SUBST(RELROFLAGS)
93
ef416fc2 94if test -n "$GCC"; then
2abf387c 95 # Add GCC-specific compiler options...
ef416fc2 96 if test -z "$OPTIM"; then
97 if test "x$with_optim" = x; then
98 # Default to optimize-for-size and debug
99 OPTIM="-Os -g"
100 else
101 OPTIM="$with_optim $OPTIM"
102 fi
103 fi
104
a4924f6c 105 # Generate position-independent code as needed...
ef416fc2 106 if test $PICFLAG = 1 -a $uname != AIX; then
107 OPTIM="-fPIC $OPTIM"
108 fi
109
a4924f6c
MS
110 # The -fstack-protector option is available with some versions of
111 # GCC and adds "stack canaries" which detect when the return address
112 # has been overwritten, preventing many types of exploit attacks.
113 AC_MSG_CHECKING(if GCC supports -fstack-protector)
114 OLDCFLAGS="$CFLAGS"
115 CFLAGS="$CFLAGS -fstack-protector"
68b10830 116 AC_TRY_LINK(,,
db8b865d
MS
117 if test "x$LSB_BUILD" = xy; then
118 # Can't use stack-protector with LSB binaries...
119 OPTIM="$OPTIM -fno-stack-protector"
120 else
121 OPTIM="$OPTIM -fstack-protector"
122 fi
a4924f6c
MS
123 AC_MSG_RESULT(yes),
124 AC_MSG_RESULT(no))
125 CFLAGS="$OLDCFLAGS"
126
db8b865d
MS
127 if test "x$LSB_BUILD" != xy; then
128 # The -fPIE option is available with some versions of GCC and
129 # adds randomization of addresses, which avoids another class of
130 # exploits that depend on a fixed address for common functions.
131 #
132 # Not available to LSB binaries...
133 AC_MSG_CHECKING(if GCC supports -fPIE)
134 OLDCFLAGS="$CFLAGS"
135 CFLAGS="$CFLAGS -fPIE"
136 AC_TRY_COMPILE(,,
137 [case "$CC" in
138 *clang)
139 PIEFLAGS="-fPIE -Wl,-pie"
140 ;;
141 *)
142 PIEFLAGS="-fPIE -pie"
143 ;;
144 esac
145 AC_MSG_RESULT(yes)],
146 AC_MSG_RESULT(no))
147 CFLAGS="$OLDCFLAGS"
148 fi
ef416fc2 149
150 if test "x$with_optim" = x; then
151 # Add useful warning options for tracking down problems...
321d8d57 152 OPTIM="-Wall -Wno-format-y2k -Wunused $OPTIM"
f228370c 153
a4924f6c 154 # Additional warning options for development testing...
d9bca400 155 if test -d .svn; then
85dda01c 156 OPTIM="-Wshadow -Werror $OPTIM"
f228370c
MS
157 else
158 AC_MSG_CHECKING(if GCC supports -Wno-tautological-compare)
159 OLDCFLAGS="$CFLAGS"
f99f3698 160 CFLAGS="$CFLAGS -Werror -Wno-tautological-compare"
f228370c
MS
161 AC_TRY_COMPILE(,,
162 [OPTIM="$OPTIM -Wno-tautological-compare"
163 AC_MSG_RESULT(yes)],
164 AC_MSG_RESULT(no))
165 CFLAGS="$OLDCFLAGS"
d9bca400 166 fi
ef416fc2 167 fi
e1d6a774 168
169 case "$uname" in
a4924f6c
MS
170 Darwin*)
171 # -D_FORTIFY_SOURCE=2 adds additional object size
172 # checking, basically wrapping all string functions
173 # with buffer-limited ones. Not strictly needed for
174 # CUPS since we already use buffer-limited calls, but
22c9029b 175 # this will catch any additions that are broken.
a4924f6c
MS
176 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
177 ;;
178
e1d6a774 179 Linux*)
a4924f6c
MS
180 # The -z relro option is provided by the Linux linker command to
181 # make relocatable data read-only.
182 if test x$enable_relro = xyes; then
183 RELROFLAGS="-Wl,-z,relro"
184 fi
e1d6a774 185 ;;
186 esac
ef416fc2 187else
2abf387c 188 # Add vendor-specific compiler options...
ef416fc2 189 case $uname in
190 AIX*)
191 if test -z "$OPTIM"; then
192 if test "x$with_optim" = x; then
193 OPTIM="-O2 -qmaxmem=6000"
194 else
195 OPTIM="$with_optim $OPTIM"
196 fi
197 fi
198 ;;
199 HP-UX*)
200 if test -z "$OPTIM"; then
201 if test "x$with_optim" = x; then
202 OPTIM="+O2"
203 else
204 OPTIM="$with_optim $OPTIM"
205 fi
206 fi
207
208 CFLAGS="-Ae $CFLAGS"
209
ef416fc2 210 if test $PICFLAG = 1; then
211 OPTIM="+z $OPTIM"
212 fi
213 ;;
2abf387c 214 OSF*)
215 # Tru64 UNIX aka Digital UNIX aka OSF/1
216 if test -z "$OPTIM"; then
217 if test "x$with_optim" = x; then
218 OPTIM="-O"
219 else
220 OPTIM="$with_optim"
221 fi
222 fi
223 ;;
ef416fc2 224 SunOS*)
225 # Solaris
226 if test -z "$OPTIM"; then
227 if test "x$with_optim" = x; then
ed486911 228 OPTIM="-xO2"
ef416fc2 229 else
230 OPTIM="$with_optim $OPTIM"
231 fi
232 fi
233
ef416fc2 234 if test $PICFLAG = 1; then
235 OPTIM="-KPIC $OPTIM"
236 fi
237 ;;
238 UNIX_SVR*)
239 # UnixWare
240 if test -z "$OPTIM"; then
241 if test "x$with_optim" = x; then
242 OPTIM="-O"
243 else
244 OPTIM="$with_optim $OPTIM"
245 fi
246 fi
247
248 if test $PICFLAG = 1; then
249 OPTIM="-KPIC $OPTIM"
250 fi
251 ;;
252 *)
253 # Running some other operating system; inform the user they
254 # should contribute the necessary options to
255 # cups-support@cups.org...
256 echo "Building CUPS with default compiler optimizations; contact"
257 echo "cups-bugs@cups.org with uname and compiler options needed"
5bd77a73
MS
258 echo "for your platform, or set the CFLAGS and LDFLAGS environment"
259 echo "variables before running configure."
ef416fc2 260 ;;
261 esac
262fi
263
2abf387c 264# Add general compiler options per platform...
265case $uname in
266 HP-UX*)
267 # HP-UX 10.20 (at least) needs this definition to get the
268 # h_errno global...
269 OPTIM="$OPTIM -D_XOPEN_SOURCE_EXTENDED"
270
271 # HP-UX 11.00 (at least) needs this definition to get the
272 # u_short type used by the IP headers...
273 OPTIM="$OPTIM -D_INCLUDE_HPUX_SOURCE"
b94498cf 274
275 # HP-UX 11.23 (at least) needs this definition to get the
276 # IPv6 header to work...
277 OPTIM="$OPTIM -D_HPUX_SOURCE"
2abf387c 278 ;;
279
dd1abb6b
MS
280 Linux*)
281 # glibc 2.8 and higher breaks peer credentials unless you
282 # define _GNU_SOURCE...
283 OPTIM="$OPTIM -D_GNU_SOURCE"
284 ;;
285
2abf387c 286 OSF*)
287 # Tru64 UNIX aka Digital UNIX aka OSF/1 need to be told
288 # to be POSIX-compliant...
289 OPTIM="$OPTIM -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_OSF_SOURCE"
290 ;;
291esac
ef416fc2 292
293dnl
b19ccc9e 294dnl End of "$Id: cups-compiler.m4 7871 2008-08-27 21:12:43Z mike $".
ef416fc2 295dnl