2 dnl "$Id: cups-common.m4 8781 2009-08-28 17:34:54Z mike $"
4 dnl Common configuration stuff for CUPS.
6 dnl Copyright 2007-2012 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...
52 AC_PATH_PROG(CHMOD,chmod)
53 AC_PATH_PROG(GZIP,gzip)
54 AC_PATH_PROG(HTMLDOC,htmldoc)
59 AC_PATH_PROG(RMDIR,rmdir)
61 AC_PATH_PROG(XDGOPEN,xdg-open)
62 if test "x$XDGOPEN" = x; then
63 CUPS_HTMLVIEW="htmlview"
65 CUPS_HTMLVIEW="$XDGOPEN"
67 AC_SUBST(CUPS_HTMLVIEW)
69 AC_MSG_CHECKING(for install-sh script)
70 INSTALL="`pwd`/install-sh"
72 AC_MSG_RESULT(using $INSTALL)
74 if test "x$AR" = x; then
75 AC_MSG_ERROR([Unable to find required library archive command.])
77 if test "x$CC" = x; then
78 AC_MSG_ERROR([Unable to find required C compiler command.])
81 dnl Static library option...
83 AC_ARG_ENABLE(static, [ --enable-static install static libraries])
85 if test x$enable_static = xyes; then
86 echo Installing static libraries...
87 INSTALLSTATIC="installstatic"
90 AC_SUBST(INSTALLSTATIC)
92 dnl Check for pkg-config, which is used for some other tests later on...
93 AC_PATH_PROG(PKGCONFIG, pkg-config)
95 dnl Check for libraries...
96 AC_SEARCH_LIBS(fmod, m)
97 AC_SEARCH_LIBS(crypt, crypt)
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(string.h,AC_DEFINE(HAVE_STRING_H))
134 AC_CHECK_HEADER(strings.h,AC_DEFINE(HAVE_STRINGS_H))
135 AC_CHECK_HEADER(bstring.h,AC_DEFINE(HAVE_BSTRING_H))
136 AC_CHECK_HEADER(usersec.h,AC_DEFINE(HAVE_USERSEC_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(scsi/sg.h,AC_DEFINE(HAVE_SCSI_SG_H))
142 dnl Checks for iconv.h and iconv_open
143 AC_CHECK_HEADER(iconv.h,
146 AC_SEARCH_LIBS(iconv_open,iconv,
147 AC_DEFINE(HAVE_ICONV_H)
148 SAVELIBS="$SAVELIBS $LIBS")
151 dnl Checks for Mini-XML (www.minixml.org)...
153 AC_CHECK_HEADER(mxml.h,
155 AC_SEARCH_LIBS(mmxlNewElement,mxml,
156 AC_DEFINE(HAVE_MXML_H)
161 dnl Checks for statfs and its many headers...
162 AC_CHECK_HEADER(sys/mount.h,AC_DEFINE(HAVE_SYS_MOUNT_H))
163 AC_CHECK_HEADER(sys/statfs.h,AC_DEFINE(HAVE_SYS_STATFS_H))
164 AC_CHECK_HEADER(sys/statvfs.h,AC_DEFINE(HAVE_SYS_STATVFS_H))
165 AC_CHECK_HEADER(sys/vfs.h,AC_DEFINE(HAVE_SYS_VFS_H))
166 AC_CHECK_FUNCS(statfs statvfs)
168 dnl Checks for string functions.
169 AC_CHECK_FUNCS(strdup strlcat strlcpy)
170 if test "$uname" = "HP-UX" -a "$uversion" = "1020"; then
171 echo Forcing snprintf emulation for HP-UX.
173 AC_CHECK_FUNCS(snprintf vsnprintf)
176 dnl Check for random number functions...
177 AC_CHECK_FUNCS(random lrand48 arc4random)
179 dnl Check for geteuid function.
180 AC_CHECK_FUNCS(geteuid)
182 dnl Check for setpgid function.
183 AC_CHECK_FUNCS(setpgid)
185 dnl Check for vsyslog function.
186 AC_CHECK_FUNCS(vsyslog)
188 dnl Checks for signal functions.
191 # Do not use sigset on Linux or GNU HURD
194 # Use sigset on other platforms, if available
195 AC_CHECK_FUNCS(sigset)
199 AC_CHECK_FUNCS(sigaction)
201 dnl Checks for wait functions.
202 AC_CHECK_FUNCS(waitpid wait3)
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])
229 if test "x$PKGCONFIG" != x; then
230 if test x$enable_libusb = xyes -o $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`"
241 elif test x$enable_libusb = xyes; then
242 AC_MSG_ERROR(Need pkg-config to enable libusb support.)
245 dnl See if we have libwrap for TCP wrappers support...
246 AC_ARG_ENABLE(tcp_wrappers, [ --enable-tcp-wrappers use libwrap for TCP wrappers support])
251 if test x$enable_tcp_wrappers = xyes; then
252 AC_CHECK_LIB(wrap, hosts_access,[
253 AC_CHECK_HEADER(tcpd.h,
254 AC_DEFINE(HAVE_TCPD_H)
261 AC_CHECK_HEADER(zlib.h,
262 AC_CHECK_LIB(z, gzgets,
266 if test "x$GZIP" != z; then
269 AC_SUBST(INSTALL_GZIP)
272 dnl Flags for "ar" command...
284 dnl Prep libraries specifically for cupsd and backends...
290 dnl See if we have POSIX ACL support...
293 AC_ARG_ENABLE(acl, [ --enable-acl build with POSIX ACL support])
294 if test "x$enable_acl" != xno; then
295 AC_SEARCH_LIBS(acl_init, acl, AC_DEFINE(HAVE_ACL_INIT))
296 SERVERLIBS="$SERVERLIBS $LIBS"
300 dnl Check for DBUS support
301 if test -d /etc/dbus-1; then
302 DBUSDIR="/etc/dbus-1"
307 AC_ARG_ENABLE(dbus, [ --enable-dbus build with DBUS support])
308 AC_ARG_WITH(dbusdir, [ --with-dbusdir set DBUS configuration directory ],
314 if test "x$enable_dbus" != xno -a "x$PKGCONFIG" != x; 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))
334 AC_SUBST(DBUS_NOTIFIER)
335 AC_SUBST(DBUS_NOTIFIERLIBS)
337 dnl Extra platform-specific libraries...
338 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@SYSTEM"
339 CUPS_SYSTEM_AUTHKEY=""
344 BACKLIBS="$BACKLIBS -framework IOKit"
345 SERVERLIBS="$SERVERLIBS -framework IOKit -weak_framework ApplicationServices"
346 LIBS="-framework SystemConfiguration -framework CoreFoundation -framework Security $LIBS"
348 dnl Check for framework headers...
349 AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h,AC_DEFINE(HAVE_APPLICATIONSERVICES_H))
350 AC_CHECK_HEADER(CoreFoundation/CoreFoundation.h,AC_DEFINE(HAVE_COREFOUNDATION_H))
351 AC_CHECK_HEADER(CoreFoundation/CFPriv.h,AC_DEFINE(HAVE_CFPRIV_H))
352 AC_CHECK_HEADER(CoreFoundation/CFBundlePriv.h,AC_DEFINE(HAVE_CFBUNDLEPRIV_H))
353 AC_CHECK_HEADER(IOKit/pwr_mgt/IOPMLibPrivate.h,AC_DEFINE(HAVE_IOKIT_PWR_MGT_IOPMLIBPRIVATE_H))
355 dnl Check for dynamic store function...
356 AC_CHECK_FUNCS(SCDynamicStoreCopyComputerName)
358 dnl Check for the new membership functions in MacOSX 10.4...
359 AC_CHECK_HEADER(membership.h,AC_DEFINE(HAVE_MEMBERSHIP_H))
360 AC_CHECK_HEADER(membershipPriv.h,AC_DEFINE(HAVE_MEMBERSHIPPRIV_H))
361 AC_CHECK_FUNCS(mbr_uid_to_uuid)
363 dnl Check for the vproc_transaction_begin/end stuff...
364 AC_CHECK_FUNCS(vproc_transaction_begin)
366 dnl Need <dlfcn.h> header...
367 AC_CHECK_HEADER(dlfcn.h,AC_DEFINE(HAVE_DLFCN_H))
369 dnl Check for notify_post support
370 AC_CHECK_HEADER(notify.h,AC_DEFINE(HAVE_NOTIFY_H))
371 AC_CHECK_FUNCS(notify_post)
373 dnl Check for Authorization Services support
374 AC_ARG_WITH(adminkey, [ --with-adminkey set the default SystemAuthKey value],
375 default_adminkey="$withval",
376 default_adminkey="default")
377 AC_ARG_WITH(operkey, [ --with-operkey set the default operator @AUTHKEY value],
378 default_operkey="$withval",
379 default_operkey="default")
381 AC_CHECK_HEADER(Security/Authorization.h, [
382 AC_DEFINE(HAVE_AUTHORIZATION_H)
384 if test "x$default_adminkey" != xdefault; then
385 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey $default_adminkey"
386 elif grep -q system.print.operator /etc/authorization; then
387 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.print.admin"
389 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.preferences"
392 if test "x$default_operkey" != xdefault; then
393 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY($default_operkey) @admin @lpadmin"
394 elif grep -q system.print.operator /etc/authorization; then
395 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.operator) @admin @lpadmin"
397 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.admin) @admin @lpadmin"
399 AC_CHECK_HEADER(Security/SecBasePriv.h,AC_DEFINE(HAVE_SECBASEPRIV_H))
401 dnl Check for sandbox/Seatbelt support
402 if test $uversion -ge 100; then
403 AC_CHECK_HEADER(sandbox.h,AC_DEFINE(HAVE_SANDBOX_H))
405 if test $uversion -ge 110; then
406 # Broken public headers in 10.7...
407 AC_MSG_CHECKING(for sandbox/private.h presence)
408 if test -f /usr/local/include/sandbox/private.h; then
412 AC_MSG_ERROR(Run 'sudo mkdir -p /usr/local/include/sandbox' and 'sudo touch /usr/local/include/sandbox/private.h' to build CUPS.)
416 dnl Check for XPC support
417 AC_CHECK_HEADER(xpc/xpc.h,
419 INSTALLXPC="install-xpc")
420 AC_CHECK_HEADER(xpc/private.h,
421 AC_DEFINE(HAVE_XPC_PRIVATE_H))
425 AC_SUBST(CUPS_DEFAULT_PRINTOPERATOR_AUTH)
426 AC_DEFINE_UNQUOTED(CUPS_DEFAULT_PRINTOPERATOR_AUTH, "$CUPS_DEFAULT_PRINTOPERATOR_AUTH")
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!])
455 dnl End of "$Id: cups-common.m4 8781 2009-08-28 17:34:54Z mike $".