1# Process this file with autoconf to create configure.
2
3AC_PREREQ([2.65])
4
5# ====================
6# Version informations
7# ====================
8m4_define([cups_filters_version_major],[1])
9m4_define([cups_filters_version_minor],[28])
10m4_define([cups_filters_version_micro],[10])
11m4_define([cups_filters_version],[cups_filters_version_major.cups_filters_version_minor.cups_filters_version_micro])
12
13# =============
14# Automake init
15# =============
16AC_INIT([cups-filters],[cups_filters_version])
17AC_CONFIG_MACRO_DIR([m4])
18m4_include([m4/ac_define_dir.m4])
19m4_include([m4/ax_compare_version.m4])
20m4_include([m4/basic-directories.m4])
21AM_INIT_AUTOMAKE([1.11 gnu dist-xz dist-bzip2 subdir-objects])
22AM_SILENT_RULES([yes])
23AC_LANG([C++])
24AC_CONFIG_HEADERS([config.h])
25# Extra defines for the config.h
26AH_BOTTOM([
27#ifdef HAVE_LONG_LONG
28#  define CUPS_LLFMT   "%lld"
29#  define CUPS_LLCAST  (long long)
30#else
31#  define CUPS_LLFMT   "%ld"
32#  define CUPS_LLCAST  (long)
33#endif /* HAVE_LONG_LONG */
34
35#ifdef HAVE_ARC4RANDOM
36#  define CUPS_RAND() arc4random()
37#  define CUPS_SRAND(v) arc4random_stir()
38#elif defined(HAVE_RANDOM)
39#  define CUPS_RAND() random()
40#  define CUPS_SRAND(v) srandom(v)
41#elif defined(HAVE_LRAND48)
42#  define CUPS_RAND() lrand48()
43#  define CUPS_SRAND(v) srand48(v)
44#else
45#  define CUPS_RAND() rand()
46#  define CUPS_SRAND(v) srand(v)
47#endif /* HAVE_ARC4RANDOM */
48])
49
50# ===========================
51# Find required base packages
52# ===========================
53AC_PROG_CC
54AC_PROG_CXX
55AX_CXX_COMPILE_STDCXX([11],[noext],[mandatory])
56AM_PROG_CC_C_O
57AM_ICONV
58AC_PROG_CPP
59AC_PROG_INSTALL
60AC_PROG_LN_S
61AS_LN_SRF_PREPARE
62AC_PROG_LN_SRF
63AC_PROG_MAKE_SET
64AC_PROG_LIBTOOL
65PKG_PROG_PKG_CONFIG([0.20])
66
67AM_GNU_GETTEXT_VERSION([0.18.3])
68AM_GNU_GETTEXT([external])
69
70# ========================================
71# Specify the fontdir patch if not default
72# ========================================
73AC_ARG_WITH([fontdir],
74	[AS_HELP_STRING([--with-fontdir=path], [Specify path to font config directory (default: fonts/conf.d/).])],
75	[FONTDIR="$withval"],
76	[FONTDIR="fonts/conf.d"]
77)
78AC_SUBST(FONTDIR)
79
80# ================================
81# Find CUPS internals (no pc file)
82# ================================
83AC_ARG_WITH([cups-config],
84	[AS_HELP_STRING([--with-cups-config=path], [Specify path to cups-config executable.])],
85	[with_cups_config="$withval"],
86	[with_cups_config=system]
87)
88
89AS_IF([test "x$with_cups_config" != "xsystem"], [
90	CUPSCONFIG=$with_cups_config
91], [
92	AC_PATH_TOOL(CUPSCONFIG, [cups-config])
93	AS_IF([test -z "$CUPSCONFIG"], [
94		AC_MSG_ERROR([Required cups-config is missing. Please install CUPS developer packages.])
95	])
96])
97CUPS_CFLAGS=`$CUPSCONFIG --cflags`' -D_PPD_DEPRECATED=""'
98CUPS_LIBS=`$CUPSCONFIG --image --libs`
99CUPS_VERSION=`$CUPSCONFIG --version`
100AC_SUBST(CUPS_CFLAGS)
101AC_SUBST(CUPS_LIBS)
102
103CUPS_DATADIR="`$CUPSCONFIG --datadir`"
104AC_DEFINE_UNQUOTED(CUPS_DATADIR, "$CUPS_DATADIR", [CUPS datadir])
105AC_SUBST(CUPS_DATADIR)
106
107CUPS_SERVERROOT="`$CUPSCONFIG --serverroot`"
108AC_DEFINE_UNQUOTED(CUPS_SERVERROOT, "$CUPS_SERVERROOT", [CUPS serverroot])
109AC_SUBST(CUPS_SERVERROOT)
110
111CUPS_FONTPATH="$CUPS_DATADIR/fonts"
112AC_DEFINE_UNQUOTED(CUPS_FONTPATH, "$CUPS_FONTPATH", [Path to CUPS fonts dir])
113AC_SUBST(CUPS_FONTPATH)
114
115CUPS_SERVERBIN="`$CUPSCONFIG --serverbin`"
116AC_DEFINE_UNQUOTED(CUPS_SERVERBIN, "$CUPS_SERVERBIN", [Path to CUPS binaries dir])
117AC_SUBST(CUPS_SERVERBIN)
118
119AX_COMPARE_VERSION([$CUPS_VERSION],[gt],[1.4], [
120	AC_DEFINE(CUPS_1_4, 1, [CUPS Version is 1.4 or newer])
121])
122
123AC_ARG_ENABLE([driverless], [AS_HELP_STRING([--enable-driverless], [enable PPD generator for driverless printing in /usr/lib/cups/driver/, for manual setup of driverless printers with printer setup tool.])],
124        [enable_driverless="$enableval"],
125        [enable_driverless=yes]
126)
127AX_COMPARE_VERSION([$CUPS_VERSION],[lt],[1.6], [
128	enable_driverless=no
129])
130AM_CONDITIONAL([ENABLE_DRIVERLESS],
131[test "x$enable_driverless" != "xno"])
132
133APPLE_RASTER_FILTER=rastertopdf
134AX_COMPARE_VERSION([$CUPS_VERSION],[lt],[2.2.2], [
135	APPLE_RASTER_FILTER=urftopdf
136])
137AC_ARG_WITH([apple-raster-filter],
138	[AS_HELP_STRING([--with-apple-raster-filter=rastertopdf|urftopdf], [Select filter for Apple Raster input. Default: rastertopdf for CUPS 2.2.2+, urftopdf for older CUPS])],
139	[with_apple_raster_filter="$withval"],
140	[with_apple_raster_filter="$APPLE_RASTER_FILTER"]
141)
142AS_CASE([x$with_apple_raster_filter],
143	[xrastertopdf|xurftopdf], [APPLE_RASTER_FILTER=$with_apple_raster_filter],
144	[AC_MSG_ERROR([Unknown value of with-apple-raster-filter provided: $with_apple_raster_filter])]
145)
146AM_CONDITIONAL([ENABLE_URFTOPDF],
147	       [test "x$APPLE_RASTER_FILTER" = "xurftopdf"])
148AC_SUBST(APPLE_RASTER_FILTER)
149
150AC_DEFINE(PDFTOPDF, [], [Needed for pdftopdf filter compilation])
151AC_DEFINE_DIR(BANNERTOPDF_DATADIR, "{CUPS_DATADIR}/data", [Directory where bannertopdf finds its data files (PDF templates)])
152
153AC_ARG_ENABLE([auto-setup-local-only], [AS_HELP_STRING([--enable-auto-setup-local-only], [enable automatic setup of only local IPP printers.])],
154        [enable_auto_setup_local_only="$enableval"],
155        [enable_auto_setup_local_only=no]
156)
157if test "x$enable_auto_setup_local_only" != "xno"; then
158	AC_DEFINE([ONLY_LOCAL_IPP_PRINTERS_AUTO_SETUP], [], [Auto-setup only local IPP network printers?])
159fi
160
161AC_ARG_ENABLE([auto-setup-driverless-only], [AS_HELP_STRING([--enable-auto-setup-driverless-only], [enable automatic setup of only IPP network printers with driverless printing support.])],
162        [enable_auto_setup_driverless_only="$enableval"],
163        [enable_auto_setup_driverless_only=no]
164)
165if test "x$enable_auto_setup_driverless_only" != "xno"; then
166	AC_DEFINE([ONLY_DRIVERLESS_IPP_PRINTERS_AUTO_SETUP], [], [Auto-setup only driverless IPP network printers?])
167fi
168
169if test "x$enable_auto_setup_local_only" != "xno"; then
170	enable_auto_setup_driverless_only=no
171	enable_auto_setup_all=no
172else
173	if test "x$enable_auto_setup_driverless_only" != "xno"; then
174		enable_auto_setup_all=no
175	else
176		enable_auto_setup_all=yes
177	fi
178fi
179
180AC_SEARCH_LIBS([dlopen],
181	[dl],
182	[AS_IF([test "$ac_cv_search_dlopen" != "none required"], [
183		DLOPEN_LIBS="$ac_cv_search_dlopen"
184	])],
185	AC_MSG_ERROR([unable to find the dlopen() function])
186)
187AC_SUBST(DLOPEN_LIBS)
188
189# Transient run-time state dir of CUPS
190CUPS_STATEDIR=""
191AC_ARG_WITH(cups-rundir, [  --with-cups-rundir           set transient run-time state directory of CUPS],CUPS_STATEDIR="$withval",[
192        case "$uname" in
193                Darwin*)
194                        # Darwin (OS X)
195                        CUPS_STATEDIR="$CUPS_SERVERROOT"
196                        ;;
197                *)
198                        # All others
199                        CUPS_STATEDIR="$localstatedir/run/cups"
200                        ;;
201        esac])
202AC_DEFINE_UNQUOTED(CUPS_STATEDIR, "$CUPS_STATEDIR", [Transient run-time state dir of CUPS])
203AC_SUBST(CUPS_STATEDIR)
204
205# Domain socket of CUPS...
206CUPS_DEFAULT_DOMAINSOCKET=""
207AC_ARG_WITH(cups-domainsocket, [  --with-cups-domainsocket     set unix domain socket name used by CUPS
208],
209        default_domainsocket="$withval",
210        default_domainsocket="")
211
212if test x$enable_domainsocket != xno -a x$default_domainsocket != xno; then
213        if test "x$default_domainsocket" = x; then
214                case "$uname" in
215                        Darwin*)
216                                # Darwin and MaxOS X do their own thing...
217                                CUPS_DEFAULT_DOMAINSOCKET="$localstatedir/run/cupsd"
218                                ;;
219                        *)
220                                # All others use FHS standard...
221                                CUPS_DEFAULT_DOMAINSOCKET="$CUPS_STATEDIR/cups.sock"
222                                ;;
223                esac
224        else
225                CUPS_DEFAULT_DOMAINSOCKET="$default_domainsocket"
226        fi
227fi
228AC_DEFINE_UNQUOTED(CUPS_DEFAULT_DOMAINSOCKET, "$CUPS_DEFAULT_DOMAINSOCKET", "Domain socket of CUPS")
229AC_SUBST(CUPS_DEFAULT_DOMAINSOCKET)
230
231# ======================
232# Check system functions
233# ======================
234AC_CHECK_FUNCS(strlcat)
235AC_CHECK_FUNCS(strlcpy)
236AC_CHECK_FUNCS(sigaction)
237AC_CHECK_FUNCS(waitpid wait3)
238AC_CHECK_FUNCS(strtoll)
239AC_CHECK_FUNCS(open_memstream)
240AC_CHECK_FUNCS(getline,[],AC_SUBST([GETLINE],['bannertopdf-getline.$(OBJEXT)']))
241AC_CHECK_FUNCS(strcasestr,[],AC_SUBST([STRCASESTR],['pdftops-strcasestr.$(OBJEXT)']))
242AC_SEARCH_LIBS(pow, m)
243
244# ========================
245# Check for system headers
246# ========================
247AC_CHECK_HEADERS([stdlib.h])
248AC_CHECK_HEADERS([sys/stat.h])
249AC_CHECK_HEADERS([sys/types.h])
250AC_CHECK_HEADERS([unistd.h])
251AC_CHECK_HEADERS([zlib.h])
252AC_CHECK_HEADERS([endian.h])
253AC_CHECK_HEADERS([dirent.h])
254AC_CHECK_HEADERS([sys/ioctl.h])
255
256# =============
257# Image options
258# =============
259AC_ARG_ENABLE([imagefilters],
260	[AS_HELP_STRING([--disable-imagefilters], [Build the image filters.])],
261	[enable_imagefilters="$enableval"],
262	[enable_imagefilters=yes]
263)
264AM_CONDITIONAL([ENABLE_IMAGEFILTERS], [test "x$enable_imagefilters" != "xno"])
265
266# Libraries
267AC_ARG_WITH([jpeg],
268	[AS_HELP_STRING([--without-jpeg], [Disable jpeg support.])],
269	[with_jpeg="$withval"],
270	[with_jpeg=yes]
271)
272AS_IF([test x"$with_jpeg" != "xno"], [
273	AC_DEFINE([HAVE_LIBJPEG], [], [Defines if we provide jpeg library.])
274	AC_CHECK_HEADERS([jpeglib.h])
275	AC_SEARCH_LIBS([jpeg_destroy_decompress],
276		[jpeg],
277		LIBJPEG_LIBS="-ljpeg",
278		AC_MSG_ERROR([jpeg libraries not found.])
279	)
280	AC_SUBST(LIBJPEG_LIBS)
281])
282
283AC_ARG_WITH([png],
284	[AS_HELP_STRING([--without-png], [Disable png support.])],
285	[with_png="$withval"],
286	[with_png=yes]
287)
288AS_IF([test x"$with_png" != "xno"], [
289	PKG_CHECK_MODULES([LIBPNG], [libpng])
290	AC_DEFINE([HAVE_LIBPNG], [], [Defines if we provide png library.])
291])
292
293AC_ARG_WITH([tiff],
294	[AS_HELP_STRING([--without-tiff], [Disable tiff support.])],
295	[with_tiff="$withval"],
296	[with_tiff=yes]
297)
298AS_IF([test x"$with_tiff" != "xno"], [
299	AC_DEFINE([HAVE_LIBTIFF], [], [Defines if we provide tiff library.])
300	AC_CHECK_HEADERS([tiff.h])
301	AC_SEARCH_LIBS([TIFFReadScanline],
302		[tiff],
303		LIBJPEG_LIBS="-ltiff",
304		AC_MSG_ERROR([tiff libraries not found.])
305	)
306	AC_SUBST(LIBTIFF_LIBS)
307])
308
309# ==================================
310# Check for modules needed by utils/
311# ==================================
312
313dnl Avahi for cups-browsed
314AVAHI_LIBS=""
315AVAHI_CFLAGS=""
316AVAHI_GLIB_CFLAGS=""
317AVAHI_GLIB_LIBS=""
318
319AC_ARG_ENABLE([avahi],
320	[AS_HELP_STRING([--disable-avahi], [Disable DNS Service Discovery support using Avahi.])],
321	[enable_avahi="$enableval"],
322	[enable_avahi=yes]
323)
324AM_CONDITIONAL([ENABLE_AVAHI], [test "x$enable_avahi" != "xno"])
325
326AC_ARG_WITH(avahi-libs,
327	[AS_HELP_STRING([--with-avahi-libs], [Set directory for Avahi library.])],
328	AVAHI_LIBS="-L$withval $AVAHI_LIBS",)
329AC_ARG_WITH(avahi-includes,
330	[AS_HELP_STRING([--with-avahi-includes], [Set directory for Avahi includes])],
331	AVAHI_CFLAGS="-I$withval $AVAHI_CFLAGS",)
332
333if test "x$enable_avahi" != xno; then
334	PKG_CHECK_MODULES(AVAHI, avahi-client,
335		[AC_DEFINE(HAVE_AVAHI, [], [Define if you have the avahi library])])
336fi
337
338AC_SUBST(AVAHI_LIBS)
339AC_SUBST(AVAHI_CFLAGS)
340
341dnl
342dnl   LDAP configuration stuff for CUPS.
343dnl
344dnl   Copyright 2007-2011 by Apple Inc.
345dnl   Copyright 2003-2006 by Easy Software Products, all rights reserved.
346dnl
347dnl   These coded instructions, statements, and computer programs are the
348dnl   property of Apple Inc. and are protected by Federal copyright
349dnl   law.  Distribution and use rights are outlined in the file "COPYING"
350dnl   which should have been included with this file.
351dnl
352
353AC_ARG_ENABLE([ldap], [AS_HELP_STRING([--disable-ldap], [disable LDAP support.])],
354        [enable_ldap="$enableval"],
355        [enable_ldap=yes]
356)
357AC_ARG_WITH([ldap-libs], [AS_HELP_STRING([--with-ldap-libs], [set directory for LDAP library.])],
358    LDFLAGS="-L$withval $LDFLAGS"
359    DSOFLAGS="-L$withval $DSOFLAGS",)
360AC_ARG_WITH([ldap-includes], [AS_HELP_STRING([--with-ldap-includes], [set directory for LDAP includes.])],
361    CFLAGS="-I$withval $CFLAGS"
362    CPPFLAGS="-I$withval $CPPFLAGS",)
363
364if test x$enable_ldap != xno; then
365
366    AC_CHECK_HEADER([ldap.h], [
367	AC_SEARCH_LIBS([ldap_initialize], [ldap], [
368	    AC_DEFINE([HAVE_LDAP], [], [Define if LDAP support should be enabled])
369	    AC_DEFINE([HAVE_OPENLDAP], [], [If LDAP support is that of OpenLDAP])
370	    AC_CHECK_LIB([ldap], [ldap_start_tls],
371		AC_DEFINE([HAVE_LDAP_SSL], [], [If LDAP has SSL/TLS support enabled]))],[
372
373	    AC_CHECK_LIB([ldap], [ldap_init], [
374		AC_DEFINE([HAVE_LDAP], [], [Define if LDAP support should be enabled])
375		AC_DEFINE([HAVE_MOZILLA_LDAP], [], [If LDAP support is that of Mozilla])
376		AC_CHECK_HEADERS([ldap_ssl.h], [], [], [#include <ldap.h>])
377		AC_CHECK_LIB([ldap], [ldapssl_init],
378		    AC_DEFINE([HAVE_LDAP_SSL], [], [If LDAP has SSL/TLS support enabled]))])]
379	)
380	AC_CHECK_LIB([ldap], [ldap_set_rebind_proc], AC_DEFINE([HAVE_LDAP_REBIND_PROC], [], [If libldap implements ldap_set_rebind_proc]))
381    ])
382
383fi
384
385PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.30.2])
386AC_SUBST(GLIB_CFLAGS)
387AC_SUBST(GLIB_LIBS)
388
389if test x$enable_avahi != xno; then
390	PKG_CHECK_MODULES(AVAHI_GLIB, [avahi-glib])
391fi
392
393AC_SUBST(AVAHI_GLIB_CFLAGS)
394AC_SUBST(AVAHI_GLIB_LIBS)
395
396PKG_CHECK_MODULES(GIO, [gio-2.0])
397AC_SUBST(GIO_CFLAGS)
398AC_SUBST(GIO_LIBS)
399
400PKG_CHECK_MODULES(GIO_UNIX, [gio-unix-2.0])
401AC_SUBST(GIO_UNIX_CFLAGS)
402AC_SUBST(GIO_UNIX_LIBS)
403
404AC_ARG_WITH([browseremoteprotocols],
405	[AS_HELP_STRING([--with-browseremoteprotocols=value], [Set which protocols to listen for in cups-browsed (default: dnssd cups)])],
406	[with_browseremoteprotocols="$withval"],
407	[with_browseremoteprotocols="dnssd cups"]
408)
409BROWSEREMOTEPROTOCOLS="$with_browseremoteprotocols"
410AC_SUBST(BROWSEREMOTEPROTOCOLS)
411
412dnl Setup init.d locations...
413AC_ARG_WITH(rcdir, [AS_HELP_STRING([--with-rcdir], [Set path for rc scripts])],rcdir="$withval",rcdir="")
414AC_ARG_WITH(rclevels, [AS_HELP_STRING([--with-rclevels], [Set run levels for rc scripts])],rclevels="$withval",rclevels="2 3 5")
415AC_ARG_WITH(rcstart, [AS_HELP_STRING([--with-rcstart], [Set start number for rc scripts])],rcstart="$withval",rcstart="99")
416AC_ARG_WITH(rcstop, [AS_HELP_STRING([--with-rcstop], [Set stop number for rc scripts])],rcstop="$withval",rcstop="00")
417
418INITDIR=""
419INITDDIR=""
420RCLEVELS="$rclevels"
421RCSTART="$rcstart"
422RCSTOP="$rcstop"
423
424if test x$rcdir = x; then
425	case "`uname`" in
426		FreeBSD* | OpenBSD* | MirBSD* | ekkoBSD*)
427			# FreeBSD and OpenBSD
428			;;
429
430		Linux | GNU | GNU/k*BSD*)
431			# Linux/HURD seems to choose an init.d directory at random...
432			if test -d /sbin/init.d; then
433				# SuSE
434				INITDIR="/sbin/init.d"
435			else
436				if test -d /etc/init.d; then
437					# Others
438					INITDIR="/etc"
439				else
440					# RedHat
441					INITDIR="/etc/rc.d"
442				fi
443			fi
444			RCSTART="82"
445			RCSTOP="35"
446			;;
447
448		NetBSD*)
449			# NetBSD
450			INITDDIR="/etc/rc.d"
451			;;
452
453		*)
454			INITDIR="/etc"
455			;;
456
457	esac
458elif test "x$rcdir" != xno; then
459	if test "x$rclevels" = x; then
460		INITDDIR="$rcdir"
461	else
462		INITDIR="$rcdir"
463	fi
464fi
465
466AM_CONDITIONAL([RCLINKS], [test "x$INITDIR" != "x"])
467
468if test "x${INITDIR}" != "x" -a "x${INITDDIR}" = "x"; then
469   INITDDIR="${INITDIR}/init.d"
470fi
471
472AC_SUBST(INITDIR)
473AC_SUBST(INITDDIR)
474AC_SUBST(RCLEVELS)
475AC_SUBST(RCSTART)
476AC_SUBST(RCSTOP)
477
478# ======================================
479# Check for various pdf required modules
480# ======================================
481PKG_CHECK_MODULES([LCMS], [lcms2], [lcms2=yes], [lcms2=no])
482AS_IF([test x"$lcms2" = "xno"], [
483	PKG_CHECK_MODULES([LCMS], [lcms])
484	AC_DEFINE([USE_LCMS1], [1], [Defines if use lcms1])
485])
486PKG_CHECK_MODULES([FREETYPE], [freetype2], [AC_DEFINE([HAVE_FREETYPE_H], [1], [Have FreeType2 include files])])
487PKG_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.0.0])
488PKG_CHECK_MODULES([ZLIB], [zlib])
489AC_DEFINE([HAVE_LIBZ], [], [Define that we use zlib])
490PKG_CHECK_MODULES([LIBQPDF], [libqpdf >= 8.3.0])
491
492# ===============================
493# Check for PCLm printing support
494# ===============================
495AC_ARG_ENABLE([pclm], [AS_HELP_STRING([--enable-pclm], [enable PCLm printing.])],
496	[enable_pclm="$enableval"],
497	[enable_pclm=yes]
498)
499if test "x$enable_pclm" != "xno"; then
500	AC_DEFINE([QPDF_HAVE_PCLM], [1], [QPDF has PCLm support?])
501	QPDF_NO_PCLM=
502else
503	QPDF_NO_PCLM=\#
504fi
505AC_SUBST(QPDF_NO_PCLM)
506
507
508
509# =================
510# Check for Poppler
511# =================
512AC_ARG_ENABLE(poppler, AS_HELP_STRING([--enable-poppler],[enable Poppler-based filters]),
513	      enable_poppler=$enableval,enable_poppler=yes)
514AM_CONDITIONAL(ENABLE_POPPLER, test x$enable_poppler = xyes)
515if test x$enable_poppler = xyes; then
516	PKG_CHECK_MODULES([POPPLER], [poppler-cpp >= 0.19])
517	AC_CHECK_HEADER([poppler/cpp/poppler-version.h], [AC_DEFINE([HAVE_CPP_POPPLER_VERSION_H],,[Define if you have Poppler's "cpp/poppler-version.h" header file.])], [])
518fi
519
520# ===============
521# Check for D-Bus
522# ===============
523AC_ARG_ENABLE(dbus, AS_HELP_STRING([--enable-dbus],[enable DBus CMS code]),
524	      enable_dbus=$enableval,enable_dbus=yes)
525AM_CONDITIONAL(BUILD_DBUS, test x$enable_dbus = xyes)
526if test x$enable_dbus = xyes; then
527	PKG_CHECK_MODULES(DBUS, dbus-1)
528fi
529
530# ===================================
531# Check for large files and long long
532# ===================================
533AC_SYS_LARGEFILE
534LARGEFILE=""
535AS_IF([test x"$enable_largefile" != "xno"], [
536	LARGEFILE="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE"
537	AS_IF([test x"$ac_cv_sys_large_files" = "x1"], [LARGEFILE="$LARGEFILE -D_LARGE_FILES"])
538	AS_IF([test x"$ac_cv_sys_file_offset_bits" = "x64"], [LARGEFILE="$LARGEFILE -D_FILE_OFFSET_BITS=64"])
539])
540AC_SUBST(LARGEFILE)
541
542AC_CHECK_TYPE(long long, [long_long_found=yes], [long_long_found=no])
543AS_IF([test x"$long_long_found" = "xyes"], [
544	AC_DEFINE([HAVE_LONG_LONG], [], [Platform supports long long type])
545])
546
547# ================
548# Check for Mutool
549# ================
550AC_ARG_ENABLE([mutool],
551	[AS_HELP_STRING([--disable-mutool], [Disable filters using mutool.])],
552	[enable_mutool="$enableval"],
553	[enable_mutool=yes]
554)
555
556AC_ARG_WITH([mutool-path],
557	[AS_HELP_STRING([--with-mutool-path=value], [Set path to mutool binary (default: system).])],
558	[with_mutool_path="$withval"],
559	[with_mutool_path=system]
560)
561
562# ================
563# Check for pdf2ps
564# ================
565AC_ARG_ENABLE([ghostscript],
566	[AS_HELP_STRING([--disable-ghostscript], [Disable filters using Ghostscript.])],
567	[enable_ghostscript="$enableval"],
568	[enable_ghostscript=yes]
569)
570AC_ARG_WITH([pdftops],
571	[AS_HELP_STRING([--with-pdftops=value], [Set which pdftops to use (gs,pdftops,pdftocairo,acroread,mupdf,hybrid).])],
572	[with_pdftops="$withval"],
573	[with_pdftops=hybrid]
574)
575AS_CASE([x$with_pdftops],
576        [xgs|xpdftops|xpdftocairo|xacroread|xmupdf|xhybrid], [],
577        [AC_MSG_ERROR([Unknown value of with-pdftops provided: $with_pdftops])]
578)
579AC_ARG_WITH([gs-path],
580	[AS_HELP_STRING([--with-gs-path=value], [Set path to ghostcript binary (default: system).])],
581	[with_gs_path="$withval"],
582	[with_gs_path=system]
583)
584AC_ARG_WITH([pdftops-path],
585        [AS_HELP_STRING([--with-pdftops-path=value], [Set path to pdftops/ghostscript binary (default: system).])],
586        [with_pdftops_path="$withval"],
587        [with_pdftops_path=system]
588)
589AC_ARG_WITH([pdftocairo-path],
590        [AS_HELP_STRING([--with-pdftocairo-path=value], [Set path to pdftocairo binary (default: system).])],
591        [with_pdftocairo_path="$withval"],
592        [with_pdftocairo_path=system]
593)
594AC_ARG_WITH([acroread-path],
595        [AS_HELP_STRING([--with-acroread-path=value], [Set path to acroread binary (default: system).])],
596        [with_acroread_path="$withval"],
597        [with_acroread_path=system]
598)
599AC_ARG_WITH([ippfind-path],
600        [AS_HELP_STRING([--with-ippfind-path=value], [Set path to ippfind binary (default: system).])],
601        [with_ippfind_path="$withval"],
602        [with_ippfind_path=system]
603)
604AC_ARG_WITH([pdftops-maxres],
605	[AS_HELP_STRING([--with-pdftops-maxres=value], [Set maximum image rendering resolution for pdftops filter (0, 75, 150, 300, 600, 1200, 2400, 4800, 90, 180, 360, 720, 1440, 2880, 5760, unlimited). Default: 1440])],
606	[with_pdftops_maxres="$withval"],
607	[with_pdftops_maxres=1440]
608)
609AS_CASE([x$with_pdftops_maxres],
610	[x0|x75|x150|x300|x600|x1200|x2400|x4800|x90|x180|x360|x720|x1440|x2880|x5760], [CUPS_PDFTOPS_MAXRES=$with_pdftops_maxres],
611	[xunlimited], [CUPS_PDFTOPS_MAXRES=0],
612	[AC_MSG_ERROR([Unknown value of with-pdftops-maxres provided: $with_pdftops])]
613)
614AC_ARG_ENABLE([gs-ps2write],
615	[AS_HELP_STRING([--disable-gs-ps2write], [Ghostscript doesn't support ps2write device.])],
616	[enable_gs_ps2write="$enableval"],
617	[enable_gs_ps2write=yes]
618)
619
620CUPS_GHOSTSCRIPT=""
621AS_IF([test "x$enable_ghostscript" != "xyes"], [
622       with_gs_path=""
623], [
624	AS_IF([test "x$with_gs_path" != "xsystem"], [
625		CUPS_GHOSTSCRIPT="$with_gs_path"
626	], [
627		AS_IF([test "x$cross_compiling" = "xyes"], [
628			CUPS_GHOSTSCRIPT="gs"
629		], [
630			AC_CHECK_PROG(CUPS_GHOSTSCRIPT, gs, gs)
631		])
632	])
633	AS_IF([test "x$CUPS_GHOSTSCRIPT" = "x"], [
634		AC_MSG_ERROR([Required gs binary is missing. Please install ghostscript-gpl package.])
635	])
636	AC_DEFINE([HAVE_GHOSTSCRIPT], [], [Define that we provide ghostscript binary])
637	AS_IF([test x"$with_pdftops" = xgs], [AC_DEFINE_UNQUOTED([CUPS_PDFTOPS_RENDERER], [GS], [Define default renderer])])
638
639	AS_IF([test x"$enable_gs_ps2write" = "xyes"], [
640		AC_DEFINE([HAVE_GHOSTSCRIPT_PS2WRITE], [], [gs supports ps2write])
641	])
642	AS_IF([test "x$cross_compiling" != "xyes"], [
643		AC_MSG_CHECKING(whether gs supports the ps2write device)
644		AS_IF([`$CUPS_GHOSTSCRIPT -h 2>&1 | grep -q ps2write`], [
645			AC_MSG_RESULT([yes])
646			AC_DEFINE([HAVE_GHOSTSCRIPT_PS2WRITE], [], [gs supports ps2write])
647		], [
648			AC_MSG_RESULT([no])
649		])
650	])
651])
652AM_CONDITIONAL(ENABLE_GHOSTSCRIPT, test "x$enable_ghostscript" = xyes)
653AC_SUBST(CUPS_GHOSTSCRIPT)
654
655CUPS_MUTOOL=""
656AS_IF([test "x$enable_mutool" != "xyes"], [
657	with_mutool_path=""
658], [
659	AS_IF([test "x$with_mutool_path" != "xsystem"], [
660		CUPS_MUTOOL="$with_mutool_path"
661	], [
662		AS_IF([test "x$cross_compiling" = "xyes"], [
663			CUPS_MUTOOL="mutool"
664		], [
665			AC_CHECK_PROG(CUPS_MUTOOL, mutool, mutool)
666		])
667	])
668	AS_IF([test "x$CUPS_MUTOOL" = "x"], [
669		AC_MSG_ERROR([Required mutool binary is missing. Please install mutool.])
670	])
671	AS_IF([test x"$with_pdftops" = xmupdf], [AC_DEFINE_UNQUOTED([CUPS_PDFTOPS_RENDERER], [MUPDF], [Define default renderer])])
672])
673AM_CONDITIONAL(ENABLE_MUTOOL, test "x$enable_mutool" = xyes)
674AC_SUBST(CUPS_MUTOOL)
675
676AS_IF([test "x$with_pdftops_path" != "xsystem"], [
677	CUPS_PDFTOPS="$with_pdftops_path"
678], [
679	AS_IF([test "x$cross_compiling" = "xyes"], [
680		CUPS_PDFTOPS="/usr/bin/pdftops"
681	], [
682		AC_CHECK_PROG(CUPS_PDFTOPS, pdftops, /usr/bin/pdftops)
683	])
684	AS_IF([test "x$CUPS_PDFTOPS" = "x"], [
685		AC_MSG_ERROR([Required pdftops is missing. Please install the pdftops utility of Poppler.])
686	])
687])
688AS_IF([test "x$CUPS_PDFTOPS" != "x"], [
689	AC_DEFINE([HAVE_POPPLER_PDFTOPS], [], [Define that we provide poppler pdftops.])
690	AS_IF([test x"$with_pdftops" = xpdftops], [AC_DEFINE_UNQUOTED([CUPS_PDFTOPS_RENDERER], [PDFTOPS], [Define default renderer])])
691
692	AS_IF([test "x$cross_compiling" != "xyes"], [
693		AC_MSG_CHECKING([whether pdftops supports -origpagesizes])
694		AS_IF([`$CUPS_PDFTOPS -h 2>&1 | grep -q -- -origpagesizes`], [
695        		AC_MSG_RESULT([yes])
696			AC_DEFINE([HAVE_POPPLER_PDFTOPS_WITH_ORIGPAGESIZES], [] , [pdftops supports -origpagesizes.])
697		], [
698	        	AC_MSG_RESULT([no])
699		])
700		AC_MSG_CHECKING([whether pdftops supports -r])
701		AS_IF([`$CUPS_PDFTOPS -h 2>&1 | grep -q -- '-r '`], [
702	        	AC_MSG_RESULT([yes])
703			AC_DEFINE([HAVE_POPPLER_PDFTOPS_WITH_RESOLUTION], [] , [pdftops supports -r argument.])
704		], [
705        		AC_MSG_RESULT([no])
706		])
707	])
708])
709AS_IF([test "x$with_pdftocairo_path" != "xsystem"], [
710	CUPS_PDFTOCAIRO="$with_pdftocairo_path"
711], [
712	CUPS_PDFTOCAIRO="pdftocairo"
713])
714AS_IF([test "x$CUPS_PDFTOCAIRO" != "x"], [
715	AS_IF([test x"$with_pdftops" = xpdftocairo], [AC_DEFINE_UNQUOTED([CUPS_PDFTOPS_RENDERER], [PDFTOCAIRO], [Define default renderer])])
716], [
717	AC_MSG_ERROR([Required pdftocairo is missing. Please install Poppler developer packages.])
718])
719AS_IF([test "x$with_acroread_path" != "xsystem"], [
720	CUPS_ACROREAD="$with_acroread_path"
721], [
722	CUPS_ACROREAD="acroread"
723])
724AS_IF([test "x$CUPS_ACROREAD" != "x"], [
725	AS_IF([test x"$with_pdftops" = xacroread], [AC_DEFINE_UNQUOTED([CUPS_PDFTOPS_RENDERER], [ACROREAD], [Define default renderer])])
726])
727AS_IF([test "x$with_ippfind_path" != "xsystem"], [
728	CUPS_IPPFIND="$with_ippfind_path"
729], [
730	CUPS_IPPFIND="ippfind"
731])
732
733AS_IF([test "x$CUPS_GHOSTSCRIPT" != "x" -a "x$CUPS_PDFTOPS" != "x"], [
734	AS_IF([test x"$with_pdftops" = xhybrid], [AC_DEFINE_UNQUOTED([CUPS_PDFTOPS_RENDERER], [HYBRID], [Define default renderer])])
735])
736
737AC_DEFINE_UNQUOTED([CUPS_GHOSTSCRIPT], "$CUPS_GHOSTSCRIPT", [gs binary to use])
738AC_DEFINE_UNQUOTED([CUPS_MUTOOL],"$CUPS_MUTOOL",[mutool binary to use])
739AC_DEFINE_UNQUOTED([CUPS_POPPLER_PDFTOPS], "$CUPS_PDFTOPS", [pdftops binary to use.])
740AC_DEFINE_UNQUOTED([CUPS_POPPLER_PDFTOCAIRO], "$CUPS_PDFTOCAIRO", [pdftocairo binary to use.])
741AC_DEFINE_UNQUOTED([CUPS_ACROREAD], "$CUPS_ACROREAD", [acroread binary to use.])
742AC_DEFINE_UNQUOTED([CUPS_IPPFIND], "$CUPS_IPPFIND", [ippfind binary to use.])
743AC_DEFINE_UNQUOTED([CUPS_PDFTOPS_MAX_RESOLUTION], [$CUPS_PDFTOPS_MAXRES], [max resolution used for pdftops when converting images])
744
745# ==================
746# Check for foomatic
747# ==================
748AC_ARG_ENABLE([foomatic],
749	[AS_HELP_STRING([--disable-foomatic], [Disable Foomatic-based filters.])],
750	[enable_foomatic="$enableval"],
751	[enable_foomatic=yes]
752)
753AM_CONDITIONAL([ENABLE_FOOMATIC], [test "x$enable_foomatic" = "xyes"])
754
755# =============
756# Check for php
757# =============
758# NOTE: This stuff is broken, requires internal cups headers.
759AC_ARG_WITH([php],
760	[AS_HELP_STRING([--with-php], [Determine whether to build php cups extension.])],
761	[with_php="$withval"],
762	[with_php=no]
763)
764AC_ARG_WITH([php-config],
765	[AS_HELP_STRING([--with-php-config=path], [Specify path to php-config executable.])],
766	[with_php_config="$withval"],
767	[with_php_config=system]
768)
769AM_CONDITIONAL([WITH_PHP], [test "x$with_php" = "xyes"])
770AS_IF([test x"$with_php" = "xyes"], [
771	AS_IF([test "x$with_php_config" != "xsystem"], [
772		PHPCONFIG=$with_php_config
773	], [
774		AC_PATH_TOOL(PHPCONFIG, [php-config])
775		AS_IF([test -z "$PHPCONFIG"], [
776			AC_MSG_ERROR([Required php-config is missing. Please install PHP developer packages.])
777		])
778	])
779	PHPDIR="`$PHPCONFIG --extension-dir`"
780	AC_SUBST(PHPDIR)
781])
782
783# =========
784# Test ARGS
785# =========
786AC_ARG_WITH([test-font-path],
787	[AS_HELP_STRING([--with-test-font-path=value], [Set path to font used for tests (default: /usr/share/fonts/dejavu/DejaVuSans.ttf).])],
788	[with_test_font_path="$withval"],
789	[with_test_font_path=`( find /usr/share/fonts -name DejaVuSans.ttf; echo /usr/share/fonts/dejavu/DejaVuSans.ttf ) | head -1`]
790)
791
792AS_IF([test "x$cross_compiling" != "xyes" && ! test -f "$with_test_font_path"],
793	[AC_MSG_ERROR(DejaVuSans.ttf font file is missing. Please install a package providing it.)]
794)
795AC_DEFINE_UNQUOTED([TESTFONT], ["$with_test_font_path"], [Path to font used in tests])
796
797# ================
798# Check for cflags
799# ================
800AC_ARG_ENABLE([werror],
801	[AS_HELP_STRING([--enable-werror], [Treat all warnings as errors, useful for development.])],
802	[enable_werror="$enableval"],
803	[enable_werror=no]
804)
805AS_IF([test x"$enable_werror" = "xyes"], [
806	CFLAGS="$CFLAGS -Werror"
807])
808AS_IF([test x"$GCC" = "xyes"], [
809	# Be tough with warnings and produce less careless code
810	CFLAGS="$CFLAGS -Wall -std=gnu11"
811	CXXFLAGS="$CXXFLAGS -Wall " # -Weffc++" # TODO: enable when it does not print 1MB of warnings
812])
813CFLAGS="$CFLAGS -D_GNU_SOURCE"
814CXXFLAGS="$CXXFLAGS -D_GNU_SOURCE"
815
816# ==========================
817# Braille embossing/liblouis
818# ==========================
819AC_ARG_ENABLE(braille, AS_HELP_STRING([--enable-braille],[enable Braille embosing filters, requires liblouis]),
820	      enable_braille=$enableval,enable_braille=yes)
821AC_MSG_CHECKING(for liblouis)
822PKG_CHECK_EXISTS([liblouis], [
823	AC_MSG_RESULT(yes)
824	if test "x$enable_braille" = xyes; then
825		TABLESDIR=`$PKG_CONFIG --variable=tablesdir liblouis`
826	else
827		TABLESDIR=/usr/share/liblouis/tables
828	fi
829], [
830	AC_MSG_RESULT(no)
831	TABLESDIR=/usr/share/liblouis/tables
832])
833AM_CONDITIONAL(ENABLE_BRAILLE, test "x$enable_braille" = xyes)
834AC_SUBST(TABLESDIR)
835
836# ===============================================
837# Should we keep generated queues after shutdown?
838# ===============================================
839AC_ARG_ENABLE(saving-created-queues, AS_HELP_STRING([--enable-saving-created-queues], [enable saving created queues during shutdown]),
840	      [SAVING_CREATED_QUEUES=$enableval],[SAVING_CREATED_QUEUES="no"])
841
842AS_IF([test "x$SAVING_CREATED_QUEUES" != "xno"],
843      [AC_DEFINE([SAVING_CREATED_QUEUES], [1], [Define whether we save queues during shutdown])]
844)
845
846# =========================================
847# Local queue naming for remote CUPS queues
848# =========================================
849AC_ARG_WITH([remote-cups-local-queue-naming],
850	[AS_HELP_STRING([--with-remote-cups-local-queue-naming=DNS-SD|MakeModel|RemoteName], [Choose the origin of local queue naming for remote CUPS queues, default based on DNS-SD ID])],
851	[case "x$withval" in
852		"xMakeModel")
853			REMOTE_CUPS_LOCAL_QUEUE_NAMING="MakeModel"
854	                AC_DEFINE([NAMING_MAKE_MODEL], [1], [Define that we create local queues for remote CUPS queues based on printer Make-Model])
855			;;
856		"xRemoteName")
857			REMOTE_CUPS_LOCAL_QUEUE_NAMING="RemoteName"
858	                AC_DEFINE([NAMING_REMOTE_NAME], [1], [Define that we create local queues for remote CUPS queues based on their print queue name on the server])
859			;;
860		*)
861			REMOTE_CUPS_LOCAL_QUEUE_NAMING="DNS-SD"
862	                AC_DEFINE([NAMING_DNSSD], [1], [Define that we create local queues for remote CUPS queues based on DNS-SD name])
863			;;
864	esac],
865	[REMOTE_CUPS_LOCAL_QUEUE_NAMING="DNS-SD"
866	 AC_DEFINE([NAMING_DNSSD], [1], [Define that we create local queues for remote CUPS queues based on DNS-SD name])]
867)
868
869# =========================================================
870# Select a different shell instead of the default /bin/bash
871# =========================================================
872AC_ARG_WITH([shell],
873	[AS_HELP_STRING([--with-shell=path], [Specify path for a modern shell.])],
874	[with_shell="$withval"],
875	[with_shell="/bin/bash"]
876)
877AC_DEFINE_UNQUOTED([SHELL], "$with_shell", [Path for a modern shell])
878
879# =====================
880# Prepare all .in files
881# =====================
882AC_CONFIG_FILES([
883	libcupsfilters.pc
884	libfontembed.pc
885	Makefile
886	utils/cups-browsed
887	utils/cups-browsed.conf
888	filter/foomatic-rip/foomatic-rip.1
889	filter/braille/drivers/index/indexv4.sh
890	filter/braille/drivers/index/indexv3.sh
891	filter/braille/drivers/index/index.sh
892	filter/braille/drivers/index/textbrftoindexv3
893	filter/braille/drivers/index/imageubrltoindexv3
894	filter/braille/drivers/index/imageubrltoindexv4
895	filter/braille/drivers/generic/brftoembosser
896	filter/braille/filters/cups-braille.sh
897	filter/braille/filters/imagetobrf
898	filter/braille/filters/texttobrf
899	filter/braille/filters/brftopagedbrf
900	filter/braille/filters/vectortopdf
901	filter/braille/filters/vectortobrf
902	filter/braille/filters/musicxmltobrf
903	filter/braille/filters/liblouis1.defs.gen
904	mime/cupsfilters.convs
905])
906AC_CONFIG_COMMANDS([executable-scripts], [
907	chmod +x filter/braille/filters/liblouis1.defs.gen
908])
909AC_OUTPUT
910
911# ==============================================
912# Display final informations about configuration
913# ==============================================
914AC_MSG_NOTICE([
915==============================================================================
916Environment settings:
917	CFLAGS:                                    ${CFLAGS}
918	CXXFLAGS:                                  ${CXXFLAGS}
919	LDFLAGS:                                   ${LDFLAGS}
920Build configuration:
921	cups-config:     ${with_cups_config}
922	font directory:  ${sysconfdir}/${FONTDIR}
923	foomatic:        ${enable_foomatic}
924	init directory:  ${INITDDIR}
925	cups dom socket: ${CUPS_DEFAULT_DOMAINSOCKET}
926	poppler:         ${enable_poppler}
927	ghostscript:     ${enable_ghostscript}
928	gs-path:         ${with_gs_path}
929	mutool:          ${enable_mutool}
930	mutool-path:     ${with_mutool_path}
931	ippfind-path:    ${with_ippfind_path}
932	imagefilters:    ${enable_imagefilters}
933	jpeg:            ${with_jpeg}
934	pdftocairo-path: ${with_pdftocairo_path}
935	pdftops:         ${with_pdftops}
936	pdftops-path:    ${with_pdftops_path}
937	png:             ${with_png}
938	php:             ${with_php}
939	php-config:      ${with_php_config}
940	shell:           ${with_shell}
941	test-font:       ${with_test_font_path}
942	tiff:            ${with_tiff}
943	avahi:           ${enable_avahi}
944	dbus:            ${enable_dbus}
945	browsing:        ${with_browseremoteprotocols}
946	werror:          ${enable_werror}
947	braille:	 ${enable_braille}
948	braille tables:  ${TABLESDIR}
949	driverless:      ${enable_driverless}
950	apple-raster:    ${APPLE_RASTER_FILTER}
951	pclm:            ${enable_pclm}
952	local queue naming for remote CUPS queues: ${REMOTE_CUPS_LOCAL_QUEUE_NAMING}
953	keep generated queues during shutdown:     ${SAVING_CREATED_QUEUES}
954	all ipp printer auto-setup: ${enable_auto_setup_all}
955	only driverless auto-setup: ${enable_auto_setup_driverless_only}
956	only local auto-setup: ${enable_auto_setup_local_only}
957==============================================================================
958])
959