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-2010 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(HTMLDOC,htmldoc)
58 AC_PATH_PROG(RMDIR,rmdir)
60 AC_PATH_PROG(XDGOPEN,xdg-open)
61 if test "x$XDGOPEN" = x; then
62 CUPS_HTMLVIEW="htmlview"
64 CUPS_HTMLVIEW="$XDGOPEN"
66 AC_SUBST(CUPS_HTMLVIEW)
68 AC_MSG_CHECKING(for install-sh script)
69 INSTALL="`pwd`/install-sh"
71 AC_MSG_RESULT(using $INSTALL)
73 if test "x$AR" = x; then
74 AC_MSG_ERROR([Unable to find required library archive command.])
76 if test "x$CC" = x; then
77 AC_MSG_ERROR([Unable to find required C compiler command.])
80 dnl Static library option...
82 AC_ARG_ENABLE(static, [ --enable-static install static libraries])
84 if test x$enable_static = xyes; then
85 echo Installing static libraries...
86 INSTALLSTATIC="installstatic"
89 AC_SUBST(INSTALLSTATIC)
91 dnl Check for libraries...
92 AC_SEARCH_LIBS(crypt, crypt)
93 AC_SEARCH_LIBS(getspent, sec gen)
96 AC_ARG_ENABLE(mallinfo, [ --enable-mallinfo build with malloc debug logging])
98 if test x$enable_mallinfo = xyes; then
101 AC_SEARCH_LIBS(mallinfo, malloc, AC_DEFINE(HAVE_MALLINFO))
108 dnl Check for libpaper support...
109 AC_ARG_ENABLE(libpaper, [ --enable-libpaper build with libpaper support])
111 if test x$enable_libpaper = xyes; then
112 AC_CHECK_LIB(paper,systempapername,
113 AC_DEFINE(HAVE_LIBPAPER)
121 dnl Checks for header files.
123 AC_CHECK_HEADER(crypt.h,AC_DEFINE(HAVE_CRYPT_H))
124 AC_CHECK_HEADER(langinfo.h,AC_DEFINE(HAVE_LANGINFO_H))
125 AC_CHECK_HEADER(malloc.h,AC_DEFINE(HAVE_MALLOC_H))
126 AC_CHECK_HEADER(shadow.h,AC_DEFINE(HAVE_SHADOW_H))
127 AC_CHECK_HEADER(string.h,AC_DEFINE(HAVE_STRING_H))
128 AC_CHECK_HEADER(strings.h,AC_DEFINE(HAVE_STRINGS_H))
129 AC_CHECK_HEADER(bstring.h,AC_DEFINE(HAVE_BSTRING_H))
130 AC_CHECK_HEADER(usersec.h,AC_DEFINE(HAVE_USERSEC_H))
131 AC_CHECK_HEADER(sys/ioctl.h,AC_DEFINE(HAVE_SYS_IOCTL_H))
132 AC_CHECK_HEADER(sys/param.h,AC_DEFINE(HAVE_SYS_PARAM_H))
133 AC_CHECK_HEADER(sys/ucred.h,AC_DEFINE(HAVE_SYS_UCRED_H))
134 AC_CHECK_HEADER(scsi/sg.h,AC_DEFINE(HAVE_SCSI_SG_H))
136 dnl Checks for string functions.
137 AC_CHECK_FUNCS(strdup strcasecmp strncasecmp strlcat strlcpy)
138 if test "$uname" = "HP-UX" -a "$uversion" = "1020"; then
139 echo Forcing snprintf emulation for HP-UX.
141 AC_CHECK_FUNCS(snprintf vsnprintf)
144 dnl Check for random number functions...
145 AC_CHECK_FUNCS(random lrand48 arc4random)
147 dnl Check for geteuid function.
148 AC_CHECK_FUNCS(geteuid)
150 dnl Check for vsyslog function.
151 AC_CHECK_FUNCS(vsyslog)
153 dnl Checks for signal functions.
156 # Do not use sigset on Linux or GNU HURD
159 # Use sigset on other platforms, if available
160 AC_CHECK_FUNCS(sigset)
164 AC_CHECK_FUNCS(sigaction)
166 dnl Checks for wait functions.
167 AC_CHECK_FUNCS(waitpid wait3)
169 dnl See if the tm structure has the tm_gmtoff member...
170 AC_MSG_CHECKING(for tm_gmtoff member in tm structure)
171 AC_TRY_COMPILE([#include <time.h>],[struct tm t;
172 int o = t.tm_gmtoff;],
174 AC_DEFINE(HAVE_TM_GMTOFF),
177 dnl See if we have the removefile(3) function for securely removing files
178 AC_CHECK_FUNCS(removefile)
180 dnl See if we have libusb...
181 AC_ARG_ENABLE(libusb, [ --enable-libusb use libusb for USB printing])
186 if test x$enable_libusb = xyes; then
188 elif test x$enable_libusb != xno -a $uname != Darwin; then
194 if test $check_libusb = yes; then
195 AC_CHECK_LIB(usb, usb_init,[
196 AC_CHECK_HEADER(usb.h,
197 AC_DEFINE(HAVE_USB_H)
201 dnl See if we have libwrap for TCP wrappers support...
202 AC_ARG_ENABLE(tcp_wrappers, [ --enable-tcp-wrappers use libwrap for TCP wrappers support])
207 if test x$enable_tcp_wrappers = xyes; then
208 AC_CHECK_LIB(wrap, hosts_access,[
209 AC_CHECK_HEADER(tcpd.h,
210 AC_DEFINE(HAVE_TCPD_H)
214 dnl Flags for "ar" command...
226 dnl Prep libraries specifically for cupsd and backends...
232 dnl See if we have POSIX ACL support...
235 AC_ARG_ENABLE(acl, [ --enable-acl build with POSIX ACL support])
236 if test "x$enable_acl" != xno; then
237 AC_SEARCH_LIBS(acl_init, acl, AC_DEFINE(HAVE_ACL_INIT))
238 CUPSDLIBS="$CUPSDLIBS $LIBS"
242 dnl Check for DBUS support
243 if test -d /etc/dbus-1; then
244 DBUSDIR="/etc/dbus-1"
249 AC_ARG_ENABLE(dbus, [ --enable-dbus build with DBUS support])
250 AC_ARG_WITH(dbusdir, [ --with-dbusdir set DBUS configuration directory ],
256 if test "x$enable_dbus" != xno; then
257 AC_PATH_PROG(PKGCONFIG, pkg-config)
258 if test "x$PKGCONFIG" != x; then
259 AC_MSG_CHECKING(for DBUS)
260 if $PKGCONFIG --exists dbus-1; then
263 CFLAGS="$CFLAGS `$PKGCONFIG --cflags dbus-1` -DDBUS_API_SUBJECT_TO_CHANGE"
264 CUPSDLIBS="$CUPSDLIBS `$PKGCONFIG --libs dbus-1`"
266 DBUS_NOTIFIERLIBS="`$PKGCONFIG --libs dbus-1`"
268 dbus_message_iter_init_append,
269 AC_DEFINE(HAVE_DBUS_MESSAGE_ITER_INIT_APPEND),,
270 `$PKGCONFIG --libs dbus-1`)
278 AC_SUBST(DBUS_NOTIFIER)
279 AC_SUBST(DBUS_NOTIFIERLIBS)
281 dnl Extra platform-specific libraries...
282 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@SYSTEM"
283 CUPS_SYSTEM_AUTHKEY=""
284 LEGACY_BACKENDS="parallel"
289 BACKLIBS="$BACKLIBS -framework IOKit"
290 CUPSDLIBS="$CUPSDLIBS -sectorder __TEXT __text cupsd.order -e start -framework IOKit -weak_framework ApplicationServices"
291 LIBS="-framework SystemConfiguration -framework CoreFoundation -framework Security $LIBS"
293 dnl Check for framework headers...
294 AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h,AC_DEFINE(HAVE_APPLICATIONSERVICES_H))
295 AC_CHECK_HEADER(CoreFoundation/CoreFoundation.h,AC_DEFINE(HAVE_COREFOUNDATION_H))
296 AC_CHECK_HEADER(CoreFoundation/CFPriv.h,AC_DEFINE(HAVE_CFPRIV_H))
297 AC_CHECK_HEADER(CoreFoundation/CFBundlePriv.h,AC_DEFINE(HAVE_CFBUNDLEPRIV_H))
299 dnl Check for dynamic store function...
300 AC_CHECK_FUNCS(SCDynamicStoreCopyComputerName)
302 dnl Check for the new membership functions in MacOSX 10.4...
303 AC_CHECK_HEADER(membership.h,AC_DEFINE(HAVE_MEMBERSHIP_H))
304 AC_CHECK_HEADER(membershipPriv.h,AC_DEFINE(HAVE_MEMBERSHIPPRIV_H))
305 AC_CHECK_FUNCS(mbr_uid_to_uuid)
307 dnl Check for the vproc_transaction_begin/end stuff...
308 AC_CHECK_FUNCS(vproc_transaction_begin)
310 dnl Need <dlfcn.h> header...
311 AC_CHECK_HEADER(dlfcn.h,AC_DEFINE(HAVE_DLFCN_H))
313 dnl Check for notify_post support
314 AC_CHECK_HEADER(notify.h,AC_DEFINE(HAVE_NOTIFY_H))
315 AC_CHECK_FUNCS(notify_post)
317 dnl Check for Authorization Services support
318 AC_ARG_WITH(adminkey, [ --with-adminkey set the default SystemAuthKey value],
319 default_adminkey="$withval",
320 default_adminkey="default")
321 AC_ARG_WITH(operkey, [ --with-operkey set the default operator @AUTHKEY value],
322 default_operkey="$withval",
323 default_operkey="default")
325 AC_CHECK_HEADER(Security/Authorization.h, [
326 AC_DEFINE(HAVE_AUTHORIZATION_H)
328 if test "x$default_adminkey" != xdefault; then
329 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey $default_adminkey"
330 elif grep -q system.print.operator /etc/authorization; then
331 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.print.admin"
333 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.preferences"
336 if test "x$default_operkey" != xdefault; then
337 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY($default_operkey) @admin @lpadmin"
338 elif grep -q system.print.operator /etc/authorization; then
339 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.operator) @admin @lpadmin"
341 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.admin) @admin @lpadmin"
343 AC_CHECK_HEADER(Security/SecBasePriv.h,AC_DEFINE(HAVE_SECBASEPRIV_H))
345 dnl Check for sandbox/Seatbelt support
346 AC_CHECK_HEADER(sandbox.h,AC_DEFINE(HAVE_SANDBOX_H))
350 AC_SUBST(CUPS_DEFAULT_PRINTOPERATOR_AUTH)
351 AC_DEFINE_UNQUOTED(CUPS_DEFAULT_PRINTOPERATOR_AUTH, "$CUPS_DEFAULT_PRINTOPERATOR_AUTH")
352 AC_SUBST(CUPS_SYSTEM_AUTHKEY)
353 AC_SUBST(LEGACY_BACKENDS)
355 dnl Check for build components
358 AC_ARG_WITH(components, [ --with-components set components to build:
359 - "all" (default) builds everything
360 - "core" builds libcups and ipptool],
361 COMPONENTS="$withval")
363 case "$COMPONENTS" in
365 BUILDDIRS="filter backend berkeley cgi-bin driver monitor notifier ppdc scheduler systemv conf data locale man doc examples templates"
369 BUILDDIRS="data locale"
373 AC_MSG_ERROR([Bad build component "$COMPONENT" specified!])
380 dnl End of "$Id: cups-common.m4 8781 2009-08-28 17:34:54Z mike $".