a5de94fd2fbf463e14f029806a56c8203c951c7b
[platform/upstream/cups.git] / config-scripts / cups-common.m4
1 dnl
2 dnl "$Id: cups-common.m4 10317 2012-03-01 00:05:55Z mike $"
3 dnl
4 dnl   Common configuration stuff for CUPS.
5 dnl
6 dnl   Copyright 2007-2012 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.5.3
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(GZIP,gzip)
54 AC_PATH_PROG(HTMLDOC,htmldoc)
55 AC_PATH_PROG(LD,ld)
56 AC_PATH_PROG(LN,ln)
57 AC_PATH_PROG(MV,mv)
58 AC_PATH_PROG(RM,rm)
59 AC_PATH_PROG(RMDIR,rmdir)
60 AC_PATH_PROG(SED,sed)
61 AC_PATH_PROG(XDGOPEN,xdg-open)
62 if test "x$XDGOPEN" = x; then
63         CUPS_HTMLVIEW="htmlview"
64 else
65         CUPS_HTMLVIEW="$XDGOPEN"
66 fi
67 AC_SUBST(CUPS_HTMLVIEW)
68
69 AC_MSG_CHECKING(for install-sh script)
70 INSTALL="`pwd`/install-sh"
71 AC_SUBST(INSTALL)
72 AC_MSG_RESULT(using $INSTALL)
73
74 if test "x$AR" = x; then
75         AC_MSG_ERROR([Unable to find required library archive command.])
76 fi
77 if test "x$CC" = x; then
78         AC_MSG_ERROR([Unable to find required C compiler command.])
79 fi
80
81 dnl Static library option...
82 INSTALLSTATIC=""
83 AC_ARG_ENABLE(static, [  --enable-static         install static libraries])
84
85 if test x$enable_static = xyes; then
86         echo Installing static libraries...
87         INSTALLSTATIC="installstatic"
88 fi
89
90 AC_SUBST(INSTALLSTATIC)
91
92 dnl Check for pkg-config, which is used for some other tests later on...
93 AC_PATH_PROG(PKGCONFIG, pkg-config)
94
95 dnl Check for libraries...
96 AC_SEARCH_LIBS(fmod, m)
97 AC_SEARCH_LIBS(crypt, crypt)
98 AC_SEARCH_LIBS(getspent, sec gen)
99
100 LIBMALLOC=""
101 AC_ARG_ENABLE(mallinfo, [  --enable-mallinfo       build with malloc debug logging])
102
103 if test x$enable_mallinfo = xyes; then
104         SAVELIBS="$LIBS"
105         LIBS=""
106         AC_SEARCH_LIBS(mallinfo, malloc, AC_DEFINE(HAVE_MALLINFO))
107         LIBMALLOC="$LIBS"
108         LIBS="$SAVELIBS"
109 fi
110
111 AC_SUBST(LIBMALLOC)
112
113 dnl Check for libpaper support...
114 AC_ARG_ENABLE(libpaper, [  --enable-libpaper       build with libpaper support])
115
116 if test x$enable_libpaper = xyes; then
117         AC_CHECK_LIB(paper,systempapername,
118                 AC_DEFINE(HAVE_LIBPAPER)
119                 LIBPAPER="-lpaper",
120                 LIBPAPER="")
121 else
122         LIBPAPER=""
123 fi
124 AC_SUBST(LIBPAPER)
125
126 dnl Checks for header files.
127 AC_HEADER_STDC
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 statfs and its many headers...
151 AC_CHECK_HEADER(sys/mount.h,AC_DEFINE(HAVE_SYS_MOUNT_H))
152 AC_CHECK_HEADER(sys/statfs.h,AC_DEFINE(HAVE_SYS_STATFS_H))
153 AC_CHECK_HEADER(sys/statvfs.h,AC_DEFINE(HAVE_SYS_STATVFS_H))
154 AC_CHECK_HEADER(sys/vfs.h,AC_DEFINE(HAVE_SYS_VFS_H))
155 AC_CHECK_FUNCS(statfs statvfs)
156
157 dnl Checks for string functions.
158 AC_CHECK_FUNCS(strdup strlcat strlcpy)
159 if test "$uname" = "HP-UX" -a "$uversion" = "1020"; then
160         echo Forcing snprintf emulation for HP-UX.
161 else
162         AC_CHECK_FUNCS(snprintf vsnprintf)
163 fi
164
165 dnl Check for random number functions...
166 AC_CHECK_FUNCS(random lrand48 arc4random)
167
168 dnl Check for geteuid function.
169 AC_CHECK_FUNCS(geteuid)
170
171 dnl Check for setpgid function.
172 AC_CHECK_FUNCS(setpgid)
173
174 dnl Check for vsyslog function.
175 AC_CHECK_FUNCS(vsyslog)
176
177 dnl Checks for signal functions.
178 case "$uname" in
179         Linux | GNU)
180                 # Do not use sigset on Linux or GNU HURD
181                 ;;
182         *)
183                 # Use sigset on other platforms, if available
184                 AC_CHECK_FUNCS(sigset)
185                 ;;
186 esac
187
188 AC_CHECK_FUNCS(sigaction)
189
190 dnl Checks for wait functions.
191 AC_CHECK_FUNCS(waitpid wait3)
192
193 dnl See if the tm structure has the tm_gmtoff member...
194 AC_MSG_CHECKING(for tm_gmtoff member in tm structure)
195 AC_TRY_COMPILE([#include <time.h>],[struct tm t;
196         int o = t.tm_gmtoff;],
197         AC_MSG_RESULT(yes)
198         AC_DEFINE(HAVE_TM_GMTOFF),
199         AC_MSG_RESULT(no))
200
201 dnl See if the stat structure has the st_gen member...
202 AC_MSG_CHECKING(for st_gen member in stat structure)
203 AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat t;
204         int o = t.st_gen;],
205         AC_MSG_RESULT(yes)
206         AC_DEFINE(HAVE_ST_GEN),
207         AC_MSG_RESULT(no))
208
209 dnl See if we have the removefile(3) function for securely removing files
210 AC_CHECK_FUNCS(removefile)
211
212 dnl See if we have libusb...
213 AC_ARG_ENABLE(libusb, [  --enable-libusb         use libusb for USB printing])
214
215 LIBUSB=""
216 AC_SUBST(LIBUSB)
217
218 if test "x$PKGCONFIG" != x; then
219         if test x$enable_libusb = xyes -o $uname != Darwin; then
220                 AC_MSG_CHECKING(for libusb-1.0)
221                 if $PKGCONFIG --exists libusb-1.0; then
222                         AC_MSG_RESULT(yes)
223                         AC_DEFINE(HAVE_LIBUSB)
224                         CFLAGS="$CFLAGS `$PKGCONFIG --cflags libusb-1.0`"
225                         LIBUSB="`$PKGCONFIG --libs libusb-1.0`"
226                 else
227                         AC_MSG_RESULT(no)
228                 fi
229         fi
230 elif test x$enable_libusb = xyes; then
231         AC_MSG_ERROR(Need pkg-config to enable libusb support.)
232 fi
233
234 dnl See if we have libwrap for TCP wrappers support...
235 AC_ARG_ENABLE(tcp_wrappers, [  --enable-tcp-wrappers   use libwrap for TCP wrappers support])
236
237 LIBWRAP=""
238 AC_SUBST(LIBWRAP)
239
240 if test x$enable_tcp_wrappers = xyes; then
241         AC_CHECK_LIB(wrap, hosts_access,[
242                 AC_CHECK_HEADER(tcpd.h,
243                         AC_DEFINE(HAVE_TCPD_H)
244                         LIBWRAP="-lwrap")])
245 fi
246
247 dnl Flags for "ar" command...
248 case $uname in
249         Darwin* | *BSD*)
250                 ARFLAGS="-rcv"
251                 ;;
252         *)
253                 ARFLAGS="crvs"
254                 ;;
255 esac
256
257 AC_SUBST(ARFLAGS)
258
259 dnl Prep libraries specifically for cupsd and backends...
260 BACKLIBS=""
261 SERVERLIBS=""
262 AC_SUBST(BACKLIBS)
263 AC_SUBST(SERVERLIBS)
264
265 dnl See if we have POSIX ACL support...
266 SAVELIBS="$LIBS"
267 LIBS=""
268 AC_ARG_ENABLE(acl, [  --enable-acl            build with POSIX ACL support])
269 if test "x$enable_acl" != xno; then
270         AC_SEARCH_LIBS(acl_init, acl, AC_DEFINE(HAVE_ACL_INIT))
271         SERVERLIBS="$SERVERLIBS $LIBS"
272 fi
273 LIBS="$SAVELIBS"
274
275 dnl Check for DBUS support
276 if test -d /etc/dbus-1; then
277         DBUSDIR="/etc/dbus-1"
278 else
279         DBUSDIR=""
280 fi
281
282 AC_ARG_ENABLE(dbus, [  --enable-dbus           build with DBUS support])
283 AC_ARG_WITH(dbusdir, [  --with-dbusdir          set DBUS configuration directory ],
284         DBUSDIR="$withval")
285
286 DBUS_NOTIFIER=""
287 DBUS_NOTIFIERLIBS=""
288
289 if test "x$enable_dbus" != xno -a "x$PKGCONFIG" != x; then
290         AC_MSG_CHECKING(for DBUS)
291         if $PKGCONFIG --exists dbus-1; then
292                 AC_MSG_RESULT(yes)
293                 AC_DEFINE(HAVE_DBUS)
294                 CFLAGS="$CFLAGS `$PKGCONFIG --cflags dbus-1` -DDBUS_API_SUBJECT_TO_CHANGE"
295                 SERVERLIBS="$SERVERLIBS `$PKGCONFIG --libs dbus-1`"
296                 DBUS_NOTIFIER="dbus"
297                 DBUS_NOTIFIERLIBS="`$PKGCONFIG --libs dbus-1`"
298                 SAVELIBS="$LIBS"
299                 LIBS="$LIBS $DBUS_NOTIFIERLIBS"
300                 AC_CHECK_FUNC(dbus_message_iter_init_append,
301                               AC_DEFINE(HAVE_DBUS_MESSAGE_ITER_INIT_APPEND))
302                 LIBS="$SAVELIBS"
303         else
304                 AC_MSG_RESULT(no)
305         fi
306 fi
307
308 AC_SUBST(DBUSDIR)
309 AC_SUBST(DBUS_NOTIFIER)
310 AC_SUBST(DBUS_NOTIFIERLIBS)
311
312 dnl Extra platform-specific libraries...
313 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@SYSTEM"
314 CUPS_SYSTEM_AUTHKEY=""
315 INSTALLXPC=""
316 LEGACY_BACKENDS="parallel"
317
318 case $uname in
319         Darwin*)
320                 LEGACY_BACKENDS=""
321                 BACKLIBS="$BACKLIBS -framework IOKit"
322                 SERVERLIBS="$SERVERLIBS -framework IOKit -weak_framework ApplicationServices"
323                 LIBS="-framework SystemConfiguration -framework CoreFoundation -framework Security $LIBS"
324
325                 dnl Check for framework headers...
326                 AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h,AC_DEFINE(HAVE_APPLICATIONSERVICES_H))
327                 AC_CHECK_HEADER(CoreFoundation/CoreFoundation.h,AC_DEFINE(HAVE_COREFOUNDATION_H))
328                 AC_CHECK_HEADER(CoreFoundation/CFPriv.h,AC_DEFINE(HAVE_CFPRIV_H))
329                 AC_CHECK_HEADER(CoreFoundation/CFBundlePriv.h,AC_DEFINE(HAVE_CFBUNDLEPRIV_H))
330                 AC_CHECK_HEADER(IOKit/pwr_mgt/IOPMLibPrivate.h,AC_DEFINE(HAVE_IOKIT_PWR_MGT_IOPMLIBPRIVATE_H))
331
332                 dnl Check for dynamic store function...
333                 AC_CHECK_FUNCS(SCDynamicStoreCopyComputerName)
334
335                 dnl Check for new ColorSync APIs...
336                 SAVELIBS="$LIBS"
337                 LIBS="$LIBS -framework ApplicationServices"
338                 AC_CHECK_FUNCS(ColorSyncRegisterDevice)
339                 LIBS="$SAVELIBS"
340
341                 dnl Check for the new membership functions in MacOSX 10.4...
342                 AC_CHECK_HEADER(membership.h,AC_DEFINE(HAVE_MEMBERSHIP_H))
343                 AC_CHECK_HEADER(membershipPriv.h,AC_DEFINE(HAVE_MEMBERSHIPPRIV_H))
344                 AC_CHECK_FUNCS(mbr_uid_to_uuid)
345
346                 dnl Check for the vproc_transaction_begin/end stuff...
347                 AC_CHECK_FUNCS(vproc_transaction_begin)
348
349                 dnl Need <dlfcn.h> header...
350                 AC_CHECK_HEADER(dlfcn.h,AC_DEFINE(HAVE_DLFCN_H))
351
352                 dnl Check for notify_post support
353                 AC_CHECK_HEADER(notify.h,AC_DEFINE(HAVE_NOTIFY_H))
354                 AC_CHECK_FUNCS(notify_post)
355
356                 dnl Check for Authorization Services support
357                 AC_ARG_WITH(adminkey, [  --with-adminkey         set the default SystemAuthKey value],
358                         default_adminkey="$withval",
359                         default_adminkey="default")
360                 AC_ARG_WITH(operkey, [  --with-operkey          set the default operator @AUTHKEY value],
361                         default_operkey="$withval",
362                         default_operkey="default")
363
364                 AC_CHECK_HEADER(Security/Authorization.h, [
365                         AC_DEFINE(HAVE_AUTHORIZATION_H)
366
367                         if test "x$default_adminkey" != xdefault; then
368                                 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey $default_adminkey"
369                         elif grep -q system.print.operator /etc/authorization; then
370                                 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.print.admin"
371                         else
372                                 CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.preferences"
373                         fi
374
375                         if test "x$default_operkey" != xdefault; then
376                                 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY($default_operkey) @admin @lpadmin"
377                         elif grep -q system.print.operator /etc/authorization; then
378                                 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.operator) @admin @lpadmin"
379                         else
380                                 CUPS_DEFAULT_PRINTOPERATOR_AUTH="@AUTHKEY(system.print.admin) @admin @lpadmin"
381                         fi])
382                 AC_CHECK_HEADER(Security/SecBasePriv.h,AC_DEFINE(HAVE_SECBASEPRIV_H))
383
384                 dnl Check for sandbox/Seatbelt support
385                 if test $uversion -ge 100; then
386                         AC_CHECK_HEADER(sandbox.h,AC_DEFINE(HAVE_SANDBOX_H))
387                 fi
388                 if test $uversion -ge 110; then
389                         # Broken public headers in 10.7...
390                         AC_MSG_CHECKING(for sandbox/private.h presence)
391                         if test -f /usr/local/include/sandbox/private.h; then
392                                 AC_MSG_RESULT(yes)
393                         else
394                                 AC_MSG_RESULT(no)
395                                 AC_MSG_ERROR(Run 'sudo mkdir -p /usr/local/include/sandbox' and 'sudo touch /usr/local/include/sandbox/private.h' to build CUPS.)
396                         fi
397                 fi
398
399                 dnl Check for XPC support
400                 AC_CHECK_HEADER(xpc/xpc.h,
401                         AC_DEFINE(HAVE_XPC)
402                         INSTALLXPC="install-xpc")
403                 ;;
404 esac
405
406 AC_SUBST(CUPS_DEFAULT_PRINTOPERATOR_AUTH)
407 AC_DEFINE_UNQUOTED(CUPS_DEFAULT_PRINTOPERATOR_AUTH, "$CUPS_DEFAULT_PRINTOPERATOR_AUTH")
408 AC_SUBST(CUPS_SYSTEM_AUTHKEY)
409 AC_SUBST(INSTALLXPC)
410 AC_SUBST(LEGACY_BACKENDS)
411
412 dnl Check for build components
413 COMPONENTS="all"
414
415 AC_ARG_WITH(components, [  --with-components       set components to build:
416                             - "all" (default) builds everything
417                             - "core" builds libcups and ipptool],
418         COMPONENTS="$withval")
419
420 case "$COMPONENTS" in
421         all)
422                 BUILDDIRS="filter backend berkeley cgi-bin driver monitor notifier ppdc scheduler systemv conf data desktop locale man doc examples templates"
423                 ;;
424
425         core)
426                 BUILDDIRS="data locale"
427                 ;;
428
429         *)
430                 AC_MSG_ERROR([Bad build component "$COMPONENT" specified!])
431                 ;;
432 esac
433
434 AC_SUBST(BUILDDIRS)
435
436 dnl
437 dnl End of "$Id: cups-common.m4 10317 2012-03-01 00:05:55Z mike $".
438 dnl