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