]> git.ipfire.org Git - thirdparty/cups.git/blame - config-scripts/cups-common.m4
Sync up with CUPS 1.6svn-r10269 (changes from Zin TOT merged into cups.org TOT)
[thirdparty/cups.git] / config-scripts / cups-common.m4
CommitLineData
ef416fc2 1dnl
18ecb428 2dnl "$Id: cups-common.m4 8781 2009-08-28 17:34:54Z mike $"
ef416fc2 3dnl
6d2f911b 4dnl Common configuration stuff for CUPS.
ef416fc2 5dnl
0268488e 6dnl Copyright 2007-2011 by Apple Inc.
f7deaa1a 7dnl Copyright 1997-2007 by Easy Software Products, all rights reserved.
ef416fc2 8dnl
9dnl These coded instructions, statements, and computer programs are the
bc44d920 10dnl property of Apple Inc. and are protected by Federal copyright
11dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
12dnl which should have been included with this file. If this file is
13dnl file is missing or damaged, see the license at "http://www.cups.org/".
ef416fc2 14dnl
15
c277e2f8
MS
16dnl We need at least autoconf 2.60...
17AC_PREREQ(2.60)
ef416fc2 18
19dnl Set the name of the config header file...
20AC_CONFIG_HEADER(config.h)
21
ac884b6a 22dnl Version number information...
a4845881 23CUPS_VERSION="1.6svn"
ecdc0628 24CUPS_REVISION=""
a4845881
MS
25if 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'`"
27fi
e4572d57
MS
28CUPS_BUILD="cups-$CUPS_VERSION"
29
30AC_ARG_WITH(cups_build, [ --with-cups-build set "cups-config --build" string ],
31 CUPS_BUILD="$withval")
ecdc0628 32
ef416fc2 33AC_SUBST(CUPS_VERSION)
ecdc0628 34AC_SUBST(CUPS_REVISION)
e4572d57 35AC_SUBST(CUPS_BUILD)
ecdc0628 36AC_DEFINE_UNQUOTED(CUPS_SVERSION, "CUPS v$CUPS_VERSION$CUPS_REVISION")
37AC_DEFINE_UNQUOTED(CUPS_MINIMAL, "CUPS/$CUPS_VERSION$CUPS_REVISION")
ef416fc2 38
39dnl Default compiler flags...
40CFLAGS="${CFLAGS:=}"
41CPPFLAGS="${CPPFLAGS:=}"
ac884b6a 42CXXFLAGS="${CXXFLAGS:=}"
ef416fc2 43LDFLAGS="${LDFLAGS:=}"
44
45dnl Checks for programs...
46AC_PROG_AWK
47AC_PROG_CC
ef416fc2 48AC_PROG_CPP
ac884b6a 49AC_PROG_CXX
ef416fc2 50AC_PROG_RANLIB
51AC_PATH_PROG(AR,ar)
97c9a8d7 52AC_PATH_PROG(CHMOD,chmod)
ef416fc2 53AC_PATH_PROG(HTMLDOC,htmldoc)
bd7854cb 54AC_PATH_PROG(LD,ld)
ef416fc2 55AC_PATH_PROG(LN,ln)
56AC_PATH_PROG(MV,mv)
57AC_PATH_PROG(RM,rm)
e1d6a774 58AC_PATH_PROG(RMDIR,rmdir)
ef416fc2 59AC_PATH_PROG(SED,sed)
ee571f26
MS
60AC_PATH_PROG(XDGOPEN,xdg-open)
61if test "x$XDGOPEN" = x; then
62 CUPS_HTMLVIEW="htmlview"
63else
64 CUPS_HTMLVIEW="$XDGOPEN"
65fi
66AC_SUBST(CUPS_HTMLVIEW)
839a51c8
MS
67
68AC_MSG_CHECKING(for install-sh script)
e07d4801 69INSTALL="`pwd`/install-sh"
839a51c8
MS
70AC_SUBST(INSTALL)
71AC_MSG_RESULT(using $INSTALL)
ef416fc2 72
73if test "x$AR" = x; then
74 AC_MSG_ERROR([Unable to find required library archive command.])
75fi
76if test "x$CC" = x; then
77 AC_MSG_ERROR([Unable to find required C compiler command.])
78fi
ef416fc2 79
923edb68 80dnl Static library option...
81INSTALLSTATIC=""
bf3816c7 82AC_ARG_ENABLE(static, [ --enable-static install static libraries])
923edb68 83
d6ae789d 84if test x$enable_static = xyes; then
85 echo Installing static libraries...
923edb68 86 INSTALLSTATIC="installstatic"
87fi
88
89AC_SUBST(INSTALLSTATIC)
ef416fc2 90
0268488e
MS
91dnl Check for pkg-config, which is used for some other tests later on...
92AC_PATH_PROG(PKGCONFIG, pkg-config)
93
ef416fc2 94dnl Check for libraries...
83e08001 95AC_SEARCH_LIBS(fmod, m)
ef416fc2 96AC_SEARCH_LIBS(crypt, crypt)
97AC_SEARCH_LIBS(getspent, sec gen)
98
99LIBMALLOC=""
bf3816c7 100AC_ARG_ENABLE(mallinfo, [ --enable-mallinfo build with malloc debug logging])
ef416fc2 101
102if test x$enable_mallinfo = xyes; then
75bd9771
MS
103 SAVELIBS="$LIBS"
104 LIBS=""
105 AC_SEARCH_LIBS(mallinfo, malloc, AC_DEFINE(HAVE_MALLINFO))
106 LIBMALLOC="$LIBS"
107 LIBS="$SAVELIBS"
ef416fc2 108fi
109
110AC_SUBST(LIBMALLOC)
111
112dnl Check for libpaper support...
bf3816c7 113AC_ARG_ENABLE(libpaper, [ --enable-libpaper build with libpaper support])
ef416fc2 114
115if test x$enable_libpaper = xyes; then
116 AC_CHECK_LIB(paper,systempapername,
117 AC_DEFINE(HAVE_LIBPAPER)
118 LIBPAPER="-lpaper",
119 LIBPAPER="")
120else
121 LIBPAPER=""
122fi
123AC_SUBST(LIBPAPER)
124
125dnl Checks for header files.
126AC_HEADER_STDC
a4845881 127AC_CHECK_HEADER(stdlib.h,AC_DEFINE(HAVE_STDLIB_H))
ef416fc2 128AC_CHECK_HEADER(crypt.h,AC_DEFINE(HAVE_CRYPT_H))
129AC_CHECK_HEADER(langinfo.h,AC_DEFINE(HAVE_LANGINFO_H))
130AC_CHECK_HEADER(malloc.h,AC_DEFINE(HAVE_MALLOC_H))
131AC_CHECK_HEADER(shadow.h,AC_DEFINE(HAVE_SHADOW_H))
132AC_CHECK_HEADER(string.h,AC_DEFINE(HAVE_STRING_H))
133AC_CHECK_HEADER(strings.h,AC_DEFINE(HAVE_STRINGS_H))
134AC_CHECK_HEADER(bstring.h,AC_DEFINE(HAVE_BSTRING_H))
135AC_CHECK_HEADER(usersec.h,AC_DEFINE(HAVE_USERSEC_H))
136AC_CHECK_HEADER(sys/ioctl.h,AC_DEFINE(HAVE_SYS_IOCTL_H))
db1f069b 137AC_CHECK_HEADER(sys/param.h,AC_DEFINE(HAVE_SYS_PARAM_H))
bc44d920 138AC_CHECK_HEADER(sys/ucred.h,AC_DEFINE(HAVE_SYS_UCRED_H))
2abf387c 139AC_CHECK_HEADER(scsi/sg.h,AC_DEFINE(HAVE_SCSI_SG_H))
ef416fc2 140
cc754834
MS
141dnl Checks for iconv.h and iconv_open
142AC_CHECK_HEADER(iconv.h,
143 SAVELIBS="$LIBS"
144 LIBS=""
145 AC_SEARCH_LIBS(iconv_open,iconv,
146 AC_DEFINE(HAVE_ICONV_H)
147 SAVELIBS="$SAVELIBS $LIBS")
148 LIBS="$SAVELIBS")
149
12f89d24
MS
150dnl Checks for Mini-XML (www.minixml.org)...
151LIBMXML=""
152AC_CHECK_HEADER(mxml.h,
153 SAVELIBS="$LIBS"
154 AC_SEARCH_LIBS(mmxlNewElement,mxml,
155 AC_DEFINE(HAVE_MXML_H)
156 LIBMXML="-lmxml")
157 LIBS="$SAVELIBS")
158AC_SUBST(LIBMXML)
159
7cf5915e
MS
160dnl Checks for statfs and its many headers...
161AC_CHECK_HEADER(sys/mount.h,AC_DEFINE(HAVE_SYS_MOUNT_H))
162AC_CHECK_HEADER(sys/statfs.h,AC_DEFINE(HAVE_SYS_STATFS_H))
163AC_CHECK_HEADER(sys/statvfs.h,AC_DEFINE(HAVE_SYS_STATVFS_H))
164AC_CHECK_HEADER(sys/vfs.h,AC_DEFINE(HAVE_SYS_VFS_H))
165AC_CHECK_FUNCS(statfs statvfs)
166
ef416fc2 167dnl Checks for string functions.
88f9aafc 168AC_CHECK_FUNCS(strdup strlcat strlcpy)
ef416fc2 169if test "$uname" = "HP-UX" -a "$uversion" = "1020"; then
170 echo Forcing snprintf emulation for HP-UX.
171else
172 AC_CHECK_FUNCS(snprintf vsnprintf)
173fi
174
ac884b6a 175dnl Check for random number functions...
41681883 176AC_CHECK_FUNCS(random lrand48 arc4random)
ac884b6a 177
ef416fc2 178dnl Check for geteuid function.
179AC_CHECK_FUNCS(geteuid)
180
88f9aafc
MS
181dnl Check for setpgid function.
182AC_CHECK_FUNCS(setpgid)
183
ef416fc2 184dnl Check for vsyslog function.
185AC_CHECK_FUNCS(vsyslog)
186
187dnl Checks for signal functions.
188case "$uname" in
189 Linux | GNU)
190 # Do not use sigset on Linux or GNU HURD
191 ;;
192 *)
193 # Use sigset on other platforms, if available
194 AC_CHECK_FUNCS(sigset)
195 ;;
196esac
197
198AC_CHECK_FUNCS(sigaction)
199
200dnl Checks for wait functions.
cc0d019f 201AC_CHECK_FUNCS(waitpid wait3)
ef416fc2 202
203dnl See if the tm structure has the tm_gmtoff member...
204AC_MSG_CHECKING(for tm_gmtoff member in tm structure)
205AC_TRY_COMPILE([#include <time.h>],[struct tm t;
206 int o = t.tm_gmtoff;],
207 AC_MSG_RESULT(yes)
208 AC_DEFINE(HAVE_TM_GMTOFF),
209 AC_MSG_RESULT(no))
210
c7017ecc
MS
211dnl See if the stat structure has the st_gen member...
212AC_MSG_CHECKING(for st_gen member in stat structure)
213AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat t;
214 int o = t.st_gen;],
215 AC_MSG_RESULT(yes)
216 AC_DEFINE(HAVE_ST_GEN),
217 AC_MSG_RESULT(no))
218
cc0d019f
MS
219dnl See if we have the removefile(3) function for securely removing files
220AC_CHECK_FUNCS(removefile)
221
75bd9771 222dnl See if we have libusb...
bf3816c7 223AC_ARG_ENABLE(libusb, [ --enable-libusb use libusb for USB printing])
75bd9771
MS
224
225LIBUSB=""
226AC_SUBST(LIBUSB)
227
228if test x$enable_libusb = xyes; then
229 check_libusb=yes
230elif test x$enable_libusb != xno -a $uname != Darwin; then
231 check_libusb=yes
232else
233 check_libusb=no
234fi
235
12f89d24
MS
236if test $check_libusb = yes -a "x$PKGCONFIG" != x; then
237 AC_MSG_CHECKING(for libusb-1.0)
238 if $PKGCONFIG --exists libusb-1.0; then
239 AC_MSG_RESULT(yes)
240 AC_DEFINE(HAVE_LIBUSB)
241 CFLAGS="$CFLAGS `$PKGCONFIG --cflags libusb-1.0`"
242 LIBUSB="`$PKGCONFIG --libs libusb-1.0`"
243 else
244 AC_MSG_RESULT(no)
245 fi
75bd9771
MS
246fi
247
749b1e90 248dnl See if we have libwrap for TCP wrappers support...
bf3816c7 249AC_ARG_ENABLE(tcp_wrappers, [ --enable-tcp-wrappers use libwrap for TCP wrappers support])
749b1e90
MS
250
251LIBWRAP=""
252AC_SUBST(LIBWRAP)
253
254if 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)
258 LIBWRAP="-lwrap")])
259fi
260
a4845881
MS
261dnl ZLIB
262LIBZ=""
263AC_CHECK_HEADER(zlib.h,
264 AC_CHECK_LIB(z, gzgets,
265 AC_DEFINE(HAVE_LIBZ)
266 LIBZ="-lz"
267 LIBS="$LIBS -lz"))
268AC_SUBST(LIBZ)
269
ef416fc2 270dnl Flags for "ar" command...
271case $uname in
272 Darwin* | *BSD*)
273 ARFLAGS="-rcv"
274 ;;
275 *)
276 ARFLAGS="crvs"
277 ;;
278esac
279
280AC_SUBST(ARFLAGS)
281
ac884b6a 282dnl Prep libraries specifically for cupsd and backends...
bd7854cb 283BACKLIBS=""
cc754834 284SERVERLIBS=""
ac884b6a 285AC_SUBST(BACKLIBS)
cc754834 286AC_SUBST(SERVERLIBS)
ac884b6a
MS
287
288dnl See if we have POSIX ACL support...
289SAVELIBS="$LIBS"
290LIBS=""
bf3816c7 291AC_ARG_ENABLE(acl, [ --enable-acl build with POSIX ACL support])
ee571f26
MS
292if test "x$enable_acl" != xno; then
293 AC_SEARCH_LIBS(acl_init, acl, AC_DEFINE(HAVE_ACL_INIT))
cc754834 294 SERVERLIBS="$SERVERLIBS $LIBS"
ee571f26 295fi
ac884b6a
MS
296LIBS="$SAVELIBS"
297
298dnl Check for DBUS support
299if test -d /etc/dbus-1; then
300 DBUSDIR="/etc/dbus-1"
301else
302 DBUSDIR=""
303fi
bd7854cb 304
bf3816c7 305AC_ARG_ENABLE(dbus, [ --enable-dbus build with DBUS support])
ac884b6a
MS
306AC_ARG_WITH(dbusdir, [ --with-dbusdir set DBUS configuration directory ],
307 DBUSDIR="$withval")
308
c5571a1d
MS
309DBUS_NOTIFIER=""
310DBUS_NOTIFIERLIBS=""
311
0268488e
MS
312if test "x$enable_dbus" != xno -a "x$PKGCONFIG" != x; then
313 AC_MSG_CHECKING(for DBUS)
314 if $PKGCONFIG --exists dbus-1; then
315 AC_MSG_RESULT(yes)
316 AC_DEFINE(HAVE_DBUS)
317 CFLAGS="$CFLAGS `$PKGCONFIG --cflags dbus-1` -DDBUS_API_SUBJECT_TO_CHANGE"
318 SERVERLIBS="$SERVERLIBS `$PKGCONFIG --libs dbus-1`"
319 DBUS_NOTIFIER="dbus"
320 DBUS_NOTIFIERLIBS="`$PKGCONFIG --libs dbus-1`"
321 SAVELIBS="$LIBS"
322 LIBS="$LIBS $DBUS_NOTIFIERLIBS"
323 AC_CHECK_FUNC(dbus_message_iter_init_append,
324 AC_DEFINE(HAVE_DBUS_MESSAGE_ITER_INIT_APPEND))
325 LIBS="$SAVELIBS"
326 else
327 AC_MSG_RESULT(no)
ac884b6a
MS
328 fi
329fi
ecdc0628 330
ac884b6a 331AC_SUBST(DBUSDIR)
c5571a1d
MS
332AC_SUBST(DBUS_NOTIFIER)
333AC_SUBST(DBUS_NOTIFIERLIBS)
ac884b6a
MS
334
335dnl Extra platform-specific libraries...
b9faaae1 336CUPS_DEFAULT_PRINTOPERATOR_AUTH="@SYSTEM"
ac884b6a 337CUPS_SYSTEM_AUTHKEY=""
eac3a0a0 338INSTALLXPC=""
09a101d6 339
ef416fc2 340case $uname in
341 Darwin*)
ac884b6a 342 BACKLIBS="$BACKLIBS -framework IOKit"
cc754834 343 SERVERLIBS="$SERVERLIBS -framework IOKit -weak_framework ApplicationServices"
f8b3a85b 344 LIBS="-framework SystemConfiguration -framework CoreFoundation -framework Security $LIBS"
fa73b229 345
346 dnl Check for framework headers...
6d2f911b 347 AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h,AC_DEFINE(HAVE_APPLICATIONSERVICES_H))
fa73b229 348 AC_CHECK_HEADER(CoreFoundation/CoreFoundation.h,AC_DEFINE(HAVE_COREFOUNDATION_H))
349 AC_CHECK_HEADER(CoreFoundation/CFPriv.h,AC_DEFINE(HAVE_CFPRIV_H))
350 AC_CHECK_HEADER(CoreFoundation/CFBundlePriv.h,AC_DEFINE(HAVE_CFBUNDLEPRIV_H))
84315f46 351 AC_CHECK_HEADER(IOKit/pwr_mgt/IOPMLibPrivate.h,AC_DEFINE(HAVE_IOKIT_PWR_MGT_IOPMLIBPRIVATE_H))
fa73b229 352
6d2f911b
MS
353 dnl Check for dynamic store function...
354 AC_CHECK_FUNCS(SCDynamicStoreCopyComputerName)
355
229681c1
MS
356 dnl Check for new ColorSync APIs...
357 SAVELIBS="$LIBS"
358 LIBS="$LIBS -framework ApplicationServices"
359 AC_CHECK_FUNCS(ColorSyncRegisterDevice)
360 LIBS="$SAVELIBS"
361
7594b224 362 dnl Check for the new membership functions in MacOSX 10.4...
fa73b229 363 AC_CHECK_HEADER(membership.h,AC_DEFINE(HAVE_MEMBERSHIP_H))
7594b224 364 AC_CHECK_HEADER(membershipPriv.h,AC_DEFINE(HAVE_MEMBERSHIPPRIV_H))
fa73b229 365 AC_CHECK_FUNCS(mbr_uid_to_uuid)
366
178cb736
MS
367 dnl Check for the vproc_transaction_begin/end stuff...
368 AC_CHECK_FUNCS(vproc_transaction_begin)
369
7594b224 370 dnl Need <dlfcn.h> header...
371 AC_CHECK_HEADER(dlfcn.h,AC_DEFINE(HAVE_DLFCN_H))
372
fa73b229 373 dnl Check for notify_post support
374 AC_CHECK_HEADER(notify.h,AC_DEFINE(HAVE_NOTIFY_H))
375 AC_CHECK_FUNCS(notify_post)
f7deaa1a 376
377 dnl Check for Authorization Services support
1f0275e3
MS
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")
eac3a0a0 384
f7deaa1a 385 AC_CHECK_HEADER(Security/Authorization.h, [
386 AC_DEFINE(HAVE_AUTHORIZATION_H)
1f0275e3
MS
387
388 if test "x$default_adminkey" != xdefault; then
389 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey $default_adminkey"
390 elif grep -q system.print.operator /etc/authorization; then
391 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.print.admin"
01ce6322 392 else
1f0275e3
MS
393 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.preferences"
394 fi
395
396 if test "x$default_operkey" != xdefault; then
b9faaae1 397 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY($default_operkey) @admin @lpadmin"
1f0275e3 398 elif grep -q system.print.operator /etc/authorization; then
b9faaae1 399 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.operator) @admin @lpadmin"
1f0275e3 400 else
b9faaae1 401 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.admin) @admin @lpadmin"
01ce6322 402 fi])
f7deaa1a 403 AC_CHECK_HEADER(Security/SecBasePriv.h,AC_DEFINE(HAVE_SECBASEPRIV_H))
a4924f6c
MS
404
405 dnl Check for sandbox/Seatbelt support
82f97232 406 if test $uversion -ge 100; then
a2326b5b
MS
407 AC_CHECK_HEADER(sandbox.h,AC_DEFINE(HAVE_SANDBOX_H))
408 fi
409 if test $uversion -ge 110; then
410 # Broken public headers in 10.7...
411 AC_MSG_CHECKING(for sandbox/private.h presence)
412 if test -f /usr/local/include/sandbox/private.h; then
413 AC_MSG_RESULT(yes)
414 else
415 AC_MSG_RESULT(no)
416 AC_MSG_ERROR(Run 'sudo mkdir -p /usr/local/include/sandbox' and 'sudo touch /usr/local/include/sandbox/private.h' to build CUPS.)
417 fi
82f97232 418 fi
eac3a0a0
MS
419
420 dnl Check for XPC support
421 AC_CHECK_HEADER(xpc/xpc.h,
422 AC_DEFINE(HAVE_XPC)
423 INSTALLXPC="install-xpc")
ef416fc2 424 ;;
ef416fc2 425esac
426
b9faaae1
MS
427AC_SUBST(CUPS_DEFAULT_PRINTOPERATOR_AUTH)
428AC_DEFINE_UNQUOTED(CUPS_DEFAULT_PRINTOPERATOR_AUTH, "$CUPS_DEFAULT_PRINTOPERATOR_AUTH")
f7deaa1a 429AC_SUBST(CUPS_SYSTEM_AUTHKEY)
eac3a0a0 430AC_SUBST(INSTALLXPC)
ef416fc2 431
6d2f911b
MS
432dnl Check for build components
433COMPONENTS="all"
434
435AC_ARG_WITH(components, [ --with-components set components to build:
436 - "all" (default) builds everything
437 - "core" builds libcups and ipptool],
438 COMPONENTS="$withval")
439
440case "$COMPONENTS" in
441 all)
a4845881 442 BUILDDIRS="filter backend berkeley cgi-bin monitor notifier ppdc scheduler systemv conf data desktop locale man doc examples templates"
6d2f911b
MS
443 ;;
444
445 core)
446 BUILDDIRS="data locale"
447 ;;
448
449 *)
450 AC_MSG_ERROR([Bad build component "$COMPONENT" specified!])
451 ;;
452esac
453
454AC_SUBST(BUILDDIRS)
455
ef416fc2 456dnl
18ecb428 457dnl End of "$Id: cups-common.m4 8781 2009-08-28 17:34:54Z mike $".
ef416fc2 458dnl