4 dnl Common configuration stuff for CUPS.
6 dnl Copyright 2007-2014 by Apple Inc.
7 dnl Copyright 1997-2007 by Easy Software Products, all rights reserved.
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/".
16 dnl We need at least autoconf 2.60...
19 dnl Set the name of the config header file...
20 AC_CONFIG_HEADER(config.h)
22 dnl Version number information...
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'`"
28 CUPS_BUILD="cups-$CUPS_VERSION"
30 AC_ARG_WITH(cups_build, [ --with-cups-build set "cups-config --build" string ],
31 CUPS_BUILD="$withval")
33 AC_SUBST(CUPS_VERSION)
34 AC_SUBST(CUPS_REVISION)
36 AC_DEFINE_UNQUOTED(CUPS_SVERSION, "CUPS v$CUPS_VERSION$CUPS_REVISION")
37 AC_DEFINE_UNQUOTED(CUPS_MINIMAL, "CUPS/$CUPS_VERSION$CUPS_REVISION")
39 dnl Default compiler flags...
41 CPPFLAGS="${CPPFLAGS:=}"
42 CXXFLAGS="${CXXFLAGS:=}"
43 LDFLAGS="${LDFLAGS:=}"
45 dnl Checks for programs...
47 AC_PROG_CC(clang cc gcc)
49 AC_PROG_CXX(clang++ c++ g++)
52 AC_PATH_PROG(CHMOD,chmod)
53 AC_PATH_PROG(GZIP,gzip)
58 AC_PATH_PROG(RMDIR,rmdir)
60 AC_PATH_PROG(XDGOPEN,xdg-open)
61 if test "x$XDGOPEN" = x; then
62 CUPS_HTMLVIEW="htmlview"
64 CUPS_HTMLVIEW="$XDGOPEN"
66 AC_SUBST(CUPS_HTMLVIEW)
68 AC_MSG_CHECKING(for install-sh script)
69 INSTALL="`pwd`/install-sh"
71 AC_MSG_RESULT(using $INSTALL)
73 if test "x$AR" = x; then
74 AC_MSG_ERROR([Unable to find required library archive command.])
76 if test "x$CC" = x; then
77 AC_MSG_ERROR([Unable to find required C compiler command.])
80 dnl Static library option...
82 AC_ARG_ENABLE(static, [ --enable-static install static libraries])
84 if test x$enable_static = xyes; then
85 echo Installing static libraries...
86 INSTALLSTATIC="installstatic"
89 AC_SUBST(INSTALLSTATIC)
91 dnl Check for pkg-config, which is used for some other tests later on...
92 AC_PATH_TOOL(PKGCONFIG, pkg-config)
94 dnl Check for libraries...
95 AC_SEARCH_LIBS(abs, m, AC_DEFINE(HAVE_ABS))
96 AC_SEARCH_LIBS(crypt, crypt)
97 AC_SEARCH_LIBS(fmod, m)
98 AC_SEARCH_LIBS(getspent, sec gen)
101 AC_ARG_ENABLE(mallinfo, [ --enable-mallinfo build with malloc debug logging])
103 if test x$enable_mallinfo = xyes; then
106 AC_SEARCH_LIBS(mallinfo, malloc, AC_DEFINE(HAVE_MALLINFO))
113 dnl Check for libpaper support...
114 AC_ARG_ENABLE(libpaper, [ --enable-libpaper build with libpaper support])
116 if test x$enable_libpaper = xyes; then
117 AC_CHECK_LIB(paper,systempapername,
118 AC_DEFINE(HAVE_LIBPAPER)
126 dnl Checks for header files.
128 AC_CHECK_HEADER(stdlib.h,AC_DEFINE(HAVE_STDLIB_H))
129 AC_CHECK_HEADER(crypt.h,AC_DEFINE(HAVE_CRYPT_H))
130 AC_CHECK_HEADER(langinfo.h,AC_DEFINE(HAVE_LANGINFO_H))
131 AC_CHECK_HEADER(malloc.h,AC_DEFINE(HAVE_MALLOC_H))
132 AC_CHECK_HEADER(shadow.h,AC_DEFINE(HAVE_SHADOW_H))
133 AC_CHECK_HEADER(stdint.h,AC_DEFINE(HAVE_STDINT_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(sys/ioctl.h,AC_DEFINE(HAVE_SYS_IOCTL_H))
138 AC_CHECK_HEADER(sys/param.h,AC_DEFINE(HAVE_SYS_PARAM_H))
139 AC_CHECK_HEADER(sys/ucred.h,AC_DEFINE(HAVE_SYS_UCRED_H))
140 AC_CHECK_HEADER(asl.h,AC_DEFINE(HAVE_ASL_H))
141 AC_CHECK_HEADER(systemd/sd-journal.h,AC_DEFINE(HAVE_SYSTEMD_SD_JOURNAL_H))
143 dnl Checks for iconv.h and iconv_open
144 AC_CHECK_HEADER(iconv.h,
147 AC_SEARCH_LIBS(iconv_open,iconv,
148 AC_DEFINE(HAVE_ICONV_H)
149 SAVELIBS="$SAVELIBS $LIBS")
150 AC_SEARCH_LIBS(libiconv_open,iconv,
151 AC_DEFINE(HAVE_ICONV_H)
152 SAVELIBS="$SAVELIBS $LIBS")
155 dnl Checks for Mini-XML (www.minixml.org)...
157 AC_CHECK_HEADER(mxml.h,
159 AC_SEARCH_LIBS(mmxlNewElement,mxml,
160 AC_DEFINE(HAVE_MXML_H)
165 dnl Checks for statfs and its many headers...
166 AC_CHECK_HEADER(sys/mount.h,AC_DEFINE(HAVE_SYS_MOUNT_H))
167 AC_CHECK_HEADER(sys/statfs.h,AC_DEFINE(HAVE_SYS_STATFS_H))
168 AC_CHECK_HEADER(sys/statvfs.h,AC_DEFINE(HAVE_SYS_STATVFS_H))
169 AC_CHECK_HEADER(sys/vfs.h,AC_DEFINE(HAVE_SYS_VFS_H))
170 AC_CHECK_FUNCS(statfs statvfs)
172 dnl Checks for string functions.
173 AC_CHECK_FUNCS(strdup strlcat strlcpy)
174 if test "$uname" = "HP-UX" -a "$uversion" = "1020"; then
175 echo Forcing snprintf emulation for HP-UX.
177 AC_CHECK_FUNCS(snprintf vsnprintf)
180 dnl Check for random number functions...
181 AC_CHECK_FUNCS(random lrand48 arc4random)
183 dnl Check for geteuid function.
184 AC_CHECK_FUNCS(geteuid)
186 dnl Check for setpgid function.
187 AC_CHECK_FUNCS(setpgid)
189 dnl Check for vsyslog function.
190 AC_CHECK_FUNCS(vsyslog)
192 dnl Checks for signal functions.
195 # Do not use sigset on Linux or GNU HURD
198 # Use sigset on other platforms, if available
199 AC_CHECK_FUNCS(sigset)
203 AC_CHECK_FUNCS(sigaction)
205 dnl Checks for wait functions.
206 AC_CHECK_FUNCS(waitpid wait3)
208 dnl Check for posix_spawn
209 AC_CHECK_FUNCS(posix_spawn)
211 dnl See if the tm structure has the tm_gmtoff member...
212 AC_MSG_CHECKING(for tm_gmtoff member in tm structure)
213 AC_TRY_COMPILE([#include <time.h>],[struct tm t;
214 int o = t.tm_gmtoff;],
216 AC_DEFINE(HAVE_TM_GMTOFF),
219 dnl See if the stat structure has the st_gen member...
220 AC_MSG_CHECKING(for st_gen member in stat structure)
221 AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat t;
224 AC_DEFINE(HAVE_ST_GEN),
227 dnl See if we have the removefile(3) function for securely removing files
228 AC_CHECK_FUNCS(removefile)
230 dnl See if we have libusb...
231 AC_ARG_ENABLE(libusb, [ --enable-libusb use libusb for USB printing])
238 if test "x$PKGCONFIG" != x; then
239 if test x$enable_libusb != xno -a $uname != Darwin; then
240 AC_MSG_CHECKING(for libusb-1.0)
241 if $PKGCONFIG --exists libusb-1.0; then
243 AC_DEFINE(HAVE_LIBUSB)
244 CFLAGS="$CFLAGS `$PKGCONFIG --cflags libusb-1.0`"
245 LIBUSB="`$PKGCONFIG --libs libusb-1.0`"
246 USBQUIRKS="\$(DATADIR)/usb"
249 if test x$enable_libusb = xyes; then
250 AC_MSG_ERROR(libusb required for --enable-libusb.)
254 elif test x$enable_libusb = xyes; then
255 AC_MSG_ERROR(Need pkg-config to enable libusb support.)
258 dnl See if we have libwrap for TCP wrappers support...
259 AC_ARG_ENABLE(tcp_wrappers, [ --enable-tcp-wrappers use libwrap for TCP wrappers support])
264 if test x$enable_tcp_wrappers = xyes; then
265 AC_CHECK_LIB(wrap, hosts_access,[
266 AC_CHECK_HEADER(tcpd.h,
267 AC_DEFINE(HAVE_TCPD_H)
274 AC_CHECK_HEADER(zlib.h,
275 AC_CHECK_LIB(z, gzgets,
279 AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_INFLATECOPY))
280 if test "x$GZIP" != z; then
283 AC_SUBST(INSTALL_GZIP)
286 dnl Flags for "ar" command...
298 dnl Prep libraries specifically for cupsd and backends...
304 dnl See if we have POSIX ACL support...
307 AC_ARG_ENABLE(acl, [ --enable-acl build with POSIX ACL support])
308 if test "x$enable_acl" != xno; then
309 AC_SEARCH_LIBS(acl_init, acl, AC_DEFINE(HAVE_ACL_INIT))
310 SERVERLIBS="$SERVERLIBS $LIBS"
314 dnl Check for DBUS support
315 AC_ARG_ENABLE(dbus, [ --disable-dbus build without DBUS support])
316 AC_ARG_WITH(dbusdir, [ --with-dbusdir set DBUS configuration directory ],
323 if test "x$enable_dbus" != xno -a "x$PKGCONFIG" != x; then
324 AC_MSG_CHECKING(for DBUS)
325 if $PKGCONFIG --exists dbus-1; then
328 CFLAGS="$CFLAGS `$PKGCONFIG --cflags dbus-1` -DDBUS_API_SUBJECT_TO_CHANGE"
329 SERVERLIBS="$SERVERLIBS `$PKGCONFIG --libs dbus-1`"
331 DBUS_NOTIFIERLIBS="`$PKGCONFIG --libs dbus-1`"
333 LIBS="$LIBS $DBUS_NOTIFIERLIBS"
334 AC_CHECK_FUNC(dbus_message_iter_init_append,
335 AC_DEFINE(HAVE_DBUS_MESSAGE_ITER_INIT_APPEND))
336 AC_CHECK_FUNC(dbus_threads_init,
337 AC_DEFINE(HAVE_DBUS_THREADS_INIT))
339 if test -d /etc/dbus-1; then
340 DBUSDIR="/etc/dbus-1"
348 AC_SUBST(DBUS_NOTIFIER)
349 AC_SUBST(DBUS_NOTIFIERLIBS)
351 dnl Extra platform-specific libraries...
352 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@SYSTEM"
353 CUPS_DEFAULT_SYSTEM_AUTHKEY=""
354 CUPS_SYSTEM_AUTHKEY=""
359 BACKLIBS="$BACKLIBS -framework IOKit"
360 SERVERLIBS="$SERVERLIBS -framework IOKit -weak_framework ApplicationServices"
361 LIBS="-framework SystemConfiguration -framework CoreFoundation -framework Security $LIBS"
363 dnl Check for framework headers...
364 AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h,AC_DEFINE(HAVE_APPLICATIONSERVICES_H))
365 AC_CHECK_HEADER(CoreFoundation/CoreFoundation.h,AC_DEFINE(HAVE_COREFOUNDATION_H))
366 AC_CHECK_HEADER(CoreFoundation/CFPriv.h,AC_DEFINE(HAVE_CFPRIV_H))
367 AC_CHECK_HEADER(CoreFoundation/CFBundlePriv.h,AC_DEFINE(HAVE_CFBUNDLEPRIV_H))
369 dnl Check for dynamic store function...
370 AC_CHECK_FUNCS(SCDynamicStoreCopyComputerName)
372 dnl Check for the new membership functions in MacOSX 10.4...
373 AC_CHECK_HEADER(membership.h,AC_DEFINE(HAVE_MEMBERSHIP_H))
374 AC_CHECK_HEADER(membershipPriv.h,AC_DEFINE(HAVE_MEMBERSHIPPRIV_H))
375 AC_CHECK_FUNCS(mbr_uid_to_uuid)
377 dnl Need <dlfcn.h> header...
378 AC_CHECK_HEADER(dlfcn.h,AC_DEFINE(HAVE_DLFCN_H))
380 dnl Check for notify_post support
381 AC_CHECK_HEADER(notify.h,AC_DEFINE(HAVE_NOTIFY_H))
382 AC_CHECK_FUNCS(notify_post)
384 dnl Check for Authorization Services support
385 AC_ARG_WITH(adminkey, [ --with-adminkey set the default SystemAuthKey value],
386 default_adminkey="$withval",
387 default_adminkey="default")
388 AC_ARG_WITH(operkey, [ --with-operkey set the default operator @AUTHKEY value],
389 default_operkey="$withval",
390 default_operkey="default")
392 AC_CHECK_HEADER(Security/Authorization.h, [
393 AC_DEFINE(HAVE_AUTHORIZATION_H)
395 if test "x$default_adminkey" != xdefault; then
396 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey $default_adminkey"
397 CUPS_DEFAULT_SYSTEM_AUTHKEY="$default_adminkey"
398 elif grep -q system.print.operator /etc/authorization; then
399 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.print.admin"
400 CUPS_DEFAULT_SYSTEM_AUTHKEY="system.print.admin"
402 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.preferences"
403 CUPS_DEFAULT_SYSTEM_AUTHKEY="system.preferences"
406 if test "x$default_operkey" != xdefault; then
407 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY($default_operkey) @admin @lpadmin"
408 elif grep -q system.print.operator /etc/authorization; then
409 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.operator) @admin @lpadmin"
411 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.admin) @admin @lpadmin"
413 AC_CHECK_HEADER(Security/SecBasePriv.h,AC_DEFINE(HAVE_SECBASEPRIV_H))
415 dnl Check for sandbox/Seatbelt support
416 if test $uversion -ge 100; then
417 AC_CHECK_HEADER(sandbox.h,AC_DEFINE(HAVE_SANDBOX_H))
419 if test $uversion -ge 110 -a $uversion -lt 120; then
420 # Broken public headers in 10.7.x...
421 AC_MSG_CHECKING(for sandbox/private.h presence)
422 if test -f /usr/local/include/sandbox/private.h; then
426 AC_MSG_ERROR(Run 'sudo mkdir -p /usr/local/include/sandbox' and 'sudo touch /usr/local/include/sandbox/private.h' to build CUPS.)
430 dnl Check for XPC support
431 AC_CHECK_HEADER(xpc/xpc.h,
433 INSTALLXPC="install-xpc")
434 AC_CHECK_HEADER(xpc/private.h,
435 AC_DEFINE(HAVE_XPC_PRIVATE_H))
439 AC_SUBST(CUPS_DEFAULT_PRINTOPERATOR_AUTH)
440 AC_DEFINE_UNQUOTED(CUPS_DEFAULT_PRINTOPERATOR_AUTH, "$CUPS_DEFAULT_PRINTOPERATOR_AUTH")
441 AC_DEFINE_UNQUOTED(CUPS_DEFAULT_SYSTEM_AUTHKEY, "$CUPS_DEFAULT_SYSTEM_AUTHKEY")
442 AC_SUBST(CUPS_SYSTEM_AUTHKEY)
445 dnl Check for build components
448 AC_ARG_WITH(components, [ --with-components set components to build:
449 - "all" (default) builds everything
450 - "core" builds libcups and ipptool],
451 COMPONENTS="$withval")
453 case "$COMPONENTS" in
455 BUILDDIRS="filter backend berkeley cgi-bin monitor notifier ppdc scheduler systemv conf data desktop locale man doc examples templates"
459 BUILDDIRS="data locale"
463 AC_MSG_ERROR([Bad build component "$COMPONENT" specified!])