]> git.ipfire.org Git - thirdparty/cups.git/blob - config-scripts/cups-common.m4
Merge pull request #5297 from FedericoYundt/patch-1
[thirdparty/cups.git] / config-scripts / cups-common.m4
1 dnl
2 dnl Common configuration stuff for CUPS.
3 dnl
4 dnl Copyright 2007-2017 by Apple Inc.
5 dnl Copyright 1997-2007 by Easy Software Products, all rights reserved.
6 dnl
7 dnl Licensed under Apache License v2.0. See the file "LICENSE" for more information.
8 dnl
9
10 dnl Set the name of the config header file...
11 AC_CONFIG_HEADER(config.h)
12
13 dnl Version number information...
14 CUPS_VERSION="AC_PACKAGE_VERSION"
15 CUPS_REVISION=""
16 CUPS_BUILD="cups-$CUPS_VERSION"
17
18 AC_ARG_WITH(cups_build, [ --with-cups-build set "cups-config --build" string ],
19 CUPS_BUILD="$withval")
20
21 AC_SUBST(CUPS_VERSION)
22 AC_SUBST(CUPS_REVISION)
23 AC_SUBST(CUPS_BUILD)
24 AC_DEFINE_UNQUOTED(CUPS_SVERSION, "AC_PACKAGE_NAME v$CUPS_VERSION$CUPS_REVISION")
25 AC_DEFINE_UNQUOTED(CUPS_MINIMAL, "AC_PACKAGE_NAME/$CUPS_VERSION$CUPS_REVISION")
26
27 dnl Default compiler flags...
28 CFLAGS="${CFLAGS:=}"
29 CPPFLAGS="${CPPFLAGS:=}"
30 CXXFLAGS="${CXXFLAGS:=}"
31 LDFLAGS="${LDFLAGS:=}"
32
33 dnl Checks for programs...
34 AC_PROG_AWK
35 AC_PROG_CC(clang cc gcc)
36 AC_PROG_CPP
37 AC_PROG_CXX(clang++ c++ g++)
38 AC_PROG_RANLIB
39 AC_PATH_PROG(AR,ar)
40 AC_PATH_PROG(CHMOD,chmod)
41 AC_PATH_PROG(GZIP,gzip)
42 AC_PATH_PROG(LD,ld)
43 AC_PATH_PROG(LN,ln)
44 AC_PATH_PROG(MKDIR,mkdir)
45 AC_PATH_PROG(MV,mv)
46 AC_PATH_PROG(RM,rm)
47 AC_PATH_PROG(RMDIR,rmdir)
48 AC_PATH_PROG(SED,sed)
49 AC_PATH_PROG(XDGOPEN,xdg-open)
50 if test "x$XDGOPEN" = x; then
51 CUPS_HTMLVIEW="htmlview"
52 else
53 CUPS_HTMLVIEW="$XDGOPEN"
54 fi
55 AC_SUBST(CUPS_HTMLVIEW)
56
57 AC_MSG_CHECKING(for install-sh script)
58 INSTALL="`pwd`/install-sh"
59 AC_SUBST(INSTALL)
60 AC_MSG_RESULT(using $INSTALL)
61
62 if test "x$AR" = x; then
63 AC_MSG_ERROR([Unable to find required library archive command.])
64 fi
65 if test "x$CC" = x; then
66 AC_MSG_ERROR([Unable to find required C compiler command.])
67 fi
68
69 dnl Static library option...
70 INSTALLSTATIC=""
71 AC_ARG_ENABLE(static, [ --enable-static install static libraries])
72
73 if test x$enable_static = xyes; then
74 echo Installing static libraries...
75 INSTALLSTATIC="installstatic"
76 fi
77
78 AC_SUBST(INSTALLSTATIC)
79
80 dnl Check for pkg-config, which is used for some other tests later on...
81 AC_PATH_TOOL(PKGCONFIG, pkg-config)
82
83 dnl Check for libraries...
84 AC_SEARCH_LIBS(abs, m, AC_DEFINE(HAVE_ABS))
85 AC_SEARCH_LIBS(crypt, crypt)
86 AC_SEARCH_LIBS(fmod, m)
87 AC_SEARCH_LIBS(getspent, sec gen)
88
89 LIBMALLOC=""
90 AC_ARG_ENABLE(mallinfo, [ --enable-mallinfo build with malloc debug logging])
91
92 if test x$enable_mallinfo = xyes; then
93 SAVELIBS="$LIBS"
94 LIBS=""
95 AC_SEARCH_LIBS(mallinfo, malloc, AC_DEFINE(HAVE_MALLINFO))
96 LIBMALLOC="$LIBS"
97 LIBS="$SAVELIBS"
98 fi
99
100 AC_SUBST(LIBMALLOC)
101
102 dnl Check for libpaper support...
103 AC_ARG_ENABLE(libpaper, [ --enable-libpaper build with libpaper support])
104
105 if test x$enable_libpaper = xyes; then
106 AC_CHECK_LIB(paper,systempapername,
107 AC_DEFINE(HAVE_LIBPAPER)
108 LIBPAPER="-lpaper",
109 LIBPAPER="")
110 else
111 LIBPAPER=""
112 fi
113 AC_SUBST(LIBPAPER)
114
115 dnl Checks for header files.
116 AC_HEADER_STDC
117 AC_CHECK_HEADER(stdlib.h,AC_DEFINE(HAVE_STDLIB_H))
118 AC_CHECK_HEADER(crypt.h,AC_DEFINE(HAVE_CRYPT_H))
119 AC_CHECK_HEADER(langinfo.h,AC_DEFINE(HAVE_LANGINFO_H))
120 AC_CHECK_HEADER(malloc.h,AC_DEFINE(HAVE_MALLOC_H))
121 AC_CHECK_HEADER(shadow.h,AC_DEFINE(HAVE_SHADOW_H))
122 AC_CHECK_HEADER(stdint.h,AC_DEFINE(HAVE_STDINT_H))
123 AC_CHECK_HEADER(string.h,AC_DEFINE(HAVE_STRING_H))
124 AC_CHECK_HEADER(strings.h,AC_DEFINE(HAVE_STRINGS_H))
125 AC_CHECK_HEADER(bstring.h,AC_DEFINE(HAVE_BSTRING_H))
126 AC_CHECK_HEADER(sys/ioctl.h,AC_DEFINE(HAVE_SYS_IOCTL_H))
127 AC_CHECK_HEADER(sys/param.h,AC_DEFINE(HAVE_SYS_PARAM_H))
128 AC_CHECK_HEADER(sys/ucred.h,AC_DEFINE(HAVE_SYS_UCRED_H))
129
130 dnl Checks for iconv.h and iconv_open
131 AC_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")
137 AC_SEARCH_LIBS(libiconv_open,iconv,
138 AC_DEFINE(HAVE_ICONV_H)
139 SAVELIBS="$SAVELIBS $LIBS")
140 LIBS="$SAVELIBS")
141
142 dnl Checks for Mini-XML (www.minixml.org)...
143 LIBMXML=""
144 AC_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")
150 AC_SUBST(LIBMXML)
151
152 dnl Checks for statfs and its many headers...
153 AC_CHECK_HEADER(sys/mount.h,AC_DEFINE(HAVE_SYS_MOUNT_H))
154 AC_CHECK_HEADER(sys/statfs.h,AC_DEFINE(HAVE_SYS_STATFS_H))
155 AC_CHECK_HEADER(sys/statvfs.h,AC_DEFINE(HAVE_SYS_STATVFS_H))
156 AC_CHECK_HEADER(sys/vfs.h,AC_DEFINE(HAVE_SYS_VFS_H))
157 AC_CHECK_FUNCS(statfs statvfs)
158
159 dnl Checks for string functions.
160 AC_CHECK_FUNCS(strdup strlcat strlcpy)
161 if test "$host_os_name" = "hp-ux" -a "$host_os_version" = "1020"; then
162 echo Forcing snprintf emulation for HP-UX.
163 else
164 AC_CHECK_FUNCS(snprintf vsnprintf)
165 fi
166
167 dnl Check for random number functions...
168 AC_CHECK_FUNCS(random lrand48 arc4random)
169
170 dnl Check for geteuid function.
171 AC_CHECK_FUNCS(geteuid)
172
173 dnl Check for setpgid function.
174 AC_CHECK_FUNCS(setpgid)
175
176 dnl Check for vsyslog function.
177 AC_CHECK_FUNCS(vsyslog)
178
179 dnl Checks for signal functions.
180 case "$host_os_name" in
181 linux* | gnu*)
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 ;;
188 esac
189
190 AC_CHECK_FUNCS(sigaction)
191
192 dnl Checks for wait functions.
193 AC_CHECK_FUNCS(waitpid wait3)
194
195 dnl Check for posix_spawn
196 AC_CHECK_FUNCS(posix_spawn)
197
198 dnl Check for getgrouplist
199 AC_CHECK_FUNCS(getgrouplist)
200
201 dnl See if the tm structure has the tm_gmtoff member...
202 AC_MSG_CHECKING(for tm_gmtoff member in tm structure)
203 AC_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
209 dnl See if the stat structure has the st_gen member...
210 AC_MSG_CHECKING(for st_gen member in stat structure)
211 AC_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
217 dnl See if we have the removefile(3) function for securely removing files
218 AC_CHECK_FUNCS(removefile)
219
220 dnl See if we have libusb...
221 AC_ARG_ENABLE(libusb, [ --enable-libusb use libusb for USB printing])
222
223 LIBUSB=""
224 USBQUIRKS=""
225 AC_SUBST(LIBUSB)
226 AC_SUBST(USBQUIRKS)
227
228 if test "x$PKGCONFIG" != x; then
229 if test x$enable_libusb != xno -a $host_os_name != darwin; then
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`"
236 USBQUIRKS="\$(DATADIR)/usb"
237 else
238 AC_MSG_RESULT(no)
239 if test x$enable_libusb = xyes; then
240 AC_MSG_ERROR(libusb required for --enable-libusb.)
241 fi
242 fi
243 fi
244 elif test x$enable_libusb = xyes; then
245 AC_MSG_ERROR(Need pkg-config to enable libusb support.)
246 fi
247
248 dnl See if we have libwrap for TCP wrappers support...
249 AC_ARG_ENABLE(tcp_wrappers, [ --enable-tcp-wrappers use libwrap for TCP wrappers support])
250
251 LIBWRAP=""
252 AC_SUBST(LIBWRAP)
253
254 if 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")])
259 fi
260
261 dnl ZLIB
262 INSTALL_GZIP=""
263 LIBZ=""
264 AC_CHECK_HEADER(zlib.h,
265 AC_CHECK_LIB(z, gzgets,
266 AC_DEFINE(HAVE_LIBZ)
267 LIBZ="-lz"
268 LIBS="$LIBS -lz"
269 AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_INFLATECOPY))
270 if test "x$GZIP" != z; then
271 INSTALL_GZIP="-z"
272 fi))
273 AC_SUBST(INSTALL_GZIP)
274 AC_SUBST(LIBZ)
275
276 dnl Flags for "ar" command...
277 case $host_os_name in
278 darwin* | *bsd*)
279 ARFLAGS="-rcv"
280 ;;
281 *)
282 ARFLAGS="crvs"
283 ;;
284 esac
285
286 AC_SUBST(ARFLAGS)
287
288 dnl Prep libraries specifically for cupsd and backends...
289 BACKLIBS=""
290 SERVERLIBS=""
291 AC_SUBST(BACKLIBS)
292 AC_SUBST(SERVERLIBS)
293
294 dnl See if we have POSIX ACL support...
295 SAVELIBS="$LIBS"
296 LIBS=""
297 AC_ARG_ENABLE(acl, [ --enable-acl build with POSIX ACL support])
298 if test "x$enable_acl" != xno; then
299 AC_SEARCH_LIBS(acl_init, acl, AC_DEFINE(HAVE_ACL_INIT))
300 SERVERLIBS="$SERVERLIBS $LIBS"
301 fi
302 LIBS="$SAVELIBS"
303
304 dnl Check for DBUS support
305 AC_ARG_ENABLE(dbus, [ --disable-dbus build without DBUS support])
306 AC_ARG_WITH(dbusdir, [ --with-dbusdir set DBUS configuration directory ],
307 DBUSDIR="$withval")
308
309 DBUSDIR=""
310 DBUS_NOTIFIER=""
311 DBUS_NOTIFIERLIBS=""
312
313 if test "x$enable_dbus" != xno -a "x$PKGCONFIG" != x -a "x$host_os_name" != xdarwin; then
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))
326 AC_CHECK_FUNC(dbus_threads_init,
327 AC_DEFINE(HAVE_DBUS_THREADS_INIT))
328 LIBS="$SAVELIBS"
329 if test -d /etc/dbus-1; then
330 DBUSDIR="/etc/dbus-1"
331 fi
332 else
333 AC_MSG_RESULT(no)
334 fi
335 fi
336
337 AC_SUBST(DBUSDIR)
338 AC_SUBST(DBUS_NOTIFIER)
339 AC_SUBST(DBUS_NOTIFIERLIBS)
340
341 dnl Extra platform-specific libraries...
342 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@SYSTEM"
343 CUPS_DEFAULT_SYSTEM_AUTHKEY=""
344 CUPS_SYSTEM_AUTHKEY=""
345 INSTALLXPC=""
346
347 case $host_os_name in
348 darwin*)
349 BACKLIBS="$BACKLIBS -framework IOKit"
350 SERVERLIBS="$SERVERLIBS -framework IOKit -weak_framework ApplicationServices"
351 LIBS="-framework SystemConfiguration -framework CoreFoundation -framework Security $LIBS"
352
353 dnl Check for framework headers...
354 AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h,AC_DEFINE(HAVE_APPLICATIONSERVICES_H))
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
359 dnl Check for dynamic store function...
360 AC_CHECK_FUNCS(SCDynamicStoreCopyComputerName)
361
362 dnl Check for the new membership functions in MacOSX 10.4...
363 AC_CHECK_HEADER(membership.h,AC_DEFINE(HAVE_MEMBERSHIP_H))
364 AC_CHECK_HEADER(membershipPriv.h,AC_DEFINE(HAVE_MEMBERSHIPPRIV_H))
365 AC_CHECK_FUNCS(mbr_uid_to_uuid)
366
367 dnl Need <dlfcn.h> header...
368 AC_CHECK_HEADER(dlfcn.h,AC_DEFINE(HAVE_DLFCN_H))
369
370 dnl Check for notify_post support
371 AC_CHECK_HEADER(notify.h,AC_DEFINE(HAVE_NOTIFY_H))
372 AC_CHECK_FUNCS(notify_post)
373
374 dnl Check for Authorization Services support
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")
381
382 AC_CHECK_HEADER(Security/Authorization.h, [
383 AC_DEFINE(HAVE_AUTHORIZATION_H)
384
385 if test "x$default_adminkey" != xdefault; then
386 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey $default_adminkey"
387 CUPS_DEFAULT_SYSTEM_AUTHKEY="$default_adminkey"
388 else
389 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.print.admin"
390 CUPS_DEFAULT_SYSTEM_AUTHKEY="system.print.admin"
391 fi
392
393 if test "x$default_operkey" != xdefault; then
394 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY($default_operkey) @admin @lpadmin"
395 else
396 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.operator) @admin @lpadmin"
397 fi])
398 AC_CHECK_HEADER(Security/SecBasePriv.h,AC_DEFINE(HAVE_SECBASEPRIV_H))
399
400 dnl Check for sandbox/Seatbelt support
401 if test $host_os_version -ge 100; then
402 AC_CHECK_HEADER(sandbox.h,AC_DEFINE(HAVE_SANDBOX_H))
403 fi
404 if test $host_os_version -ge 110 -a $host_os_version -lt 120; then
405 # Broken public headers in 10.7.x...
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
413 fi
414
415 dnl Check for XPC support
416 AC_CHECK_HEADER(xpc/xpc.h,
417 AC_DEFINE(HAVE_XPC)
418 INSTALLXPC="install-xpc")
419 AC_CHECK_HEADER(xpc/private.h,
420 AC_DEFINE(HAVE_XPC_PRIVATE_H))
421 ;;
422 esac
423
424 AC_SUBST(CUPS_DEFAULT_PRINTOPERATOR_AUTH)
425 AC_DEFINE_UNQUOTED(CUPS_DEFAULT_PRINTOPERATOR_AUTH, "$CUPS_DEFAULT_PRINTOPERATOR_AUTH")
426 AC_DEFINE_UNQUOTED(CUPS_DEFAULT_SYSTEM_AUTHKEY, "$CUPS_DEFAULT_SYSTEM_AUTHKEY")
427 AC_SUBST(CUPS_SYSTEM_AUTHKEY)
428 AC_SUBST(INSTALLXPC)
429
430 dnl Check for build components
431 COMPONENTS="all"
432
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")
437
438 case "$COMPONENTS" in
439 all)
440 BUILDDIRS="filter backend berkeley cgi-bin monitor notifier ppdc scheduler systemv conf data desktop locale man doc examples templates"
441 ;;
442
443 core)
444 BUILDDIRS="data locale"
445 ;;
446
447 *)
448 AC_MSG_ERROR([Bad build component "$COMPONENT" specified!])
449 ;;
450 esac
451
452 AC_SUBST(BUILDDIRS)