]> git.ipfire.org Git - thirdparty/cups.git/blame - config-scripts/cups-common.m4
Merge changes from CUPS 1.5svn-r9717.
[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...
18ecb428 23CUPS_VERSION="1.5svn"
ecdc0628 24CUPS_REVISION=""
6d2f911b
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...
95AC_SEARCH_LIBS(crypt, crypt)
96AC_SEARCH_LIBS(getspent, sec gen)
97
98LIBMALLOC=""
bf3816c7 99AC_ARG_ENABLE(mallinfo, [ --enable-mallinfo build with malloc debug logging])
ef416fc2 100
101if test x$enable_mallinfo = xyes; then
75bd9771
MS
102 SAVELIBS="$LIBS"
103 LIBS=""
104 AC_SEARCH_LIBS(mallinfo, malloc, AC_DEFINE(HAVE_MALLINFO))
105 LIBMALLOC="$LIBS"
106 LIBS="$SAVELIBS"
ef416fc2 107fi
108
109AC_SUBST(LIBMALLOC)
110
111dnl Check for libpaper support...
bf3816c7 112AC_ARG_ENABLE(libpaper, [ --enable-libpaper build with libpaper support])
ef416fc2 113
114if test x$enable_libpaper = xyes; then
115 AC_CHECK_LIB(paper,systempapername,
116 AC_DEFINE(HAVE_LIBPAPER)
117 LIBPAPER="-lpaper",
118 LIBPAPER="")
119else
120 LIBPAPER=""
121fi
122AC_SUBST(LIBPAPER)
123
124dnl Checks for header files.
125AC_HEADER_STDC
126AC_CHECK_HEADER(crypt.h,AC_DEFINE(HAVE_CRYPT_H))
127AC_CHECK_HEADER(langinfo.h,AC_DEFINE(HAVE_LANGINFO_H))
128AC_CHECK_HEADER(malloc.h,AC_DEFINE(HAVE_MALLOC_H))
129AC_CHECK_HEADER(shadow.h,AC_DEFINE(HAVE_SHADOW_H))
130AC_CHECK_HEADER(string.h,AC_DEFINE(HAVE_STRING_H))
131AC_CHECK_HEADER(strings.h,AC_DEFINE(HAVE_STRINGS_H))
132AC_CHECK_HEADER(bstring.h,AC_DEFINE(HAVE_BSTRING_H))
133AC_CHECK_HEADER(usersec.h,AC_DEFINE(HAVE_USERSEC_H))
134AC_CHECK_HEADER(sys/ioctl.h,AC_DEFINE(HAVE_SYS_IOCTL_H))
db1f069b 135AC_CHECK_HEADER(sys/param.h,AC_DEFINE(HAVE_SYS_PARAM_H))
bc44d920 136AC_CHECK_HEADER(sys/ucred.h,AC_DEFINE(HAVE_SYS_UCRED_H))
2abf387c 137AC_CHECK_HEADER(scsi/sg.h,AC_DEFINE(HAVE_SCSI_SG_H))
ef416fc2 138
cc754834
MS
139dnl Checks for iconv.h and iconv_open
140AC_CHECK_HEADER(iconv.h,
141 SAVELIBS="$LIBS"
142 LIBS=""
143 AC_SEARCH_LIBS(iconv_open,iconv,
144 AC_DEFINE(HAVE_ICONV_H)
145 SAVELIBS="$SAVELIBS $LIBS")
146 LIBS="$SAVELIBS")
147
7cf5915e
MS
148dnl Checks for statfs and its many headers...
149AC_CHECK_HEADER(sys/mount.h,AC_DEFINE(HAVE_SYS_MOUNT_H))
150AC_CHECK_HEADER(sys/statfs.h,AC_DEFINE(HAVE_SYS_STATFS_H))
151AC_CHECK_HEADER(sys/statvfs.h,AC_DEFINE(HAVE_SYS_STATVFS_H))
152AC_CHECK_HEADER(sys/vfs.h,AC_DEFINE(HAVE_SYS_VFS_H))
153AC_CHECK_FUNCS(statfs statvfs)
154
ef416fc2 155dnl Checks for string functions.
156AC_CHECK_FUNCS(strdup strcasecmp strncasecmp strlcat strlcpy)
157if test "$uname" = "HP-UX" -a "$uversion" = "1020"; then
158 echo Forcing snprintf emulation for HP-UX.
159else
160 AC_CHECK_FUNCS(snprintf vsnprintf)
161fi
162
ac884b6a 163dnl Check for random number functions...
41681883 164AC_CHECK_FUNCS(random lrand48 arc4random)
ac884b6a 165
ef416fc2 166dnl Check for geteuid function.
167AC_CHECK_FUNCS(geteuid)
168
169dnl Check for vsyslog function.
170AC_CHECK_FUNCS(vsyslog)
171
172dnl Checks for signal functions.
173case "$uname" in
174 Linux | GNU)
175 # Do not use sigset on Linux or GNU HURD
176 ;;
177 *)
178 # Use sigset on other platforms, if available
179 AC_CHECK_FUNCS(sigset)
180 ;;
181esac
182
183AC_CHECK_FUNCS(sigaction)
184
185dnl Checks for wait functions.
cc0d019f 186AC_CHECK_FUNCS(waitpid wait3)
ef416fc2 187
188dnl See if the tm structure has the tm_gmtoff member...
189AC_MSG_CHECKING(for tm_gmtoff member in tm structure)
190AC_TRY_COMPILE([#include <time.h>],[struct tm t;
191 int o = t.tm_gmtoff;],
192 AC_MSG_RESULT(yes)
193 AC_DEFINE(HAVE_TM_GMTOFF),
194 AC_MSG_RESULT(no))
195
c7017ecc
MS
196dnl See if the stat structure has the st_gen member...
197AC_MSG_CHECKING(for st_gen member in stat structure)
198AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat t;
199 int o = t.st_gen;],
200 AC_MSG_RESULT(yes)
201 AC_DEFINE(HAVE_ST_GEN),
202 AC_MSG_RESULT(no))
203
cc0d019f
MS
204dnl See if we have the removefile(3) function for securely removing files
205AC_CHECK_FUNCS(removefile)
206
75bd9771 207dnl See if we have libusb...
bf3816c7 208AC_ARG_ENABLE(libusb, [ --enable-libusb use libusb for USB printing])
75bd9771
MS
209
210LIBUSB=""
211AC_SUBST(LIBUSB)
212
213if test x$enable_libusb = xyes; then
214 check_libusb=yes
215elif test x$enable_libusb != xno -a $uname != Darwin; then
216 check_libusb=yes
217else
218 check_libusb=no
219fi
220
221if test $check_libusb = yes; then
0268488e 222 AC_CHECK_LIB(usb, usb_get_string_simple,[
75bd9771
MS
223 AC_CHECK_HEADER(usb.h,
224 AC_DEFINE(HAVE_USB_H)
225 LIBUSB="-lusb")])
226fi
227
749b1e90 228dnl See if we have libwrap for TCP wrappers support...
bf3816c7 229AC_ARG_ENABLE(tcp_wrappers, [ --enable-tcp-wrappers use libwrap for TCP wrappers support])
749b1e90
MS
230
231LIBWRAP=""
232AC_SUBST(LIBWRAP)
233
234if test x$enable_tcp_wrappers = xyes; then
235 AC_CHECK_LIB(wrap, hosts_access,[
236 AC_CHECK_HEADER(tcpd.h,
237 AC_DEFINE(HAVE_TCPD_H)
238 LIBWRAP="-lwrap")])
239fi
240
ef416fc2 241dnl Flags for "ar" command...
242case $uname in
243 Darwin* | *BSD*)
244 ARFLAGS="-rcv"
245 ;;
246 *)
247 ARFLAGS="crvs"
248 ;;
249esac
250
251AC_SUBST(ARFLAGS)
252
ac884b6a 253dnl Prep libraries specifically for cupsd and backends...
bd7854cb 254BACKLIBS=""
cc754834 255SERVERLIBS=""
ac884b6a 256AC_SUBST(BACKLIBS)
cc754834 257AC_SUBST(SERVERLIBS)
ac884b6a
MS
258
259dnl See if we have POSIX ACL support...
260SAVELIBS="$LIBS"
261LIBS=""
bf3816c7 262AC_ARG_ENABLE(acl, [ --enable-acl build with POSIX ACL support])
ee571f26
MS
263if test "x$enable_acl" != xno; then
264 AC_SEARCH_LIBS(acl_init, acl, AC_DEFINE(HAVE_ACL_INIT))
cc754834 265 SERVERLIBS="$SERVERLIBS $LIBS"
ee571f26 266fi
ac884b6a
MS
267LIBS="$SAVELIBS"
268
269dnl Check for DBUS support
270if test -d /etc/dbus-1; then
271 DBUSDIR="/etc/dbus-1"
272else
273 DBUSDIR=""
274fi
bd7854cb 275
bf3816c7 276AC_ARG_ENABLE(dbus, [ --enable-dbus build with DBUS support])
ac884b6a
MS
277AC_ARG_WITH(dbusdir, [ --with-dbusdir set DBUS configuration directory ],
278 DBUSDIR="$withval")
279
c5571a1d
MS
280DBUS_NOTIFIER=""
281DBUS_NOTIFIERLIBS=""
282
0268488e
MS
283if test "x$enable_dbus" != xno -a "x$PKGCONFIG" != x; then
284 AC_MSG_CHECKING(for DBUS)
285 if $PKGCONFIG --exists dbus-1; then
286 AC_MSG_RESULT(yes)
287 AC_DEFINE(HAVE_DBUS)
288 CFLAGS="$CFLAGS `$PKGCONFIG --cflags dbus-1` -DDBUS_API_SUBJECT_TO_CHANGE"
289 SERVERLIBS="$SERVERLIBS `$PKGCONFIG --libs dbus-1`"
290 DBUS_NOTIFIER="dbus"
291 DBUS_NOTIFIERLIBS="`$PKGCONFIG --libs dbus-1`"
292 SAVELIBS="$LIBS"
293 LIBS="$LIBS $DBUS_NOTIFIERLIBS"
294 AC_CHECK_FUNC(dbus_message_iter_init_append,
295 AC_DEFINE(HAVE_DBUS_MESSAGE_ITER_INIT_APPEND))
296 LIBS="$SAVELIBS"
297 else
298 AC_MSG_RESULT(no)
ac884b6a
MS
299 fi
300fi
ecdc0628 301
ac884b6a 302AC_SUBST(DBUSDIR)
c5571a1d
MS
303AC_SUBST(DBUS_NOTIFIER)
304AC_SUBST(DBUS_NOTIFIERLIBS)
ac884b6a
MS
305
306dnl Extra platform-specific libraries...
b9faaae1 307CUPS_DEFAULT_PRINTOPERATOR_AUTH="@SYSTEM"
ac884b6a 308CUPS_SYSTEM_AUTHKEY=""
f8b3a85b 309LEGACY_BACKENDS="parallel"
09a101d6 310
ef416fc2 311case $uname in
312 Darwin*)
09a101d6 313 LEGACY_BACKENDS=""
ac884b6a 314 BACKLIBS="$BACKLIBS -framework IOKit"
cc754834 315 SERVERLIBS="$SERVERLIBS -framework IOKit -weak_framework ApplicationServices"
f8b3a85b 316 LIBS="-framework SystemConfiguration -framework CoreFoundation -framework Security $LIBS"
fa73b229 317
318 dnl Check for framework headers...
6d2f911b 319 AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h,AC_DEFINE(HAVE_APPLICATIONSERVICES_H))
fa73b229 320 AC_CHECK_HEADER(CoreFoundation/CoreFoundation.h,AC_DEFINE(HAVE_COREFOUNDATION_H))
321 AC_CHECK_HEADER(CoreFoundation/CFPriv.h,AC_DEFINE(HAVE_CFPRIV_H))
322 AC_CHECK_HEADER(CoreFoundation/CFBundlePriv.h,AC_DEFINE(HAVE_CFBUNDLEPRIV_H))
84315f46 323 AC_CHECK_HEADER(IOKit/pwr_mgt/IOPMLibPrivate.h,AC_DEFINE(HAVE_IOKIT_PWR_MGT_IOPMLIBPRIVATE_H))
fa73b229 324
6d2f911b
MS
325 dnl Check for dynamic store function...
326 AC_CHECK_FUNCS(SCDynamicStoreCopyComputerName)
327
229681c1
MS
328 dnl Check for new ColorSync APIs...
329 SAVELIBS="$LIBS"
330 LIBS="$LIBS -framework ApplicationServices"
331 AC_CHECK_FUNCS(ColorSyncRegisterDevice)
332 LIBS="$SAVELIBS"
333
7594b224 334 dnl Check for the new membership functions in MacOSX 10.4...
fa73b229 335 AC_CHECK_HEADER(membership.h,AC_DEFINE(HAVE_MEMBERSHIP_H))
7594b224 336 AC_CHECK_HEADER(membershipPriv.h,AC_DEFINE(HAVE_MEMBERSHIPPRIV_H))
fa73b229 337 AC_CHECK_FUNCS(mbr_uid_to_uuid)
338
178cb736
MS
339 dnl Check for the vproc_transaction_begin/end stuff...
340 AC_CHECK_FUNCS(vproc_transaction_begin)
341
7594b224 342 dnl Need <dlfcn.h> header...
343 AC_CHECK_HEADER(dlfcn.h,AC_DEFINE(HAVE_DLFCN_H))
344
fa73b229 345 dnl Check for notify_post support
346 AC_CHECK_HEADER(notify.h,AC_DEFINE(HAVE_NOTIFY_H))
347 AC_CHECK_FUNCS(notify_post)
f7deaa1a 348
349 dnl Check for Authorization Services support
1f0275e3
MS
350 AC_ARG_WITH(adminkey, [ --with-adminkey set the default SystemAuthKey value],
351 default_adminkey="$withval",
352 default_adminkey="default")
353 AC_ARG_WITH(operkey, [ --with-operkey set the default operator @AUTHKEY value],
354 default_operkey="$withval",
355 default_operkey="default")
356
f7deaa1a 357 AC_CHECK_HEADER(Security/Authorization.h, [
358 AC_DEFINE(HAVE_AUTHORIZATION_H)
1f0275e3
MS
359
360 if test "x$default_adminkey" != xdefault; then
361 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey $default_adminkey"
362 elif grep -q system.print.operator /etc/authorization; then
363 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.print.admin"
01ce6322 364 else
1f0275e3
MS
365 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.preferences"
366 fi
367
368 if test "x$default_operkey" != xdefault; then
b9faaae1 369 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY($default_operkey) @admin @lpadmin"
1f0275e3 370 elif grep -q system.print.operator /etc/authorization; then
b9faaae1 371 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.operator) @admin @lpadmin"
1f0275e3 372 else
b9faaae1 373 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.admin) @admin @lpadmin"
01ce6322 374 fi])
f7deaa1a 375 AC_CHECK_HEADER(Security/SecBasePriv.h,AC_DEFINE(HAVE_SECBASEPRIV_H))
a4924f6c
MS
376
377 dnl Check for sandbox/Seatbelt support
82f97232
MS
378 if test $uversion -ge 100; then
379 AC_CHECK_HEADER(sandbox.h,AC_DEFINE(HAVE_SANDBOX_H))
380 fi
ef416fc2 381 ;;
ef416fc2 382esac
383
b9faaae1
MS
384AC_SUBST(CUPS_DEFAULT_PRINTOPERATOR_AUTH)
385AC_DEFINE_UNQUOTED(CUPS_DEFAULT_PRINTOPERATOR_AUTH, "$CUPS_DEFAULT_PRINTOPERATOR_AUTH")
f7deaa1a 386AC_SUBST(CUPS_SYSTEM_AUTHKEY)
ac884b6a 387AC_SUBST(LEGACY_BACKENDS)
ef416fc2 388
6d2f911b
MS
389dnl Check for build components
390COMPONENTS="all"
391
392AC_ARG_WITH(components, [ --with-components set components to build:
393 - "all" (default) builds everything
394 - "core" builds libcups and ipptool],
395 COMPONENTS="$withval")
396
397case "$COMPONENTS" in
398 all)
399 BUILDDIRS="filter backend berkeley cgi-bin driver monitor notifier ppdc scheduler systemv conf data locale man doc examples templates"
400 ;;
401
402 core)
403 BUILDDIRS="data locale"
404 ;;
405
406 *)
407 AC_MSG_ERROR([Bad build component "$COMPONENT" specified!])
408 ;;
409esac
410
411AC_SUBST(BUILDDIRS)
412
ef416fc2 413dnl
18ecb428 414dnl End of "$Id: cups-common.m4 8781 2009-08-28 17:34:54Z mike $".
ef416fc2 415dnl