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