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))
133 dnl Checks for iconv.h and iconv_open
134 AC_CHECK_HEADER(iconv.h,
137 AC_SEARCH_LIBS(iconv_open,iconv,
138 AC_DEFINE(HAVE_ICONV_H)
139 SAVELIBS="$SAVELIBS $LIBS")
140 AC_SEARCH_LIBS(libiconv_open,iconv,
141 AC_DEFINE(HAVE_ICONV_H)
142 SAVELIBS="$SAVELIBS $LIBS")
145 dnl Checks for Mini-XML (www.minixml.org)...
147 AC_CHECK_HEADER(mxml.h,
149 AC_SEARCH_LIBS(mmxlNewElement,mxml,
150 AC_DEFINE(HAVE_MXML_H)
155 dnl Checks for statfs and its many headers...
156 AC_CHECK_HEADER(sys/mount.h,AC_DEFINE(HAVE_SYS_MOUNT_H))
157 AC_CHECK_HEADER(sys/statfs.h,AC_DEFINE(HAVE_SYS_STATFS_H))
158 AC_CHECK_HEADER(sys/statvfs.h,AC_DEFINE(HAVE_SYS_STATVFS_H))
159 AC_CHECK_HEADER(sys/vfs.h,AC_DEFINE(HAVE_SYS_VFS_H))
160 AC_CHECK_FUNCS(statfs statvfs)
162 dnl Checks for string functions.
163 AC_CHECK_FUNCS(strdup strlcat strlcpy)
164 if test "$uname" = "HP-UX" -a "$uversion" = "1020"; then
165 echo Forcing snprintf emulation for HP-UX.
167 AC_CHECK_FUNCS(snprintf vsnprintf)
170 dnl Check for random number functions...
171 AC_CHECK_FUNCS(random lrand48 arc4random)
173 dnl Check for geteuid function.
174 AC_CHECK_FUNCS(geteuid)
176 dnl Check for setpgid function.
177 AC_CHECK_FUNCS(setpgid)
179 dnl Check for vsyslog function.
180 AC_CHECK_FUNCS(vsyslog)
182 dnl Checks for signal functions.
185 # Do not use sigset on Linux or GNU HURD
188 # Use sigset on other platforms, if available
189 AC_CHECK_FUNCS(sigset)
193 AC_CHECK_FUNCS(sigaction)
195 dnl Checks for wait functions.
196 AC_CHECK_FUNCS(waitpid wait3)
198 dnl Check for posix_spawn
199 AC_CHECK_FUNCS(posix_spawn)
201 dnl Check for getgrouplist
202 AC_CHECK_FUNCS(getgrouplist)
204 dnl See if the tm structure has the tm_gmtoff member...
205 AC_MSG_CHECKING(for tm_gmtoff member in tm structure)
206 AC_TRY_COMPILE([#include <time.h>],[struct tm t;
207 int o = t.tm_gmtoff;],
209 AC_DEFINE(HAVE_TM_GMTOFF),
212 dnl See if the stat structure has the st_gen member...
213 AC_MSG_CHECKING(for st_gen member in stat structure)
214 AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat t;
217 AC_DEFINE(HAVE_ST_GEN),
220 dnl See if we have the removefile(3) function for securely removing files
221 AC_CHECK_FUNCS(removefile)
223 dnl See if we have libusb...
224 AC_ARG_ENABLE(libusb, [ --enable-libusb use libusb for USB printing])
231 if test "x$PKGCONFIG" != x; then
232 if test x$enable_libusb != xno -a $uname != Darwin; then
233 AC_MSG_CHECKING(for libusb-1.0)
234 if $PKGCONFIG --exists libusb-1.0; then
236 AC_DEFINE(HAVE_LIBUSB)
237 CFLAGS="$CFLAGS `$PKGCONFIG --cflags libusb-1.0`"
238 LIBUSB="`$PKGCONFIG --libs libusb-1.0`"
239 USBQUIRKS="\$(DATADIR)/usb"
242 if test x$enable_libusb = xyes; then
243 AC_MSG_ERROR(libusb required for --enable-libusb.)
247 elif test x$enable_libusb = xyes; then
248 AC_MSG_ERROR(Need pkg-config to enable libusb support.)
251 dnl See if we have libwrap for TCP wrappers support...
252 AC_ARG_ENABLE(tcp_wrappers, [ --enable-tcp-wrappers use libwrap for TCP wrappers support])
257 if test x$enable_tcp_wrappers = xyes; then
258 AC_CHECK_LIB(wrap, hosts_access,[
259 AC_CHECK_HEADER(tcpd.h,
260 AC_DEFINE(HAVE_TCPD_H)
267 AC_CHECK_HEADER(zlib.h,
268 AC_CHECK_LIB(z, gzgets,
272 AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_INFLATECOPY))
273 if test "x$GZIP" != z; then
276 AC_SUBST(INSTALL_GZIP)
279 dnl Flags for "ar" command...
291 dnl Prep libraries specifically for cupsd and backends...
297 dnl See if we have POSIX ACL support...
300 AC_ARG_ENABLE(acl, [ --enable-acl build with POSIX ACL support])
301 if test "x$enable_acl" != xno; then
302 AC_SEARCH_LIBS(acl_init, acl, AC_DEFINE(HAVE_ACL_INIT))
303 SERVERLIBS="$SERVERLIBS $LIBS"
307 dnl Check for DBUS support
308 AC_ARG_ENABLE(dbus, [ --disable-dbus build without DBUS support])
309 AC_ARG_WITH(dbusdir, [ --with-dbusdir set DBUS configuration directory ],
316 if test "x$enable_dbus" != xno -a "x$PKGCONFIG" != x -a "x$uname" != xDarwin; then
317 AC_MSG_CHECKING(for DBUS)
318 if $PKGCONFIG --exists dbus-1; then
321 CFLAGS="$CFLAGS `$PKGCONFIG --cflags dbus-1` -DDBUS_API_SUBJECT_TO_CHANGE"
322 SERVERLIBS="$SERVERLIBS `$PKGCONFIG --libs dbus-1`"
324 DBUS_NOTIFIERLIBS="`$PKGCONFIG --libs dbus-1`"
326 LIBS="$LIBS $DBUS_NOTIFIERLIBS"
327 AC_CHECK_FUNC(dbus_message_iter_init_append,
328 AC_DEFINE(HAVE_DBUS_MESSAGE_ITER_INIT_APPEND))
329 AC_CHECK_FUNC(dbus_threads_init,
330 AC_DEFINE(HAVE_DBUS_THREADS_INIT))
332 if test -d /etc/dbus-1; then
333 DBUSDIR="/etc/dbus-1"
341 AC_SUBST(DBUS_NOTIFIER)
342 AC_SUBST(DBUS_NOTIFIERLIBS)
344 dnl Extra platform-specific libraries...
345 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@SYSTEM"
346 CUPS_DEFAULT_SYSTEM_AUTHKEY=""
347 CUPS_SYSTEM_AUTHKEY=""
352 BACKLIBS="$BACKLIBS -framework IOKit"
353 SERVERLIBS="$SERVERLIBS -framework IOKit -weak_framework ApplicationServices"
354 LIBS="-framework SystemConfiguration -framework CoreFoundation -framework Security $LIBS"
356 dnl Check for framework headers...
357 AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h,AC_DEFINE(HAVE_APPLICATIONSERVICES_H))
358 AC_CHECK_HEADER(CoreFoundation/CoreFoundation.h,AC_DEFINE(HAVE_COREFOUNDATION_H))
359 AC_CHECK_HEADER(CoreFoundation/CFPriv.h,AC_DEFINE(HAVE_CFPRIV_H))
360 AC_CHECK_HEADER(CoreFoundation/CFBundlePriv.h,AC_DEFINE(HAVE_CFBUNDLEPRIV_H))
362 dnl Check for dynamic store function...
363 AC_CHECK_FUNCS(SCDynamicStoreCopyComputerName)
365 dnl Check for the new membership functions in MacOSX 10.4...
366 AC_CHECK_HEADER(membership.h,AC_DEFINE(HAVE_MEMBERSHIP_H))
367 AC_CHECK_HEADER(membershipPriv.h,AC_DEFINE(HAVE_MEMBERSHIPPRIV_H))
368 AC_CHECK_FUNCS(mbr_uid_to_uuid)
370 dnl Need <dlfcn.h> header...
371 AC_CHECK_HEADER(dlfcn.h,AC_DEFINE(HAVE_DLFCN_H))
373 dnl Check for notify_post support
374 AC_CHECK_HEADER(notify.h,AC_DEFINE(HAVE_NOTIFY_H))
375 AC_CHECK_FUNCS(notify_post)
377 dnl Check for Authorization Services support
378 AC_ARG_WITH(adminkey, [ --with-adminkey set the default SystemAuthKey value],
379 default_adminkey="$withval",
380 default_adminkey="default")
381 AC_ARG_WITH(operkey, [ --with-operkey set the default operator @AUTHKEY value],
382 default_operkey="$withval",
383 default_operkey="default")
385 AC_CHECK_HEADER(Security/Authorization.h, [
386 AC_DEFINE(HAVE_AUTHORIZATION_H)
388 if test "x$default_adminkey" != xdefault; then
389 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey $default_adminkey"
390 CUPS_DEFAULT_SYSTEM_AUTHKEY="$default_adminkey"
391 elif grep -q system.print.operator /etc/authorization; then
392 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.print.admin"
393 CUPS_DEFAULT_SYSTEM_AUTHKEY="system.print.admin"
395 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.preferences"
396 CUPS_DEFAULT_SYSTEM_AUTHKEY="system.preferences"
399 if test "x$default_operkey" != xdefault; then
400 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY($default_operkey) @admin @lpadmin"
401 elif grep -q system.print.operator /etc/authorization; then
402 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.operator) @admin @lpadmin"
404 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.admin) @admin @lpadmin"
406 AC_CHECK_HEADER(Security/SecBasePriv.h,AC_DEFINE(HAVE_SECBASEPRIV_H))
408 dnl Check for sandbox/Seatbelt support
409 if test $uversion -ge 100; then
410 AC_CHECK_HEADER(sandbox.h,AC_DEFINE(HAVE_SANDBOX_H))
412 if test $uversion -ge 110 -a $uversion -lt 120; then
413 # Broken public headers in 10.7.x...
414 AC_MSG_CHECKING(for sandbox/private.h presence)
415 if test -f /usr/local/include/sandbox/private.h; then
419 AC_MSG_ERROR(Run 'sudo mkdir -p /usr/local/include/sandbox' and 'sudo touch /usr/local/include/sandbox/private.h' to build CUPS.)
423 dnl Check for XPC support
424 AC_CHECK_HEADER(xpc/xpc.h,
426 INSTALLXPC="install-xpc")
427 AC_CHECK_HEADER(xpc/private.h,
428 AC_DEFINE(HAVE_XPC_PRIVATE_H))
432 AC_SUBST(CUPS_DEFAULT_PRINTOPERATOR_AUTH)
433 AC_DEFINE_UNQUOTED(CUPS_DEFAULT_PRINTOPERATOR_AUTH, "$CUPS_DEFAULT_PRINTOPERATOR_AUTH")
434 AC_DEFINE_UNQUOTED(CUPS_DEFAULT_SYSTEM_AUTHKEY, "$CUPS_DEFAULT_SYSTEM_AUTHKEY")
435 AC_SUBST(CUPS_SYSTEM_AUTHKEY)
438 dnl Check for build components
441 AC_ARG_WITH(components, [ --with-components set components to build:
442 - "all" (default) builds everything
443 - "core" builds libcups and ipptool],
444 COMPONENTS="$withval")
446 case "$COMPONENTS" in
448 BUILDDIRS="filter backend berkeley cgi-bin monitor notifier ppdc scheduler systemv conf data desktop locale man doc examples templates"
452 BUILDDIRS="data locale"
456 AC_MSG_ERROR([Bad build component "$COMPONENT" specified!])