]> git.ipfire.org Git - thirdparty/cups.git/blob - config-scripts/cups-common.m4
Merge changes from CUPS 1.6svn-r10437.
[thirdparty/cups.git] / config-scripts / cups-common.m4
1 dnl
2 dnl "$Id: cups-common.m4 8781 2009-08-28 17:34:54Z mike $"
3 dnl
4 dnl Common configuration stuff for CUPS.
5 dnl
6 dnl Copyright 2007-2012 by Apple Inc.
7 dnl Copyright 1997-2007 by Easy Software Products, all rights reserved.
8 dnl
9 dnl These coded instructions, statements, and computer programs are the
10 dnl property of Apple Inc. and are protected by Federal copyright
11 dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 dnl which should have been included with this file. If this file is
13 dnl file is missing or damaged, see the license at "http://www.cups.org/".
14 dnl
15
16 dnl We need at least autoconf 2.60...
17 AC_PREREQ(2.60)
18
19 dnl Set the name of the config header file...
20 AC_CONFIG_HEADER(config.h)
21
22 dnl Version number information...
23 CUPS_VERSION="1.6svn"
24 CUPS_REVISION=""
25 if test -z "$CUPS_REVISION" -a -d .svn; then
26 CUPS_REVISION="-r`svnversion . | awk -F: '{print $NF}' | sed -e '1,$s/[[a-zA-Z]]*//g'`"
27 fi
28 CUPS_BUILD="cups-$CUPS_VERSION"
29
30 AC_ARG_WITH(cups_build, [ --with-cups-build set "cups-config --build" string ],
31 CUPS_BUILD="$withval")
32
33 AC_SUBST(CUPS_VERSION)
34 AC_SUBST(CUPS_REVISION)
35 AC_SUBST(CUPS_BUILD)
36 AC_DEFINE_UNQUOTED(CUPS_SVERSION, "CUPS v$CUPS_VERSION$CUPS_REVISION")
37 AC_DEFINE_UNQUOTED(CUPS_MINIMAL, "CUPS/$CUPS_VERSION$CUPS_REVISION")
38
39 dnl Default compiler flags...
40 CFLAGS="${CFLAGS:=}"
41 CPPFLAGS="${CPPFLAGS:=}"
42 CXXFLAGS="${CXXFLAGS:=}"
43 LDFLAGS="${LDFLAGS:=}"
44
45 dnl Checks for programs...
46 AC_PROG_AWK
47 AC_PROG_CC
48 AC_PROG_CPP
49 AC_PROG_CXX
50 AC_PROG_RANLIB
51 AC_PATH_PROG(AR,ar)
52 AC_PATH_PROG(CHMOD,chmod)
53 AC_PATH_PROG(GZIP,gzip)
54 AC_PATH_PROG(HTMLDOC,htmldoc)
55 AC_PATH_PROG(LD,ld)
56 AC_PATH_PROG(LN,ln)
57 AC_PATH_PROG(MV,mv)
58 AC_PATH_PROG(RM,rm)
59 AC_PATH_PROG(RMDIR,rmdir)
60 AC_PATH_PROG(SED,sed)
61 AC_PATH_PROG(XDGOPEN,xdg-open)
62 if test "x$XDGOPEN" = x; then
63 CUPS_HTMLVIEW="htmlview"
64 else
65 CUPS_HTMLVIEW="$XDGOPEN"
66 fi
67 AC_SUBST(CUPS_HTMLVIEW)
68
69 AC_MSG_CHECKING(for install-sh script)
70 INSTALL="`pwd`/install-sh"
71 AC_SUBST(INSTALL)
72 AC_MSG_RESULT(using $INSTALL)
73
74 if test "x$AR" = x; then
75 AC_MSG_ERROR([Unable to find required library archive command.])
76 fi
77 if test "x$CC" = x; then
78 AC_MSG_ERROR([Unable to find required C compiler command.])
79 fi
80
81 dnl Static library option...
82 INSTALLSTATIC=""
83 AC_ARG_ENABLE(static, [ --enable-static install static libraries])
84
85 if test x$enable_static = xyes; then
86 echo Installing static libraries...
87 INSTALLSTATIC="installstatic"
88 fi
89
90 AC_SUBST(INSTALLSTATIC)
91
92 dnl Check for pkg-config, which is used for some other tests later on...
93 AC_PATH_PROG(PKGCONFIG, pkg-config)
94
95 dnl Check for libraries...
96 AC_SEARCH_LIBS(abs, m, AC_DEFINE(HAVE_ABS))
97 AC_SEARCH_LIBS(crypt, crypt)
98 AC_SEARCH_LIBS(fmod, m)
99 AC_SEARCH_LIBS(getspent, sec gen)
100
101 LIBMALLOC=""
102 AC_ARG_ENABLE(mallinfo, [ --enable-mallinfo build with malloc debug logging])
103
104 if test x$enable_mallinfo = xyes; then
105 SAVELIBS="$LIBS"
106 LIBS=""
107 AC_SEARCH_LIBS(mallinfo, malloc, AC_DEFINE(HAVE_MALLINFO))
108 LIBMALLOC="$LIBS"
109 LIBS="$SAVELIBS"
110 fi
111
112 AC_SUBST(LIBMALLOC)
113
114 dnl Check for libpaper support...
115 AC_ARG_ENABLE(libpaper, [ --enable-libpaper build with libpaper support])
116
117 if test x$enable_libpaper = xyes; then
118 AC_CHECK_LIB(paper,systempapername,
119 AC_DEFINE(HAVE_LIBPAPER)
120 LIBPAPER="-lpaper",
121 LIBPAPER="")
122 else
123 LIBPAPER=""
124 fi
125 AC_SUBST(LIBPAPER)
126
127 dnl Checks for header files.
128 AC_HEADER_STDC
129 AC_CHECK_HEADER(stdlib.h,AC_DEFINE(HAVE_STDLIB_H))
130 AC_CHECK_HEADER(crypt.h,AC_DEFINE(HAVE_CRYPT_H))
131 AC_CHECK_HEADER(langinfo.h,AC_DEFINE(HAVE_LANGINFO_H))
132 AC_CHECK_HEADER(malloc.h,AC_DEFINE(HAVE_MALLOC_H))
133 AC_CHECK_HEADER(shadow.h,AC_DEFINE(HAVE_SHADOW_H))
134 AC_CHECK_HEADER(string.h,AC_DEFINE(HAVE_STRING_H))
135 AC_CHECK_HEADER(strings.h,AC_DEFINE(HAVE_STRINGS_H))
136 AC_CHECK_HEADER(bstring.h,AC_DEFINE(HAVE_BSTRING_H))
137 AC_CHECK_HEADER(usersec.h,AC_DEFINE(HAVE_USERSEC_H))
138 AC_CHECK_HEADER(sys/ioctl.h,AC_DEFINE(HAVE_SYS_IOCTL_H))
139 AC_CHECK_HEADER(sys/param.h,AC_DEFINE(HAVE_SYS_PARAM_H))
140 AC_CHECK_HEADER(sys/ucred.h,AC_DEFINE(HAVE_SYS_UCRED_H))
141 AC_CHECK_HEADER(scsi/sg.h,AC_DEFINE(HAVE_SCSI_SG_H))
142
143 dnl Checks for iconv.h and iconv_open
144 AC_CHECK_HEADER(iconv.h,
145 SAVELIBS="$LIBS"
146 LIBS=""
147 AC_SEARCH_LIBS(iconv_open,iconv,
148 AC_DEFINE(HAVE_ICONV_H)
149 SAVELIBS="$SAVELIBS $LIBS")
150 LIBS="$SAVELIBS")
151
152 dnl Checks for Mini-XML (www.minixml.org)...
153 LIBMXML=""
154 AC_CHECK_HEADER(mxml.h,
155 SAVELIBS="$LIBS"
156 AC_SEARCH_LIBS(mmxlNewElement,mxml,
157 AC_DEFINE(HAVE_MXML_H)
158 LIBMXML="-lmxml")
159 LIBS="$SAVELIBS")
160 AC_SUBST(LIBMXML)
161
162 dnl Checks for statfs and its many headers...
163 AC_CHECK_HEADER(sys/mount.h,AC_DEFINE(HAVE_SYS_MOUNT_H))
164 AC_CHECK_HEADER(sys/statfs.h,AC_DEFINE(HAVE_SYS_STATFS_H))
165 AC_CHECK_HEADER(sys/statvfs.h,AC_DEFINE(HAVE_SYS_STATVFS_H))
166 AC_CHECK_HEADER(sys/vfs.h,AC_DEFINE(HAVE_SYS_VFS_H))
167 AC_CHECK_FUNCS(statfs statvfs)
168
169 dnl Checks for string functions.
170 AC_CHECK_FUNCS(strdup strlcat strlcpy)
171 if test "$uname" = "HP-UX" -a "$uversion" = "1020"; then
172 echo Forcing snprintf emulation for HP-UX.
173 else
174 AC_CHECK_FUNCS(snprintf vsnprintf)
175 fi
176
177 dnl Check for random number functions...
178 AC_CHECK_FUNCS(random lrand48 arc4random)
179
180 dnl Check for geteuid function.
181 AC_CHECK_FUNCS(geteuid)
182
183 dnl Check for setpgid function.
184 AC_CHECK_FUNCS(setpgid)
185
186 dnl Check for vsyslog function.
187 AC_CHECK_FUNCS(vsyslog)
188
189 dnl Checks for signal functions.
190 case "$uname" in
191 Linux | GNU)
192 # Do not use sigset on Linux or GNU HURD
193 ;;
194 *)
195 # Use sigset on other platforms, if available
196 AC_CHECK_FUNCS(sigset)
197 ;;
198 esac
199
200 AC_CHECK_FUNCS(sigaction)
201
202 dnl Checks for wait functions.
203 AC_CHECK_FUNCS(waitpid wait3)
204
205 dnl See if the tm structure has the tm_gmtoff member...
206 AC_MSG_CHECKING(for tm_gmtoff member in tm structure)
207 AC_TRY_COMPILE([#include <time.h>],[struct tm t;
208 int o = t.tm_gmtoff;],
209 AC_MSG_RESULT(yes)
210 AC_DEFINE(HAVE_TM_GMTOFF),
211 AC_MSG_RESULT(no))
212
213 dnl See if the stat structure has the st_gen member...
214 AC_MSG_CHECKING(for st_gen member in stat structure)
215 AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat t;
216 int o = t.st_gen;],
217 AC_MSG_RESULT(yes)
218 AC_DEFINE(HAVE_ST_GEN),
219 AC_MSG_RESULT(no))
220
221 dnl See if we have the removefile(3) function for securely removing files
222 AC_CHECK_FUNCS(removefile)
223
224 dnl See if we have libusb...
225 AC_ARG_ENABLE(libusb, [ --enable-libusb use libusb for USB printing])
226
227 LIBUSB=""
228 AC_SUBST(LIBUSB)
229
230 if test "x$PKGCONFIG" != x; then
231 if test x$enable_libusb = xyes -o $uname != Darwin; then
232 AC_MSG_CHECKING(for libusb-1.0)
233 if $PKGCONFIG --exists libusb-1.0; then
234 AC_MSG_RESULT(yes)
235 AC_DEFINE(HAVE_LIBUSB)
236 CFLAGS="$CFLAGS `$PKGCONFIG --cflags libusb-1.0`"
237 LIBUSB="`$PKGCONFIG --libs libusb-1.0`"
238 else
239 AC_MSG_RESULT(no)
240 fi
241 fi
242 elif test x$enable_libusb = xyes; then
243 AC_MSG_ERROR(Need pkg-config to enable libusb support.)
244 fi
245
246 dnl See if we have libwrap for TCP wrappers support...
247 AC_ARG_ENABLE(tcp_wrappers, [ --enable-tcp-wrappers use libwrap for TCP wrappers support])
248
249 LIBWRAP=""
250 AC_SUBST(LIBWRAP)
251
252 if test x$enable_tcp_wrappers = xyes; then
253 AC_CHECK_LIB(wrap, hosts_access,[
254 AC_CHECK_HEADER(tcpd.h,
255 AC_DEFINE(HAVE_TCPD_H)
256 LIBWRAP="-lwrap")])
257 fi
258
259 dnl ZLIB
260 INSTALL_GZIP=""
261 LIBZ=""
262 AC_CHECK_HEADER(zlib.h,
263 AC_CHECK_LIB(z, gzgets,
264 AC_DEFINE(HAVE_LIBZ)
265 LIBZ="-lz"
266 LIBS="$LIBS -lz"
267 if test "x$GZIP" != z; then
268 INSTALL_GZIP="-z"
269 fi))
270 AC_SUBST(INSTALL_GZIP)
271 AC_SUBST(LIBZ)
272
273 dnl Flags for "ar" command...
274 case $uname in
275 Darwin* | *BSD*)
276 ARFLAGS="-rcv"
277 ;;
278 *)
279 ARFLAGS="crvs"
280 ;;
281 esac
282
283 AC_SUBST(ARFLAGS)
284
285 dnl Prep libraries specifically for cupsd and backends...
286 BACKLIBS=""
287 SERVERLIBS=""
288 AC_SUBST(BACKLIBS)
289 AC_SUBST(SERVERLIBS)
290
291 dnl See if we have POSIX ACL support...
292 SAVELIBS="$LIBS"
293 LIBS=""
294 AC_ARG_ENABLE(acl, [ --enable-acl build with POSIX ACL support])
295 if test "x$enable_acl" != xno; then
296 AC_SEARCH_LIBS(acl_init, acl, AC_DEFINE(HAVE_ACL_INIT))
297 SERVERLIBS="$SERVERLIBS $LIBS"
298 fi
299 LIBS="$SAVELIBS"
300
301 dnl Check for DBUS support
302 if test -d /etc/dbus-1; then
303 DBUSDIR="/etc/dbus-1"
304 else
305 DBUSDIR=""
306 fi
307
308 AC_ARG_ENABLE(dbus, [ --enable-dbus build with DBUS support])
309 AC_ARG_WITH(dbusdir, [ --with-dbusdir set DBUS configuration directory ],
310 DBUSDIR="$withval")
311
312 DBUS_NOTIFIER=""
313 DBUS_NOTIFIERLIBS=""
314
315 if test "x$enable_dbus" != xno -a "x$PKGCONFIG" != x; then
316 AC_MSG_CHECKING(for DBUS)
317 if $PKGCONFIG --exists dbus-1; then
318 AC_MSG_RESULT(yes)
319 AC_DEFINE(HAVE_DBUS)
320 CFLAGS="$CFLAGS `$PKGCONFIG --cflags dbus-1` -DDBUS_API_SUBJECT_TO_CHANGE"
321 SERVERLIBS="$SERVERLIBS `$PKGCONFIG --libs dbus-1`"
322 DBUS_NOTIFIER="dbus"
323 DBUS_NOTIFIERLIBS="`$PKGCONFIG --libs dbus-1`"
324 SAVELIBS="$LIBS"
325 LIBS="$LIBS $DBUS_NOTIFIERLIBS"
326 AC_CHECK_FUNC(dbus_message_iter_init_append,
327 AC_DEFINE(HAVE_DBUS_MESSAGE_ITER_INIT_APPEND))
328 LIBS="$SAVELIBS"
329 else
330 AC_MSG_RESULT(no)
331 fi
332 fi
333
334 AC_SUBST(DBUSDIR)
335 AC_SUBST(DBUS_NOTIFIER)
336 AC_SUBST(DBUS_NOTIFIERLIBS)
337
338 dnl Extra platform-specific libraries...
339 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@SYSTEM"
340 CUPS_SYSTEM_AUTHKEY=""
341 INSTALLXPC=""
342
343 case $uname in
344 Darwin*)
345 BACKLIBS="$BACKLIBS -framework IOKit"
346 SERVERLIBS="$SERVERLIBS -framework IOKit -weak_framework ApplicationServices"
347 LIBS="-framework SystemConfiguration -framework CoreFoundation -framework Security $LIBS"
348
349 dnl Check for framework headers...
350 AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h,AC_DEFINE(HAVE_APPLICATIONSERVICES_H))
351 AC_CHECK_HEADER(CoreFoundation/CoreFoundation.h,AC_DEFINE(HAVE_COREFOUNDATION_H))
352 AC_CHECK_HEADER(CoreFoundation/CFPriv.h,AC_DEFINE(HAVE_CFPRIV_H))
353 AC_CHECK_HEADER(CoreFoundation/CFBundlePriv.h,AC_DEFINE(HAVE_CFBUNDLEPRIV_H))
354 AC_CHECK_HEADER(IOKit/pwr_mgt/IOPMLibPrivate.h,AC_DEFINE(HAVE_IOKIT_PWR_MGT_IOPMLIBPRIVATE_H))
355
356 dnl Check for dynamic store function...
357 AC_CHECK_FUNCS(SCDynamicStoreCopyComputerName)
358
359 dnl Check for the new membership functions in MacOSX 10.4...
360 AC_CHECK_HEADER(membership.h,AC_DEFINE(HAVE_MEMBERSHIP_H))
361 AC_CHECK_HEADER(membershipPriv.h,AC_DEFINE(HAVE_MEMBERSHIPPRIV_H))
362 AC_CHECK_FUNCS(mbr_uid_to_uuid)
363
364 dnl Check for the vproc_transaction_begin/end stuff...
365 AC_CHECK_FUNCS(vproc_transaction_begin)
366
367 dnl Need <dlfcn.h> header...
368 AC_CHECK_HEADER(dlfcn.h,AC_DEFINE(HAVE_DLFCN_H))
369
370 dnl Check for notify_post support
371 AC_CHECK_HEADER(notify.h,AC_DEFINE(HAVE_NOTIFY_H))
372 AC_CHECK_FUNCS(notify_post)
373
374 dnl Check for Authorization Services support
375 AC_ARG_WITH(adminkey, [ --with-adminkey set the default SystemAuthKey value],
376 default_adminkey="$withval",
377 default_adminkey="default")
378 AC_ARG_WITH(operkey, [ --with-operkey set the default operator @AUTHKEY value],
379 default_operkey="$withval",
380 default_operkey="default")
381
382 AC_CHECK_HEADER(Security/Authorization.h, [
383 AC_DEFINE(HAVE_AUTHORIZATION_H)
384
385 if test "x$default_adminkey" != xdefault; then
386 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey $default_adminkey"
387 elif grep -q system.print.operator /etc/authorization; then
388 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.print.admin"
389 else
390 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.preferences"
391 fi
392
393 if test "x$default_operkey" != xdefault; then
394 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY($default_operkey) @admin @lpadmin"
395 elif grep -q system.print.operator /etc/authorization; then
396 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.operator) @admin @lpadmin"
397 else
398 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.admin) @admin @lpadmin"
399 fi])
400 AC_CHECK_HEADER(Security/SecBasePriv.h,AC_DEFINE(HAVE_SECBASEPRIV_H))
401
402 dnl Check for sandbox/Seatbelt support
403 if test $uversion -ge 100; then
404 AC_CHECK_HEADER(sandbox.h,AC_DEFINE(HAVE_SANDBOX_H))
405 fi
406 if test $uversion -ge 110; then
407 # Broken public headers in 10.7...
408 AC_MSG_CHECKING(for sandbox/private.h presence)
409 if test -f /usr/local/include/sandbox/private.h; then
410 AC_MSG_RESULT(yes)
411 else
412 AC_MSG_RESULT(no)
413 AC_MSG_ERROR(Run 'sudo mkdir -p /usr/local/include/sandbox' and 'sudo touch /usr/local/include/sandbox/private.h' to build CUPS.)
414 fi
415 fi
416
417 dnl Check for XPC support
418 AC_CHECK_HEADER(xpc/xpc.h,
419 AC_DEFINE(HAVE_XPC)
420 INSTALLXPC="install-xpc")
421 AC_CHECK_HEADER(xpc/private.h,
422 AC_DEFINE(HAVE_XPC_PRIVATE_H))
423 ;;
424 esac
425
426 AC_SUBST(CUPS_DEFAULT_PRINTOPERATOR_AUTH)
427 AC_DEFINE_UNQUOTED(CUPS_DEFAULT_PRINTOPERATOR_AUTH, "$CUPS_DEFAULT_PRINTOPERATOR_AUTH")
428 AC_SUBST(CUPS_SYSTEM_AUTHKEY)
429 AC_SUBST(INSTALLXPC)
430
431 dnl Check for build components
432 COMPONENTS="all"
433
434 AC_ARG_WITH(components, [ --with-components set components to build:
435 - "all" (default) builds everything
436 - "core" builds libcups and ipptool],
437 COMPONENTS="$withval")
438
439 case "$COMPONENTS" in
440 all)
441 BUILDDIRS="filter backend berkeley cgi-bin monitor notifier ppdc scheduler systemv conf data desktop locale man doc examples templates"
442 ;;
443
444 core)
445 BUILDDIRS="data locale"
446 ;;
447
448 *)
449 AC_MSG_ERROR([Bad build component "$COMPONENT" specified!])
450 ;;
451 esac
452
453 AC_SUBST(BUILDDIRS)
454
455 dnl
456 dnl End of "$Id: cups-common.m4 8781 2009-08-28 17:34:54Z mike $".
457 dnl