2 dnl Common configuration stuff for CUPS.
4 dnl Copyright 2007-2016 by Apple Inc.
5 dnl Copyright 1997-2007 by Easy Software Products, all rights reserved.
7 dnl These coded instructions, statements, and computer programs are the
8 dnl property of Apple Inc. and are protected by Federal copyright
9 dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
10 dnl which should have been included with this file. If this file is
11 dnl file is missing or damaged, see the license at "http://www.cups.org/".
14 dnl Set the name of the config header file...
15 AC_CONFIG_HEADER(config.h)
17 dnl Version number information...
18 CUPS_VERSION="AC_PACKAGE_VERSION"
20 CUPS_BUILD="cups-$CUPS_VERSION"
22 AC_ARG_WITH(cups_build, [ --with-cups-build set "cups-config --build" string ],
23 CUPS_BUILD="$withval")
25 AC_SUBST(CUPS_VERSION)
26 AC_SUBST(CUPS_REVISION)
28 AC_DEFINE_UNQUOTED(CUPS_SVERSION, "AC_PACKAGE_NAME v$CUPS_VERSION$CUPS_REVISION")
29 AC_DEFINE_UNQUOTED(CUPS_MINIMAL, "AC_PACKAGE_NAME/$CUPS_VERSION$CUPS_REVISION")
31 dnl Default compiler flags...
33 CPPFLAGS="${CPPFLAGS:=}"
34 CXXFLAGS="${CXXFLAGS:=}"
35 LDFLAGS="${LDFLAGS:=}"
37 dnl Checks for programs...
39 AC_PROG_CC(clang cc gcc)
41 AC_PROG_CXX(clang++ c++ g++)
44 AC_PATH_PROG(CHMOD,chmod)
45 AC_PATH_PROG(GZIP,gzip)
50 AC_PATH_PROG(RMDIR,rmdir)
52 AC_PATH_PROG(XDGOPEN,xdg-open)
53 if test "x$XDGOPEN" = x; then
54 CUPS_HTMLVIEW="htmlview"
56 CUPS_HTMLVIEW="$XDGOPEN"
58 AC_SUBST(CUPS_HTMLVIEW)
60 AC_MSG_CHECKING(for install-sh script)
61 INSTALL="`pwd`/install-sh"
63 AC_MSG_RESULT(using $INSTALL)
65 if test "x$AR" = x; then
66 AC_MSG_ERROR([Unable to find required library archive command.])
68 if test "x$CC" = x; then
69 AC_MSG_ERROR([Unable to find required C compiler command.])
72 dnl Static library option...
74 AC_ARG_ENABLE(static, [ --enable-static install static libraries])
76 if test x$enable_static = xyes; then
77 echo Installing static libraries...
78 INSTALLSTATIC="installstatic"
81 AC_SUBST(INSTALLSTATIC)
83 dnl Check for pkg-config, which is used for some other tests later on...
84 AC_PATH_TOOL(PKGCONFIG, pkg-config)
86 dnl Check for libraries...
87 AC_SEARCH_LIBS(abs, m, AC_DEFINE(HAVE_ABS))
88 AC_SEARCH_LIBS(crypt, crypt)
89 AC_SEARCH_LIBS(fmod, m)
90 AC_SEARCH_LIBS(getspent, sec gen)
93 AC_ARG_ENABLE(mallinfo, [ --enable-mallinfo build with malloc debug logging])
95 if test x$enable_mallinfo = xyes; then
98 AC_SEARCH_LIBS(mallinfo, malloc, AC_DEFINE(HAVE_MALLINFO))
105 dnl Check for libpaper support...
106 AC_ARG_ENABLE(libpaper, [ --enable-libpaper build with libpaper support])
108 if test x$enable_libpaper = xyes; then
109 AC_CHECK_LIB(paper,systempapername,
110 AC_DEFINE(HAVE_LIBPAPER)
118 dnl Checks for header files.
120 AC_CHECK_HEADER(stdlib.h,AC_DEFINE(HAVE_STDLIB_H))
121 AC_CHECK_HEADER(crypt.h,AC_DEFINE(HAVE_CRYPT_H))
122 AC_CHECK_HEADER(langinfo.h,AC_DEFINE(HAVE_LANGINFO_H))
123 AC_CHECK_HEADER(malloc.h,AC_DEFINE(HAVE_MALLOC_H))
124 AC_CHECK_HEADER(shadow.h,AC_DEFINE(HAVE_SHADOW_H))
125 AC_CHECK_HEADER(stdint.h,AC_DEFINE(HAVE_STDINT_H))
126 AC_CHECK_HEADER(string.h,AC_DEFINE(HAVE_STRING_H))
127 AC_CHECK_HEADER(strings.h,AC_DEFINE(HAVE_STRINGS_H))
128 AC_CHECK_HEADER(bstring.h,AC_DEFINE(HAVE_BSTRING_H))
129 AC_CHECK_HEADER(sys/ioctl.h,AC_DEFINE(HAVE_SYS_IOCTL_H))
130 AC_CHECK_HEADER(sys/param.h,AC_DEFINE(HAVE_SYS_PARAM_H))
131 AC_CHECK_HEADER(sys/ucred.h,AC_DEFINE(HAVE_SYS_UCRED_H))
132 AC_CHECK_HEADER(asl.h,AC_DEFINE(HAVE_ASL_H))
134 dnl Checks for iconv.h and iconv_open
135 AC_CHECK_HEADER(iconv.h,
138 AC_SEARCH_LIBS(iconv_open,iconv,
139 AC_DEFINE(HAVE_ICONV_H)
140 SAVELIBS="$SAVELIBS $LIBS")
141 AC_SEARCH_LIBS(libiconv_open,iconv,
142 AC_DEFINE(HAVE_ICONV_H)
143 SAVELIBS="$SAVELIBS $LIBS")
146 dnl Checks for Mini-XML (www.minixml.org)...
148 AC_CHECK_HEADER(mxml.h,
150 AC_SEARCH_LIBS(mmxlNewElement,mxml,
151 AC_DEFINE(HAVE_MXML_H)
156 dnl Checks for statfs and its many headers...
157 AC_CHECK_HEADER(sys/mount.h,AC_DEFINE(HAVE_SYS_MOUNT_H))
158 AC_CHECK_HEADER(sys/statfs.h,AC_DEFINE(HAVE_SYS_STATFS_H))
159 AC_CHECK_HEADER(sys/statvfs.h,AC_DEFINE(HAVE_SYS_STATVFS_H))
160 AC_CHECK_HEADER(sys/vfs.h,AC_DEFINE(HAVE_SYS_VFS_H))
161 AC_CHECK_FUNCS(statfs statvfs)
163 dnl Checks for string functions.
164 AC_CHECK_FUNCS(strdup strlcat strlcpy)
165 if test "$uname" = "HP-UX" -a "$uversion" = "1020"; then
166 echo Forcing snprintf emulation for HP-UX.
168 AC_CHECK_FUNCS(snprintf vsnprintf)
171 dnl Check for random number functions...
172 AC_CHECK_FUNCS(random lrand48 arc4random)
174 dnl Check for geteuid function.
175 AC_CHECK_FUNCS(geteuid)
177 dnl Check for setpgid function.
178 AC_CHECK_FUNCS(setpgid)
180 dnl Check for vsyslog function.
181 AC_CHECK_FUNCS(vsyslog)
183 dnl Checks for signal functions.
186 # Do not use sigset on Linux or GNU HURD
189 # Use sigset on other platforms, if available
190 AC_CHECK_FUNCS(sigset)
194 AC_CHECK_FUNCS(sigaction)
196 dnl Checks for wait functions.
197 AC_CHECK_FUNCS(waitpid wait3)
199 dnl Check for posix_spawn
200 AC_CHECK_FUNCS(posix_spawn)
202 dnl See if the tm structure has the tm_gmtoff member...
203 AC_MSG_CHECKING(for tm_gmtoff member in tm structure)
204 AC_TRY_COMPILE([#include <time.h>],[struct tm t;
205 int o = t.tm_gmtoff;],
207 AC_DEFINE(HAVE_TM_GMTOFF),
210 dnl See if the stat structure has the st_gen member...
211 AC_MSG_CHECKING(for st_gen member in stat structure)
212 AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat t;
215 AC_DEFINE(HAVE_ST_GEN),
218 dnl See if we have the removefile(3) function for securely removing files
219 AC_CHECK_FUNCS(removefile)
221 dnl See if we have libusb...
222 AC_ARG_ENABLE(libusb, [ --enable-libusb use libusb for USB printing])
229 if test "x$PKGCONFIG" != x; then
230 if test x$enable_libusb != xno -a $uname != Darwin; then
231 AC_MSG_CHECKING(for libusb-1.0)
232 if $PKGCONFIG --exists libusb-1.0; then
234 AC_DEFINE(HAVE_LIBUSB)
235 CFLAGS="$CFLAGS `$PKGCONFIG --cflags libusb-1.0`"
236 LIBUSB="`$PKGCONFIG --libs libusb-1.0`"
237 USBQUIRKS="\$(DATADIR)/usb"
240 if test x$enable_libusb = xyes; then
241 AC_MSG_ERROR(libusb required for --enable-libusb.)
245 elif test x$enable_libusb = xyes; then
246 AC_MSG_ERROR(Need pkg-config to enable libusb support.)
249 dnl See if we have libwrap for TCP wrappers support...
250 AC_ARG_ENABLE(tcp_wrappers, [ --enable-tcp-wrappers use libwrap for TCP wrappers support])
255 if test x$enable_tcp_wrappers = xyes; then
256 AC_CHECK_LIB(wrap, hosts_access,[
257 AC_CHECK_HEADER(tcpd.h,
258 AC_DEFINE(HAVE_TCPD_H)
265 AC_CHECK_HEADER(zlib.h,
266 AC_CHECK_LIB(z, gzgets,
270 AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_INFLATECOPY))
271 if test "x$GZIP" != z; then
274 AC_SUBST(INSTALL_GZIP)
277 dnl Flags for "ar" command...
289 dnl Prep libraries specifically for cupsd and backends...
295 dnl See if we have POSIX ACL support...
298 AC_ARG_ENABLE(acl, [ --enable-acl build with POSIX ACL support])
299 if test "x$enable_acl" != xno; then
300 AC_SEARCH_LIBS(acl_init, acl, AC_DEFINE(HAVE_ACL_INIT))
301 SERVERLIBS="$SERVERLIBS $LIBS"
305 dnl Check for DBUS support
306 AC_ARG_ENABLE(dbus, [ --disable-dbus build without DBUS support])
307 AC_ARG_WITH(dbusdir, [ --with-dbusdir set DBUS configuration directory ],
314 if test "x$enable_dbus" != xno -a "x$PKGCONFIG" != x -a "x$uname" != xDarwin; then
315 AC_MSG_CHECKING(for DBUS)
316 if $PKGCONFIG --exists dbus-1; then
319 CFLAGS="$CFLAGS `$PKGCONFIG --cflags dbus-1` -DDBUS_API_SUBJECT_TO_CHANGE"
320 SERVERLIBS="$SERVERLIBS `$PKGCONFIG --libs dbus-1`"
322 DBUS_NOTIFIERLIBS="`$PKGCONFIG --libs dbus-1`"
324 LIBS="$LIBS $DBUS_NOTIFIERLIBS"
325 AC_CHECK_FUNC(dbus_message_iter_init_append,
326 AC_DEFINE(HAVE_DBUS_MESSAGE_ITER_INIT_APPEND))
327 AC_CHECK_FUNC(dbus_threads_init,
328 AC_DEFINE(HAVE_DBUS_THREADS_INIT))
330 if test -d /etc/dbus-1; then
331 DBUSDIR="/etc/dbus-1"
339 AC_SUBST(DBUS_NOTIFIER)
340 AC_SUBST(DBUS_NOTIFIERLIBS)
342 dnl Extra platform-specific libraries...
343 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@SYSTEM"
344 CUPS_DEFAULT_SYSTEM_AUTHKEY=""
345 CUPS_SYSTEM_AUTHKEY=""
350 BACKLIBS="$BACKLIBS -framework IOKit"
351 SERVERLIBS="$SERVERLIBS -framework IOKit -weak_framework ApplicationServices"
352 LIBS="-framework SystemConfiguration -framework CoreFoundation -framework Security $LIBS"
354 dnl Check for framework headers...
355 AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h,AC_DEFINE(HAVE_APPLICATIONSERVICES_H))
356 AC_CHECK_HEADER(CoreFoundation/CoreFoundation.h,AC_DEFINE(HAVE_COREFOUNDATION_H))
357 AC_CHECK_HEADER(CoreFoundation/CFPriv.h,AC_DEFINE(HAVE_CFPRIV_H))
358 AC_CHECK_HEADER(CoreFoundation/CFBundlePriv.h,AC_DEFINE(HAVE_CFBUNDLEPRIV_H))
360 dnl Check for dynamic store function...
361 AC_CHECK_FUNCS(SCDynamicStoreCopyComputerName)
363 dnl Check for the new membership functions in MacOSX 10.4...
364 AC_CHECK_HEADER(membership.h,AC_DEFINE(HAVE_MEMBERSHIP_H))
365 AC_CHECK_HEADER(membershipPriv.h,AC_DEFINE(HAVE_MEMBERSHIPPRIV_H))
366 AC_CHECK_FUNCS(mbr_uid_to_uuid)
368 dnl Need <dlfcn.h> header...
369 AC_CHECK_HEADER(dlfcn.h,AC_DEFINE(HAVE_DLFCN_H))
371 dnl Check for notify_post support
372 AC_CHECK_HEADER(notify.h,AC_DEFINE(HAVE_NOTIFY_H))
373 AC_CHECK_FUNCS(notify_post)
375 dnl Check for Authorization Services support
376 AC_ARG_WITH(adminkey, [ --with-adminkey set the default SystemAuthKey value],
377 default_adminkey="$withval",
378 default_adminkey="default")
379 AC_ARG_WITH(operkey, [ --with-operkey set the default operator @AUTHKEY value],
380 default_operkey="$withval",
381 default_operkey="default")
383 AC_CHECK_HEADER(Security/Authorization.h, [
384 AC_DEFINE(HAVE_AUTHORIZATION_H)
386 if test "x$default_adminkey" != xdefault; then
387 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey $default_adminkey"
388 CUPS_DEFAULT_SYSTEM_AUTHKEY="$default_adminkey"
389 elif grep -q system.print.operator /etc/authorization; then
390 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.print.admin"
391 CUPS_DEFAULT_SYSTEM_AUTHKEY="system.print.admin"
393 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.preferences"
394 CUPS_DEFAULT_SYSTEM_AUTHKEY="system.preferences"
397 if test "x$default_operkey" != xdefault; then
398 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY($default_operkey) @admin @lpadmin"
399 elif grep -q system.print.operator /etc/authorization; then
400 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.operator) @admin @lpadmin"
402 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.admin) @admin @lpadmin"
404 AC_CHECK_HEADER(Security/SecBasePriv.h,AC_DEFINE(HAVE_SECBASEPRIV_H))
406 dnl Check for sandbox/Seatbelt support
407 if test $uversion -ge 100; then
408 AC_CHECK_HEADER(sandbox.h,AC_DEFINE(HAVE_SANDBOX_H))
410 if test $uversion -ge 110 -a $uversion -lt 120; then
411 # Broken public headers in 10.7.x...
412 AC_MSG_CHECKING(for sandbox/private.h presence)
413 if test -f /usr/local/include/sandbox/private.h; then
417 AC_MSG_ERROR(Run 'sudo mkdir -p /usr/local/include/sandbox' and 'sudo touch /usr/local/include/sandbox/private.h' to build CUPS.)
421 dnl Check for XPC support
422 AC_CHECK_HEADER(xpc/xpc.h,
424 INSTALLXPC="install-xpc")
425 AC_CHECK_HEADER(xpc/private.h,
426 AC_DEFINE(HAVE_XPC_PRIVATE_H))
430 AC_SUBST(CUPS_DEFAULT_PRINTOPERATOR_AUTH)
431 AC_DEFINE_UNQUOTED(CUPS_DEFAULT_PRINTOPERATOR_AUTH, "$CUPS_DEFAULT_PRINTOPERATOR_AUTH")
432 AC_DEFINE_UNQUOTED(CUPS_DEFAULT_SYSTEM_AUTHKEY, "$CUPS_DEFAULT_SYSTEM_AUTHKEY")
433 AC_SUBST(CUPS_SYSTEM_AUTHKEY)
436 dnl Check for build components
439 AC_ARG_WITH(components, [ --with-components set components to build:
440 - "all" (default) builds everything
441 - "core" builds libcups and ipptool],
442 COMPONENTS="$withval")
444 case "$COMPONENTS" in
446 BUILDDIRS="filter backend berkeley cgi-bin monitor notifier ppdc scheduler systemv conf data desktop locale man doc examples templates"
450 BUILDDIRS="data locale"
454 AC_MSG_ERROR([Bad build component "$COMPONENT" specified!])