]> git.ipfire.org Git - thirdparty/cups.git/blob - config-scripts/cups-common.m4
Merge changes from CUPS 1.6svn-r10267.
[thirdparty/cups.git] / config-scripts / cups-common.m4
1 dnl
2 dnl "$Id: cups-common.m4 8781 2009-08-28 17:34:54Z mike $"
3 dnl
4 dnl Common configuration stuff for CUPS.
5 dnl
6 dnl Copyright 2007-2011 by Apple Inc.
7 dnl Copyright 1997-2007 by Easy Software Products, all rights reserved.
8 dnl
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/".
14 dnl
15
16 dnl We need at least autoconf 2.60...
17 AC_PREREQ(2.60)
18
19 dnl Set the name of the config header file...
20 AC_CONFIG_HEADER(config.h)
21
22 dnl Version number information...
23 CUPS_VERSION="1.6svn"
24 CUPS_REVISION=""
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'`"
27 fi
28 CUPS_BUILD="cups-$CUPS_VERSION"
29
30 AC_ARG_WITH(cups_build, [ --with-cups-build set "cups-config --build" string ],
31 CUPS_BUILD="$withval")
32
33 AC_SUBST(CUPS_VERSION)
34 AC_SUBST(CUPS_REVISION)
35 AC_SUBST(CUPS_BUILD)
36 AC_DEFINE_UNQUOTED(CUPS_SVERSION, "CUPS v$CUPS_VERSION$CUPS_REVISION")
37 AC_DEFINE_UNQUOTED(CUPS_MINIMAL, "CUPS/$CUPS_VERSION$CUPS_REVISION")
38
39 dnl Default compiler flags...
40 CFLAGS="${CFLAGS:=}"
41 CPPFLAGS="${CPPFLAGS:=}"
42 CXXFLAGS="${CXXFLAGS:=}"
43 LDFLAGS="${LDFLAGS:=}"
44
45 dnl Checks for programs...
46 AC_PROG_AWK
47 AC_PROG_CC
48 AC_PROG_CPP
49 AC_PROG_CXX
50 AC_PROG_RANLIB
51 AC_PATH_PROG(AR,ar)
52 AC_PATH_PROG(CHMOD,chmod)
53 AC_PATH_PROG(HTMLDOC,htmldoc)
54 AC_PATH_PROG(LD,ld)
55 AC_PATH_PROG(LN,ln)
56 AC_PATH_PROG(MV,mv)
57 AC_PATH_PROG(RM,rm)
58 AC_PATH_PROG(RMDIR,rmdir)
59 AC_PATH_PROG(SED,sed)
60 AC_PATH_PROG(XDGOPEN,xdg-open)
61 if test "x$XDGOPEN" = x; then
62 CUPS_HTMLVIEW="htmlview"
63 else
64 CUPS_HTMLVIEW="$XDGOPEN"
65 fi
66 AC_SUBST(CUPS_HTMLVIEW)
67
68 AC_MSG_CHECKING(for install-sh script)
69 INSTALL="`pwd`/install-sh"
70 AC_SUBST(INSTALL)
71 AC_MSG_RESULT(using $INSTALL)
72
73 if test "x$AR" = x; then
74 AC_MSG_ERROR([Unable to find required library archive command.])
75 fi
76 if test "x$CC" = x; then
77 AC_MSG_ERROR([Unable to find required C compiler command.])
78 fi
79
80 dnl Static library option...
81 INSTALLSTATIC=""
82 AC_ARG_ENABLE(static, [ --enable-static install static libraries])
83
84 if test x$enable_static = xyes; then
85 echo Installing static libraries...
86 INSTALLSTATIC="installstatic"
87 fi
88
89 AC_SUBST(INSTALLSTATIC)
90
91 dnl Check for pkg-config, which is used for some other tests later on...
92 AC_PATH_PROG(PKGCONFIG, pkg-config)
93
94 dnl Check for libraries...
95 AC_SEARCH_LIBS(fmod, m)
96 AC_SEARCH_LIBS(crypt, crypt)
97 AC_SEARCH_LIBS(getspent, sec gen)
98
99 LIBMALLOC=""
100 AC_ARG_ENABLE(mallinfo, [ --enable-mallinfo build with malloc debug logging])
101
102 if test x$enable_mallinfo = xyes; then
103 SAVELIBS="$LIBS"
104 LIBS=""
105 AC_SEARCH_LIBS(mallinfo, malloc, AC_DEFINE(HAVE_MALLINFO))
106 LIBMALLOC="$LIBS"
107 LIBS="$SAVELIBS"
108 fi
109
110 AC_SUBST(LIBMALLOC)
111
112 dnl Check for libpaper support...
113 AC_ARG_ENABLE(libpaper, [ --enable-libpaper build with libpaper support])
114
115 if test x$enable_libpaper = xyes; then
116 AC_CHECK_LIB(paper,systempapername,
117 AC_DEFINE(HAVE_LIBPAPER)
118 LIBPAPER="-lpaper",
119 LIBPAPER="")
120 else
121 LIBPAPER=""
122 fi
123 AC_SUBST(LIBPAPER)
124
125 dnl Checks for header files.
126 AC_HEADER_STDC
127 AC_CHECK_HEADER(stdlib.h,AC_DEFINE(HAVE_STDLIB_H))
128 AC_CHECK_HEADER(crypt.h,AC_DEFINE(HAVE_CRYPT_H))
129 AC_CHECK_HEADER(langinfo.h,AC_DEFINE(HAVE_LANGINFO_H))
130 AC_CHECK_HEADER(malloc.h,AC_DEFINE(HAVE_MALLOC_H))
131 AC_CHECK_HEADER(shadow.h,AC_DEFINE(HAVE_SHADOW_H))
132 AC_CHECK_HEADER(string.h,AC_DEFINE(HAVE_STRING_H))
133 AC_CHECK_HEADER(strings.h,AC_DEFINE(HAVE_STRINGS_H))
134 AC_CHECK_HEADER(bstring.h,AC_DEFINE(HAVE_BSTRING_H))
135 AC_CHECK_HEADER(usersec.h,AC_DEFINE(HAVE_USERSEC_H))
136 AC_CHECK_HEADER(sys/ioctl.h,AC_DEFINE(HAVE_SYS_IOCTL_H))
137 AC_CHECK_HEADER(sys/param.h,AC_DEFINE(HAVE_SYS_PARAM_H))
138 AC_CHECK_HEADER(sys/ucred.h,AC_DEFINE(HAVE_SYS_UCRED_H))
139 AC_CHECK_HEADER(scsi/sg.h,AC_DEFINE(HAVE_SCSI_SG_H))
140
141 dnl Checks for iconv.h and iconv_open
142 AC_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
150 dnl Checks for Mini-XML (www.minixml.org)...
151 LIBMXML=""
152 AC_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")
158 AC_SUBST(LIBMXML)
159
160 dnl Checks for statfs and its many headers...
161 AC_CHECK_HEADER(sys/mount.h,AC_DEFINE(HAVE_SYS_MOUNT_H))
162 AC_CHECK_HEADER(sys/statfs.h,AC_DEFINE(HAVE_SYS_STATFS_H))
163 AC_CHECK_HEADER(sys/statvfs.h,AC_DEFINE(HAVE_SYS_STATVFS_H))
164 AC_CHECK_HEADER(sys/vfs.h,AC_DEFINE(HAVE_SYS_VFS_H))
165 AC_CHECK_FUNCS(statfs statvfs)
166
167 dnl Checks for string functions.
168 AC_CHECK_FUNCS(strdup strlcat strlcpy)
169 if test "$uname" = "HP-UX" -a "$uversion" = "1020"; then
170 echo Forcing snprintf emulation for HP-UX.
171 else
172 AC_CHECK_FUNCS(snprintf vsnprintf)
173 fi
174
175 dnl Check for random number functions...
176 AC_CHECK_FUNCS(random lrand48 arc4random)
177
178 dnl Check for geteuid function.
179 AC_CHECK_FUNCS(geteuid)
180
181 dnl Check for setpgid function.
182 AC_CHECK_FUNCS(setpgid)
183
184 dnl Check for vsyslog function.
185 AC_CHECK_FUNCS(vsyslog)
186
187 dnl Checks for signal functions.
188 case "$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 ;;
196 esac
197
198 AC_CHECK_FUNCS(sigaction)
199
200 dnl Checks for wait functions.
201 AC_CHECK_FUNCS(waitpid wait3)
202
203 dnl See if the tm structure has the tm_gmtoff member...
204 AC_MSG_CHECKING(for tm_gmtoff member in tm structure)
205 AC_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
211 dnl See if the stat structure has the st_gen member...
212 AC_MSG_CHECKING(for st_gen member in stat structure)
213 AC_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
219 dnl See if we have the removefile(3) function for securely removing files
220 AC_CHECK_FUNCS(removefile)
221
222 dnl See if we have libusb...
223 AC_ARG_ENABLE(libusb, [ --enable-libusb use libusb for USB printing])
224
225 LIBUSB=""
226 AC_SUBST(LIBUSB)
227
228 if test x$enable_libusb = xyes; then
229 check_libusb=yes
230 elif test x$enable_libusb != xno -a $uname != Darwin; then
231 check_libusb=yes
232 else
233 check_libusb=no
234 fi
235
236 if 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
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 LIBZ=""
263 AC_CHECK_HEADER(zlib.h,
264 AC_CHECK_LIB(z, gzgets,
265 AC_DEFINE(HAVE_LIBZ)
266 LIBZ="-lz"
267 LIBS="$LIBS -lz"))
268 AC_SUBST(LIBZ)
269
270 dnl Flags for "ar" command...
271 case $uname in
272 Darwin* | *BSD*)
273 ARFLAGS="-rcv"
274 ;;
275 *)
276 ARFLAGS="crvs"
277 ;;
278 esac
279
280 AC_SUBST(ARFLAGS)
281
282 dnl Prep libraries specifically for cupsd and backends...
283 BACKLIBS=""
284 SERVERLIBS=""
285 AC_SUBST(BACKLIBS)
286 AC_SUBST(SERVERLIBS)
287
288 dnl See if we have POSIX ACL support...
289 SAVELIBS="$LIBS"
290 LIBS=""
291 AC_ARG_ENABLE(acl, [ --enable-acl build with POSIX ACL support])
292 if test "x$enable_acl" != xno; then
293 AC_SEARCH_LIBS(acl_init, acl, AC_DEFINE(HAVE_ACL_INIT))
294 SERVERLIBS="$SERVERLIBS $LIBS"
295 fi
296 LIBS="$SAVELIBS"
297
298 dnl Check for DBUS support
299 if test -d /etc/dbus-1; then
300 DBUSDIR="/etc/dbus-1"
301 else
302 DBUSDIR=""
303 fi
304
305 AC_ARG_ENABLE(dbus, [ --enable-dbus build with DBUS support])
306 AC_ARG_WITH(dbusdir, [ --with-dbusdir set DBUS configuration directory ],
307 DBUSDIR="$withval")
308
309 DBUS_NOTIFIER=""
310 DBUS_NOTIFIERLIBS=""
311
312 if 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)
328 fi
329 fi
330
331 AC_SUBST(DBUSDIR)
332 AC_SUBST(DBUS_NOTIFIER)
333 AC_SUBST(DBUS_NOTIFIERLIBS)
334
335 dnl Extra platform-specific libraries...
336 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@SYSTEM"
337 CUPS_SYSTEM_AUTHKEY=""
338 INSTALLXPC=""
339
340 case $uname in
341 Darwin*)
342 BACKLIBS="$BACKLIBS -framework IOKit"
343 SERVERLIBS="$SERVERLIBS -framework IOKit -weak_framework ApplicationServices"
344 LIBS="-framework SystemConfiguration -framework CoreFoundation -framework Security $LIBS"
345
346 dnl Check for framework headers...
347 AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h,AC_DEFINE(HAVE_APPLICATIONSERVICES_H))
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))
351 AC_CHECK_HEADER(IOKit/pwr_mgt/IOPMLibPrivate.h,AC_DEFINE(HAVE_IOKIT_PWR_MGT_IOPMLIBPRIVATE_H))
352
353 dnl Check for dynamic store function...
354 AC_CHECK_FUNCS(SCDynamicStoreCopyComputerName)
355
356 dnl Check for new ColorSync APIs...
357 SAVELIBS="$LIBS"
358 LIBS="$LIBS -framework ApplicationServices"
359 AC_CHECK_FUNCS(ColorSyncRegisterDevice)
360 LIBS="$SAVELIBS"
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 Check for the vproc_transaction_begin/end stuff...
368 AC_CHECK_FUNCS(vproc_transaction_begin)
369
370 dnl Need <dlfcn.h> header...
371 AC_CHECK_HEADER(dlfcn.h,AC_DEFINE(HAVE_DLFCN_H))
372
373 dnl Check for notify_post support
374 AC_CHECK_HEADER(notify.h,AC_DEFINE(HAVE_NOTIFY_H))
375 AC_CHECK_FUNCS(notify_post)
376
377 dnl Check for Authorization Services support
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")
384
385 AC_CHECK_HEADER(Security/Authorization.h, [
386 AC_DEFINE(HAVE_AUTHORIZATION_H)
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"
392 else
393 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.preferences"
394 fi
395
396 if test "x$default_operkey" != xdefault; then
397 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY($default_operkey) @admin @lpadmin"
398 elif grep -q system.print.operator /etc/authorization; then
399 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.operator) @admin @lpadmin"
400 else
401 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.admin) @admin @lpadmin"
402 fi])
403 AC_CHECK_HEADER(Security/SecBasePriv.h,AC_DEFINE(HAVE_SECBASEPRIV_H))
404
405 dnl Check for sandbox/Seatbelt support
406 if test $uversion -ge 100; then
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
418 fi
419
420 dnl Check for XPC support
421 AC_CHECK_HEADER(xpc/xpc.h,
422 AC_DEFINE(HAVE_XPC)
423 INSTALLXPC="install-xpc")
424 ;;
425 esac
426
427 AC_SUBST(CUPS_DEFAULT_PRINTOPERATOR_AUTH)
428 AC_DEFINE_UNQUOTED(CUPS_DEFAULT_PRINTOPERATOR_AUTH, "$CUPS_DEFAULT_PRINTOPERATOR_AUTH")
429 AC_SUBST(CUPS_SYSTEM_AUTHKEY)
430 AC_SUBST(INSTALLXPC)
431
432 dnl Check for build components
433 COMPONENTS="all"
434
435 AC_ARG_WITH(components, [ --with-components set components to build:
436 - "all" (default) builds everything
437 - "core" builds libcups and ipptool],
438 COMPONENTS="$withval")
439
440 case "$COMPONENTS" in
441 all)
442 BUILDDIRS="filter backend berkeley cgi-bin monitor notifier ppdc scheduler systemv conf data desktop locale man doc examples templates"
443 ;;
444
445 core)
446 BUILDDIRS="data locale"
447 ;;
448
449 *)
450 AC_MSG_ERROR([Bad build component "$COMPONENT" specified!])
451 ;;
452 esac
453
454 AC_SUBST(BUILDDIRS)
455
456 dnl
457 dnl End of "$Id: cups-common.m4 8781 2009-08-28 17:34:54Z mike $".
458 dnl