2 dnl Common configuration stuff for CUPS.
4 dnl Copyright 2007-2017 by Apple Inc.
5 dnl Copyright 1997-2007 by Easy Software Products, all rights reserved.
7 dnl Licensed under Apache License v2.0. See the file "LICENSE" for more information.
10 dnl Set the name of the config header file...
11 AC_CONFIG_HEADER(config.h)
13 dnl Version number information...
14 CUPS_VERSION="AC_PACKAGE_VERSION"
16 CUPS_BUILD="cups-$CUPS_VERSION"
18 AC_ARG_WITH(cups_build, [ --with-cups-build set "cups-config --build" string ],
19 CUPS_BUILD="$withval")
21 AC_SUBST(CUPS_VERSION)
22 AC_SUBST(CUPS_REVISION)
24 AC_DEFINE_UNQUOTED(CUPS_SVERSION, "AC_PACKAGE_NAME v$CUPS_VERSION$CUPS_REVISION")
25 AC_DEFINE_UNQUOTED(CUPS_MINIMAL, "AC_PACKAGE_NAME/$CUPS_VERSION$CUPS_REVISION")
27 dnl Default compiler flags...
29 CPPFLAGS="${CPPFLAGS:=}"
30 CXXFLAGS="${CXXFLAGS:=}"
31 LDFLAGS="${LDFLAGS:=}"
33 dnl Checks for programs...
35 AC_PROG_CC(clang cc gcc)
37 AC_PROG_CXX(clang++ c++ g++)
40 AC_PATH_PROG(CHMOD,chmod)
41 AC_PATH_PROG(GZIP,gzip)
44 AC_PATH_PROG(MKDIR,mkdir)
47 AC_PATH_PROG(RMDIR,rmdir)
49 AC_PATH_PROG(XDGOPEN,xdg-open)
50 if test "x$XDGOPEN" = x; then
51 CUPS_HTMLVIEW="htmlview"
53 CUPS_HTMLVIEW="$XDGOPEN"
55 AC_SUBST(CUPS_HTMLVIEW)
57 AC_MSG_CHECKING(for install-sh script)
58 INSTALL="`pwd`/install-sh"
60 AC_MSG_RESULT(using $INSTALL)
62 if test "x$AR" = x; then
63 AC_MSG_ERROR([Unable to find required library archive command.])
65 if test "x$CC" = x; then
66 AC_MSG_ERROR([Unable to find required C compiler command.])
69 dnl Static library option...
71 AC_ARG_ENABLE(static, [ --enable-static install static libraries])
73 if test x$enable_static = xyes; then
74 echo Installing static libraries...
75 INSTALLSTATIC="installstatic"
78 AC_SUBST(INSTALLSTATIC)
80 dnl Check for pkg-config, which is used for some other tests later on...
81 AC_PATH_TOOL(PKGCONFIG, pkg-config)
83 dnl Check for libraries...
84 AC_SEARCH_LIBS(abs, m, AC_DEFINE(HAVE_ABS))
85 AC_SEARCH_LIBS(crypt, crypt)
86 AC_SEARCH_LIBS(fmod, m)
87 AC_SEARCH_LIBS(getspent, sec gen)
90 AC_ARG_ENABLE(mallinfo, [ --enable-mallinfo build with malloc debug logging])
92 if test x$enable_mallinfo = xyes; then
95 AC_SEARCH_LIBS(mallinfo, malloc, AC_DEFINE(HAVE_MALLINFO))
102 dnl Check for libpaper support...
103 AC_ARG_ENABLE(libpaper, [ --enable-libpaper build with libpaper support])
105 if test x$enable_libpaper = xyes; then
106 AC_CHECK_LIB(paper,systempapername,
107 AC_DEFINE(HAVE_LIBPAPER)
115 dnl Checks for header files.
117 AC_CHECK_HEADER(stdlib.h,AC_DEFINE(HAVE_STDLIB_H))
118 AC_CHECK_HEADER(crypt.h,AC_DEFINE(HAVE_CRYPT_H))
119 AC_CHECK_HEADER(langinfo.h,AC_DEFINE(HAVE_LANGINFO_H))
120 AC_CHECK_HEADER(malloc.h,AC_DEFINE(HAVE_MALLOC_H))
121 AC_CHECK_HEADER(shadow.h,AC_DEFINE(HAVE_SHADOW_H))
122 AC_CHECK_HEADER(stdint.h,AC_DEFINE(HAVE_STDINT_H))
123 AC_CHECK_HEADER(string.h,AC_DEFINE(HAVE_STRING_H))
124 AC_CHECK_HEADER(strings.h,AC_DEFINE(HAVE_STRINGS_H))
125 AC_CHECK_HEADER(bstring.h,AC_DEFINE(HAVE_BSTRING_H))
126 AC_CHECK_HEADER(sys/ioctl.h,AC_DEFINE(HAVE_SYS_IOCTL_H))
127 AC_CHECK_HEADER(sys/param.h,AC_DEFINE(HAVE_SYS_PARAM_H))
128 AC_CHECK_HEADER(sys/ucred.h,AC_DEFINE(HAVE_SYS_UCRED_H))
130 dnl Checks for iconv.h and iconv_open
131 AC_CHECK_HEADER(iconv.h,
134 AC_SEARCH_LIBS(iconv_open,iconv,
135 AC_DEFINE(HAVE_ICONV_H)
136 SAVELIBS="$SAVELIBS $LIBS")
137 AC_SEARCH_LIBS(libiconv_open,iconv,
138 AC_DEFINE(HAVE_ICONV_H)
139 SAVELIBS="$SAVELIBS $LIBS")
142 dnl Checks for Mini-XML (www.minixml.org)...
144 AC_CHECK_HEADER(mxml.h,
146 AC_SEARCH_LIBS(mmxlNewElement,mxml,
147 AC_DEFINE(HAVE_MXML_H)
152 dnl Checks for statfs and its many headers...
153 AC_CHECK_HEADER(sys/mount.h,AC_DEFINE(HAVE_SYS_MOUNT_H))
154 AC_CHECK_HEADER(sys/statfs.h,AC_DEFINE(HAVE_SYS_STATFS_H))
155 AC_CHECK_HEADER(sys/statvfs.h,AC_DEFINE(HAVE_SYS_STATVFS_H))
156 AC_CHECK_HEADER(sys/vfs.h,AC_DEFINE(HAVE_SYS_VFS_H))
157 AC_CHECK_FUNCS(statfs statvfs)
159 dnl Checks for string functions.
160 AC_CHECK_FUNCS(strdup strlcat strlcpy)
161 if test "$host_os_name" = "hp-ux" -a "$host_os_version" = "1020"; then
162 echo Forcing snprintf emulation for HP-UX.
164 AC_CHECK_FUNCS(snprintf vsnprintf)
167 dnl Check for random number functions...
168 AC_CHECK_FUNCS(random lrand48 arc4random)
170 dnl Check for geteuid function.
171 AC_CHECK_FUNCS(geteuid)
173 dnl Check for setpgid function.
174 AC_CHECK_FUNCS(setpgid)
176 dnl Check for vsyslog function.
177 AC_CHECK_FUNCS(vsyslog)
179 dnl Checks for signal functions.
180 case "$host_os_name" in
182 # Do not use sigset on Linux or GNU HURD
185 # Use sigset on other platforms, if available
186 AC_CHECK_FUNCS(sigset)
190 AC_CHECK_FUNCS(sigaction)
192 dnl Checks for wait functions.
193 AC_CHECK_FUNCS(waitpid wait3)
195 dnl Check for posix_spawn
196 AC_CHECK_FUNCS(posix_spawn)
198 dnl Check for getgrouplist
199 AC_CHECK_FUNCS(getgrouplist)
201 dnl See if the tm structure has the tm_gmtoff member...
202 AC_MSG_CHECKING(for tm_gmtoff member in tm structure)
203 AC_TRY_COMPILE([#include <time.h>],[struct tm t;
204 int o = t.tm_gmtoff;],
206 AC_DEFINE(HAVE_TM_GMTOFF),
209 dnl See if the stat structure has the st_gen member...
210 AC_MSG_CHECKING(for st_gen member in stat structure)
211 AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat t;
214 AC_DEFINE(HAVE_ST_GEN),
217 dnl See if we have the removefile(3) function for securely removing files
218 AC_CHECK_FUNCS(removefile)
220 dnl See if we have libusb...
221 AC_ARG_ENABLE(libusb, [ --enable-libusb use libusb for USB printing])
228 if test "x$PKGCONFIG" != x; then
229 if test x$enable_libusb != xno -a $host_os_name != darwin; then
230 AC_MSG_CHECKING(for libusb-1.0)
231 if $PKGCONFIG --exists libusb-1.0; then
233 AC_DEFINE(HAVE_LIBUSB)
234 CFLAGS="$CFLAGS `$PKGCONFIG --cflags libusb-1.0`"
235 LIBUSB="`$PKGCONFIG --libs libusb-1.0`"
236 USBQUIRKS="\$(DATADIR)/usb"
239 if test x$enable_libusb = xyes; then
240 AC_MSG_ERROR(libusb required for --enable-libusb.)
244 elif test x$enable_libusb = xyes; then
245 AC_MSG_ERROR(Need pkg-config to enable libusb support.)
248 dnl See if we have libwrap for TCP wrappers support...
249 AC_ARG_ENABLE(tcp_wrappers, [ --enable-tcp-wrappers use libwrap for TCP wrappers support])
254 if test x$enable_tcp_wrappers = xyes; then
255 AC_CHECK_LIB(wrap, hosts_access,[
256 AC_CHECK_HEADER(tcpd.h,
257 AC_DEFINE(HAVE_TCPD_H)
264 AC_CHECK_HEADER(zlib.h,
265 AC_CHECK_LIB(z, gzgets,
269 AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_INFLATECOPY))
270 if test "x$GZIP" != z; then
273 AC_SUBST(INSTALL_GZIP)
276 dnl Flags for "ar" command...
277 case $host_os_name in
288 dnl Prep libraries specifically for cupsd and backends...
294 dnl See if we have POSIX ACL support...
297 AC_ARG_ENABLE(acl, [ --enable-acl build with POSIX ACL support])
298 if test "x$enable_acl" != xno; then
299 AC_SEARCH_LIBS(acl_init, acl, AC_DEFINE(HAVE_ACL_INIT))
300 SERVERLIBS="$SERVERLIBS $LIBS"
304 dnl Check for DBUS support
305 AC_ARG_ENABLE(dbus, [ --disable-dbus build without DBUS support])
306 AC_ARG_WITH(dbusdir, [ --with-dbusdir set DBUS configuration directory ],
313 if test "x$enable_dbus" != xno -a "x$PKGCONFIG" != x -a "x$host_os_name" != xdarwin; then
314 AC_MSG_CHECKING(for DBUS)
315 if $PKGCONFIG --exists dbus-1; then
318 CFLAGS="$CFLAGS `$PKGCONFIG --cflags dbus-1` -DDBUS_API_SUBJECT_TO_CHANGE"
319 SERVERLIBS="$SERVERLIBS `$PKGCONFIG --libs dbus-1`"
321 DBUS_NOTIFIERLIBS="`$PKGCONFIG --libs dbus-1`"
323 LIBS="$LIBS $DBUS_NOTIFIERLIBS"
324 AC_CHECK_FUNC(dbus_message_iter_init_append,
325 AC_DEFINE(HAVE_DBUS_MESSAGE_ITER_INIT_APPEND))
326 AC_CHECK_FUNC(dbus_threads_init,
327 AC_DEFINE(HAVE_DBUS_THREADS_INIT))
329 if test -d /etc/dbus-1; then
330 DBUSDIR="/etc/dbus-1"
338 AC_SUBST(DBUS_NOTIFIER)
339 AC_SUBST(DBUS_NOTIFIERLIBS)
341 dnl Extra platform-specific libraries...
342 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@SYSTEM"
343 CUPS_DEFAULT_SYSTEM_AUTHKEY=""
344 CUPS_SYSTEM_AUTHKEY=""
347 case $host_os_name in
349 BACKLIBS="$BACKLIBS -framework IOKit"
350 SERVERLIBS="$SERVERLIBS -framework IOKit -weak_framework ApplicationServices"
351 LIBS="-framework SystemConfiguration -framework CoreFoundation -framework Security $LIBS"
353 dnl Check for framework headers...
354 AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h,AC_DEFINE(HAVE_APPLICATIONSERVICES_H))
355 AC_CHECK_HEADER(CoreFoundation/CoreFoundation.h,AC_DEFINE(HAVE_COREFOUNDATION_H))
356 AC_CHECK_HEADER(CoreFoundation/CFPriv.h,AC_DEFINE(HAVE_CFPRIV_H))
357 AC_CHECK_HEADER(CoreFoundation/CFBundlePriv.h,AC_DEFINE(HAVE_CFBUNDLEPRIV_H))
359 dnl Check for dynamic store function...
360 AC_CHECK_FUNCS(SCDynamicStoreCopyComputerName)
362 dnl Check for the new membership functions in MacOSX 10.4...
363 AC_CHECK_HEADER(membership.h,AC_DEFINE(HAVE_MEMBERSHIP_H))
364 AC_CHECK_HEADER(membershipPriv.h,AC_DEFINE(HAVE_MEMBERSHIPPRIV_H))
365 AC_CHECK_FUNCS(mbr_uid_to_uuid)
367 dnl Need <dlfcn.h> header...
368 AC_CHECK_HEADER(dlfcn.h,AC_DEFINE(HAVE_DLFCN_H))
370 dnl Check for notify_post support
371 AC_CHECK_HEADER(notify.h,AC_DEFINE(HAVE_NOTIFY_H))
372 AC_CHECK_FUNCS(notify_post)
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")
382 AC_CHECK_HEADER(Security/Authorization.h, [
383 AC_DEFINE(HAVE_AUTHORIZATION_H)
385 if test "x$default_adminkey" != xdefault; then
386 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey $default_adminkey"
387 CUPS_DEFAULT_SYSTEM_AUTHKEY="$default_adminkey"
389 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.print.admin"
390 CUPS_DEFAULT_SYSTEM_AUTHKEY="system.print.admin"
393 if test "x$default_operkey" != xdefault; then
394 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY($default_operkey) @admin @lpadmin"
396 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.operator) @admin @lpadmin"
398 AC_CHECK_HEADER(Security/SecBasePriv.h,AC_DEFINE(HAVE_SECBASEPRIV_H))
400 dnl Check for sandbox/Seatbelt support
401 if test $host_os_version -ge 100; then
402 AC_CHECK_HEADER(sandbox.h,AC_DEFINE(HAVE_SANDBOX_H))
404 if test $host_os_version -ge 110 -a $host_os_version -lt 120; then
405 # Broken public headers in 10.7.x...
406 AC_MSG_CHECKING(for sandbox/private.h presence)
407 if test -f /usr/local/include/sandbox/private.h; then
411 AC_MSG_ERROR(Run 'sudo mkdir -p /usr/local/include/sandbox' and 'sudo touch /usr/local/include/sandbox/private.h' to build CUPS.)
415 dnl Check for XPC support
416 AC_CHECK_HEADER(xpc/xpc.h,
418 INSTALLXPC="install-xpc")
419 AC_CHECK_HEADER(xpc/private.h,
420 AC_DEFINE(HAVE_XPC_PRIVATE_H))
424 AC_SUBST(CUPS_DEFAULT_PRINTOPERATOR_AUTH)
425 AC_DEFINE_UNQUOTED(CUPS_DEFAULT_PRINTOPERATOR_AUTH, "$CUPS_DEFAULT_PRINTOPERATOR_AUTH")
426 AC_DEFINE_UNQUOTED(CUPS_DEFAULT_SYSTEM_AUTHKEY, "$CUPS_DEFAULT_SYSTEM_AUTHKEY")
427 AC_SUBST(CUPS_SYSTEM_AUTHKEY)
430 dnl Check for build components
433 AC_ARG_WITH(components, [ --with-components set components to build:
434 - "all" (default) builds everything
435 - "core" builds libcups and ipptool],
436 COMPONENTS="$withval")
438 case "$COMPONENTS" in
440 BUILDDIRS="filter backend berkeley cgi-bin monitor notifier ppdc scheduler systemv conf data desktop locale man doc examples templates"
444 BUILDDIRS="data locale"
448 AC_MSG_ERROR([Bad build component "$COMPONENT" specified!])