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