2 dnl Common configuration stuff for CUPS.
4 dnl Copyright © 2007-2019 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
11 dnl Set the name of the config header file...
12 AC_CONFIG_HEADER(config.h)
14 dnl Version number information...
15 CUPS_VERSION="AC_PACKAGE_VERSION"
17 CUPS_BUILD="cups-$CUPS_VERSION"
19 AC_ARG_WITH(cups_build, [ --with-cups-build set "cups-config --build" string ],
20 CUPS_BUILD="$withval")
22 AC_SUBST(CUPS_VERSION)
23 AC_SUBST(CUPS_REVISION)
25 AC_DEFINE_UNQUOTED(CUPS_SVERSION, "AC_PACKAGE_NAME v$CUPS_VERSION$CUPS_REVISION")
26 AC_DEFINE_UNQUOTED(CUPS_MINIMAL, "AC_PACKAGE_NAME/$CUPS_VERSION$CUPS_REVISION")
28 dnl Default compiler flags...
30 CPPFLAGS="${CPPFLAGS:=}"
31 CXXFLAGS="${CXXFLAGS:=}"
32 LDFLAGS="${LDFLAGS:=}"
34 dnl Checks for programs...
36 AC_PROG_CC(clang cc gcc)
38 AC_PROG_CXX(clang++ c++ g++)
41 AC_PATH_PROG(CHMOD,chmod)
42 AC_PATH_PROG(GZIPPROG,gzip)
43 AC_MSG_CHECKING(for install-sh script)
44 INSTALL="`pwd`/install-sh"
46 AC_MSG_RESULT(using $INSTALL)
49 AC_PATH_PROG(MKDIR,mkdir)
52 AC_PATH_PROG(RMDIR,rmdir)
54 AC_PATH_PROG(XDGOPEN,xdg-open)
56 if test "x$XDGOPEN" = x; then
57 CUPS_HTMLVIEW="htmlview"
59 CUPS_HTMLVIEW="$XDGOPEN"
61 AC_SUBST(CUPS_HTMLVIEW)
63 if test "x$AR" = x; then
64 AC_MSG_ERROR([Unable to find required library archive command.])
66 if test "x$CC" = x; then
67 AC_MSG_ERROR([Unable to find required C compiler command.])
70 dnl Static library option...
72 AC_ARG_ENABLE(static, [ --enable-static install static libraries])
74 if test x$enable_static = xyes; then
75 echo Installing static libraries...
76 INSTALLSTATIC="installstatic"
79 AC_SUBST(INSTALLSTATIC)
81 dnl Check for pkg-config, which is used for some other tests later on...
82 AC_PATH_TOOL(PKGCONFIG, pkg-config)
84 dnl Check for libraries...
85 AC_SEARCH_LIBS(abs, m, AC_DEFINE(HAVE_ABS))
86 AC_SEARCH_LIBS(crypt, crypt)
87 AC_SEARCH_LIBS(fmod, m)
88 AC_SEARCH_LIBS(getspent, sec gen)
91 AC_ARG_ENABLE(mallinfo, [ --enable-mallinfo build with malloc debug logging])
93 if test x$enable_mallinfo = xyes; then
96 AC_SEARCH_LIBS(mallinfo, malloc, AC_DEFINE(HAVE_MALLINFO))
103 dnl Check for libpaper support...
104 AC_ARG_ENABLE(libpaper, [ --enable-libpaper build with libpaper support])
106 if test x$enable_libpaper = xyes; then
107 AC_CHECK_LIB(paper,systempapername,
108 AC_DEFINE(HAVE_LIBPAPER)
116 dnl Checks for header files.
118 AC_CHECK_HEADER(stdlib.h,AC_DEFINE(HAVE_STDLIB_H))
119 AC_CHECK_HEADER(crypt.h,AC_DEFINE(HAVE_CRYPT_H))
120 AC_CHECK_HEADER(langinfo.h,AC_DEFINE(HAVE_LANGINFO_H))
121 AC_CHECK_HEADER(malloc.h,AC_DEFINE(HAVE_MALLOC_H))
122 AC_CHECK_HEADER(shadow.h,AC_DEFINE(HAVE_SHADOW_H))
123 AC_CHECK_HEADER(stdint.h,AC_DEFINE(HAVE_STDINT_H))
124 AC_CHECK_HEADER(string.h,AC_DEFINE(HAVE_STRING_H))
125 AC_CHECK_HEADER(strings.h,AC_DEFINE(HAVE_STRINGS_H))
126 AC_CHECK_HEADER(bstring.h,AC_DEFINE(HAVE_BSTRING_H))
127 AC_CHECK_HEADER(sys/ioctl.h,AC_DEFINE(HAVE_SYS_IOCTL_H))
128 AC_CHECK_HEADER(sys/param.h,AC_DEFINE(HAVE_SYS_PARAM_H))
129 AC_CHECK_HEADER(sys/ucred.h,AC_DEFINE(HAVE_SYS_UCRED_H))
131 dnl Checks for iconv.h and iconv_open
132 AC_CHECK_HEADER(iconv.h,
135 AC_SEARCH_LIBS(iconv_open,iconv,
136 AC_DEFINE(HAVE_ICONV_H)
137 SAVELIBS="$SAVELIBS $LIBS")
138 AC_SEARCH_LIBS(libiconv_open,iconv,
139 AC_DEFINE(HAVE_ICONV_H)
140 SAVELIBS="$SAVELIBS $LIBS")
143 dnl Checks for statfs and its many headers...
144 AC_CHECK_HEADER(sys/mount.h,AC_DEFINE(HAVE_SYS_MOUNT_H))
145 AC_CHECK_HEADER(sys/statfs.h,AC_DEFINE(HAVE_SYS_STATFS_H))
146 AC_CHECK_HEADER(sys/statvfs.h,AC_DEFINE(HAVE_SYS_STATVFS_H))
147 AC_CHECK_HEADER(sys/vfs.h,AC_DEFINE(HAVE_SYS_VFS_H))
148 AC_CHECK_FUNCS(statfs statvfs)
150 dnl Checks for string functions.
151 AC_CHECK_FUNCS(strdup strlcat strlcpy)
152 if test "$host_os_name" = "hp-ux" -a "$host_os_version" = "1020"; then
153 echo Forcing snprintf emulation for HP-UX.
155 AC_CHECK_FUNCS(snprintf vsnprintf)
158 dnl Check for random number functions...
159 AC_CHECK_FUNCS(random lrand48 arc4random)
161 dnl Check for geteuid function.
162 AC_CHECK_FUNCS(geteuid)
164 dnl Check for setpgid function.
165 AC_CHECK_FUNCS(setpgid)
167 dnl Check for vsyslog function.
168 AC_CHECK_FUNCS(vsyslog)
170 dnl Checks for signal functions.
171 case "$host_os_name" in
173 # Do not use sigset on Linux or GNU HURD
176 # Use sigset on other platforms, if available
177 AC_CHECK_FUNCS(sigset)
181 AC_CHECK_FUNCS(sigaction)
183 dnl Checks for wait functions.
184 AC_CHECK_FUNCS(waitpid wait3)
186 dnl Check for posix_spawn
187 AC_CHECK_FUNCS(posix_spawn)
189 dnl Check for getgrouplist
190 AC_CHECK_FUNCS(getgrouplist)
192 dnl See if the tm structure has the tm_gmtoff member...
193 AC_MSG_CHECKING(for tm_gmtoff member in tm structure)
194 AC_TRY_COMPILE([#include <time.h>],[struct tm t;
195 int o = t.tm_gmtoff;],
197 AC_DEFINE(HAVE_TM_GMTOFF),
200 dnl See if the stat structure has the st_gen member...
201 AC_MSG_CHECKING(for st_gen member in stat structure)
202 AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat t;
205 AC_DEFINE(HAVE_ST_GEN),
208 dnl See if we have the removefile(3) function for securely removing files
209 AC_CHECK_FUNCS(removefile)
211 dnl See if we have libusb...
212 AC_ARG_ENABLE(libusb, [ --enable-libusb use libusb for USB printing])
219 if test "x$PKGCONFIG" != x; then
220 if test x$enable_libusb != xno -a $host_os_name != darwin; then
221 AC_MSG_CHECKING(for libusb-1.0)
222 if $PKGCONFIG --exists libusb-1.0; then
224 AC_DEFINE(HAVE_LIBUSB)
225 CFLAGS="$CFLAGS `$PKGCONFIG --cflags libusb-1.0`"
226 LIBUSB="`$PKGCONFIG --libs libusb-1.0`"
227 USBQUIRKS="\$(DATADIR)/usb"
230 if test x$enable_libusb = xyes; then
231 AC_MSG_ERROR(libusb required for --enable-libusb.)
235 elif test x$enable_libusb = xyes; then
236 AC_MSG_ERROR(Need pkg-config to enable libusb support.)
239 dnl See if we have libwrap for TCP wrappers support...
240 AC_ARG_ENABLE(tcp_wrappers, [ --enable-tcp-wrappers use libwrap for TCP wrappers support])
245 if test x$enable_tcp_wrappers = xyes; then
246 AC_CHECK_LIB(wrap, hosts_access,[
247 AC_CHECK_HEADER(tcpd.h,
248 AC_DEFINE(HAVE_TCPD_H)
255 AC_CHECK_HEADER(zlib.h,
256 AC_CHECK_LIB(z, gzgets,[
260 AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_INFLATECOPY))
261 if test "x$GZIPPROG" != x; then
264 AC_SUBST(INSTALL_GZIP)
267 dnl Flags for "ar" command...
268 case $host_os_name in
279 dnl Prep libraries specifically for cupsd and backends...
285 dnl See if we have POSIX ACL support...
288 AC_ARG_ENABLE(acl, [ --enable-acl build with POSIX ACL support])
289 if test "x$enable_acl" != xno; then
290 AC_SEARCH_LIBS(acl_init, acl, AC_DEFINE(HAVE_ACL_INIT))
291 SERVERLIBS="$SERVERLIBS $LIBS"
295 dnl Check for DBUS support
300 AC_ARG_ENABLE(dbus, [ --disable-dbus build without DBUS support])
301 AC_ARG_WITH(dbusdir, [ --with-dbusdir set DBUS configuration directory ],
304 if test "x$enable_dbus" != xno -a "x$PKGCONFIG" != x -a "x$host_os_name" != xdarwin; then
305 AC_MSG_CHECKING(for DBUS)
306 if $PKGCONFIG --exists dbus-1; then
309 CFLAGS="$CFLAGS `$PKGCONFIG --cflags dbus-1` -DDBUS_API_SUBJECT_TO_CHANGE"
310 SERVERLIBS="$SERVERLIBS `$PKGCONFIG --libs dbus-1`"
312 DBUS_NOTIFIERLIBS="`$PKGCONFIG --libs dbus-1`"
314 LIBS="$LIBS $DBUS_NOTIFIERLIBS"
315 AC_CHECK_FUNC(dbus_message_iter_init_append,
316 AC_DEFINE(HAVE_DBUS_MESSAGE_ITER_INIT_APPEND))
317 AC_CHECK_FUNC(dbus_threads_init,
318 AC_DEFINE(HAVE_DBUS_THREADS_INIT))
320 if test -d /etc/dbus-1; then
321 DBUSDIR="/etc/dbus-1"
329 AC_SUBST(DBUS_NOTIFIER)
330 AC_SUBST(DBUS_NOTIFIERLIBS)
332 dnl Extra platform-specific libraries...
333 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@SYSTEM"
334 CUPS_DEFAULT_SYSTEM_AUTHKEY=""
335 CUPS_SYSTEM_AUTHKEY=""
338 case $host_os_name in
340 BACKLIBS="$BACKLIBS -framework IOKit"
341 SERVERLIBS="$SERVERLIBS -framework IOKit -weak_framework ApplicationServices"
342 LIBS="-framework CoreFoundation -framework Security $LIBS"
344 dnl Check for framework headers...
345 AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h,AC_DEFINE(HAVE_APPLICATIONSERVICES_H))
346 AC_CHECK_HEADER(CoreFoundation/CoreFoundation.h,AC_DEFINE(HAVE_COREFOUNDATION_H))
348 dnl Check for dynamic store function...
350 LIBS="-framework SystemConfiguration $LIBS"
351 AC_CHECK_FUNCS(SCDynamicStoreCopyComputerName,[
352 AC_DEFINE(HAVE_SCDYNAMICSTORECOPYCOMPUTERNAME)],[
355 dnl Check for the new membership functions in MacOSX 10.4...
356 AC_CHECK_HEADER(membership.h,AC_DEFINE(HAVE_MEMBERSHIP_H))
357 AC_CHECK_FUNCS(mbr_uid_to_uuid)
359 dnl Need <dlfcn.h> header...
360 AC_CHECK_HEADER(dlfcn.h,AC_DEFINE(HAVE_DLFCN_H))
362 dnl Check for notify_post support
363 AC_CHECK_HEADER(notify.h,AC_DEFINE(HAVE_NOTIFY_H))
364 AC_CHECK_FUNCS(notify_post)
366 dnl Check for Authorization Services support
367 AC_ARG_WITH(adminkey, [ --with-adminkey set the default SystemAuthKey value],
368 default_adminkey="$withval",
369 default_adminkey="default")
370 AC_ARG_WITH(operkey, [ --with-operkey set the default operator @AUTHKEY value],
371 default_operkey="$withval",
372 default_operkey="default")
374 AC_CHECK_HEADER(Security/Authorization.h, [
375 AC_DEFINE(HAVE_AUTHORIZATION_H)
377 if test "x$default_adminkey" != xdefault; then
378 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey $default_adminkey"
379 CUPS_DEFAULT_SYSTEM_AUTHKEY="$default_adminkey"
381 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.print.admin"
382 CUPS_DEFAULT_SYSTEM_AUTHKEY="system.print.admin"
385 if test "x$default_operkey" != xdefault; then
386 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY($default_operkey) @admin @lpadmin"
388 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.operator) @admin @lpadmin"
391 dnl Check for sandbox/Seatbelt support
392 if test $host_os_version -ge 100; then
393 AC_CHECK_HEADER(sandbox.h,AC_DEFINE(HAVE_SANDBOX_H))
395 if test $host_os_version -ge 110 -a $host_os_version -lt 120; then
396 # Broken public headers in 10.7.x...
397 AC_MSG_CHECKING(for sandbox/private.h presence)
398 if test -f /usr/local/include/sandbox/private.h; then
402 AC_MSG_ERROR(Run 'sudo mkdir -p /usr/local/include/sandbox' and 'sudo touch /usr/local/include/sandbox/private.h' to build CUPS.)
406 dnl Check for XPC support
407 AC_CHECK_HEADER(xpc/xpc.h,
409 INSTALLXPC="install-xpc")
413 AC_SUBST(CUPS_DEFAULT_PRINTOPERATOR_AUTH)
414 AC_DEFINE_UNQUOTED(CUPS_DEFAULT_PRINTOPERATOR_AUTH, "$CUPS_DEFAULT_PRINTOPERATOR_AUTH")
415 AC_DEFINE_UNQUOTED(CUPS_DEFAULT_SYSTEM_AUTHKEY, "$CUPS_DEFAULT_SYSTEM_AUTHKEY")
416 AC_SUBST(CUPS_SYSTEM_AUTHKEY)
419 dnl Check for build components
422 AC_ARG_WITH(components, [ --with-components set components to build:
423 - "all" (default) builds everything
424 - "core" builds libcups and ipptool
425 - "libcups" builds just libcups
426 - "libcupslite" builds just libcups without driver support],
427 COMPONENTS="$withval")
429 cupsimagebase="cupsimage"
430 IPPEVECOMMANDS="ippevepcl ippeveps"
431 LIBCUPSOBJS="\$(COREOBJS) \$(DRIVEROBJS)"
432 LIBHEADERS="\$(COREHEADERS) \$(DRIVERHEADERS)"
433 LIBHEADERSPRIV="\$(COREHEADERSPRIV) \$(DRIVERHEADERSPRIV)"
435 case "$COMPONENTS" in
437 BUILDDIRS="tools filter backend berkeley cgi-bin monitor notifier ppdc scheduler systemv conf data desktop locale man doc examples templates"
441 BUILDDIRS="tools examples locale"
446 BUILDDIRS="tools examples locale"
448 LIBCUPSOBJS="\$(COREOBJS)"
449 LIBHEADERS="\$(COREHEADERS)"
450 LIBHEADERSPRIV="\$(COREHEADERSPRIV)"
462 LIBCUPSOBJS="\$(COREOBJS)"
463 LIBHEADERS="\$(COREHEADERS)"
464 LIBHEADERSPRIV="\$(COREHEADERSPRIV)"
468 AC_MSG_ERROR([Bad build component "$COMPONENT" specified!])
473 AC_SUBST(IPPEVECOMMANDS)
474 AC_SUBST(LIBCUPSOBJS)
476 AC_SUBST(LIBHEADERSPRIV)