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