1dnl Copyright (C) 2001-2004 Roger Leigh
2dnl
3dnl This program is free software; you can redistribute it and/or modify
4dnl it under the terms of the GNU General Public License as published by
5dnl the Free Software Foundation; either version 2, or (at your option)
6dnl any later version.
7dnl
8dnl This program is distributed in the hope that it will be useful,
9dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
10dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11dnl GNU General Public License for more details.
12dnl
13dnl You should have received a copy of the GNU General Public License
14dnl along with this program.  If not, see <https://www.gnu.org/licenses/>.
15
16dnl Process this file with autoconf to produce a configure script.
17
18dnl MAKING RELEASES (a step-by-step guide!)
19dnl ===============
20dnl
21dnl Since the last release:
22dnl 1. if only source code (not the interface) has changed, set
23dnl      GUTENPRINT_MICRO_VERSION += 1;
24dnl 2. if any interfaces have been added or changed *compatibly*
25dnl      GUTENPRINT_CURRENT_INTERFACE (GCI) += 1;
26dnl      GUTENPRINT_BINARY_AGE (GBA) += 1;
27dnl 3. if interfaces have been deleted or changed *incompatibly*, set
28dnl    	 GCI = GBA + 1;
29dnl      GBA = 0;
30dnl
31dnl (Note that "added", "changed", and "deleted" refer to *external*
32dnl interfaces, that is, interfaces that start with stp_ and are in any
33dnl of the header files in include/gutenprint.  Internal interfaces
34dnl that are prefixed with stpi_ and are only listed in internal headers
35dnl in src/main do not need to be considered, since no external program
36dnl should rely on them.  "Change" refers to more than just function
37dnl signature; things like changes to enumerated types or changes in
38dnl behavior with the same function arguments are also considered changes)
39dnl
40dnl The .soname version is (GCI - GBA).GBA
41dnl Example: if GCI is 3 and GBA is 1, the version is 2.1.  To get 2.2,
42dnl GCI would be incremented to 4 and GBA to 2.
43dnl
44dnl *NOTE*: due to an error preparing 5.2.8, we must skip over major version of
45dnl 3 (that is, GCI - GBA) and go directly from 2 to 4.
46dnl
47dnl For example:
48dnl 	 GCI=3, GBA=1 => .soname = libgutenprint.so.2.1
49dnl 	 GCI=4, GBA=2 => .soname = libgutenprint.so.2.2 (5.2.9)
50dnl 	 GCI=5, GBA=3 => .soname = libgutenprint.so.2.3 (5.2.10)
51dnl          (and so on for 5.2 releases, which must remain compatible)
52dnl 	 GCI=4, GBA=0 => .soname = libgutenprint.so.4.0
53dnl 	 GCI=5, GBA=1 => .soname = libgutenprint.so.4.1
54dnl 	 GCI=6, GBA=2 => .soname = libgutenprint.so.4.2
55dnl          (for Gutenprint 5.3 or 5.4 or 6.0 or whatever)
56dnl 	 GCI=5, GBA=0 => .soname = libgutenprint.so.5.0
57dnl 	 GCI=6, GBA=1 => .soname = libgutenprint.so.5.1
58dnl 	 GCI=7, GBA=2 => .soname = libgutenprint.so.5.2
59dnl          (for the next major/minor release beyond that)
60dnl
61dnl Typically, programs will require a certain major number to be matched
62dnl and a minimum minor number.  Causing the major number to be incremented
63dnl will result in programs linked against libgutenprint.so.2 to be treated
64dnl as incompatible with libgutenprint.so.3.
65dnl
66dnl .soname versions can have a third component, which is set from
67dnl GUTENPRINT_INTERFACE_AGE.  This resulted in problems on OS X and
68dnl we have elected to use only two components in the .soname.
69dnl
70dnl Similar principles apply to libgutenprintui2, but that interface is
71dnl still at 1.0.
72dnl
73dnl For more detailed information, see the libtool info documentation.
74dnl
75pushdef([GUTENPRINT_NAME],              [gutenprint])
76pushdef([GUTENPRINT_MAJOR_VERSION],     [5])
77pushdef([GUTENPRINT_MINOR_VERSION],     [3])
78pushdef([GUTENPRINT_MICRO_VERSION],     [3])
79dnl Append snapshot ID if STP_BUILD_SNAPSHOT is set
80pushdef([GUTENPRINT_EXTRA_VERSION],     [[]m4_esyscmd_s(scripts/snapstamp)])
81pushdef([GUTENPRINT_CURRENT_INTERFACE], [13])
82pushdef([GUTENPRINT_BINARY_AGE],        [4])
83pushdef([GUTENPRINTUI2_CURRENT_INTERFACE], [6])
84pushdef([GUTENPRINTUI2_BINARY_AGE],        [4])
85pushdef([GUTENPRINT_VERSION], GUTENPRINT_MAJOR_VERSION.GUTENPRINT_MINOR_VERSION.GUTENPRINT_MICRO_VERSION[]GUTENPRINT_EXTRA_VERSION)
86
87AC_INIT([GUTENPRINT_NAME],
88	[GUTENPRINT_VERSION],
89	[gimp-print-devel@lists.sourceforge.net],
90	[GUTENPRINT_NAME],
91	[https://gimp-print.sourceforge.net])
92AC_PREREQ([2.69])
93AC_REVISION($Revision$)
94AC_CONFIG_SRCDIR(src/main/print-vars.c)
95AC_CONFIG_MACRO_DIR([m4])
96AC_CONFIG_AUX_DIR(scripts)
97STP_INIT
98AC_COPYRIGHT(
99[
100Parts of this configure script come from the 'configure.ac' file, and
101are not based on freely-redistributable m4 macros; you can redistribute
102them and/or modify them under the terms of the GNU General Public
103as published by the Free Software Foundation; either version 2, or (at
104your option) any later version.
105
106This program is distributed in the hope that it will be useful,
107but WITHOUT ANY WARRANTY; without even the implied warranty of
108MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
109GNU General Public License for more details.
110
111You should have received a copy of the GNU General Public License
112along with this program.  If not, see <https://www.gnu.org/licenses/>.
113])
114
115[GUTENPRINT_MAJOR_VERSION]=GUTENPRINT_MAJOR_VERSION
116[GUTENPRINT_MINOR_VERSION]=GUTENPRINT_MINOR_VERSION
117[GUTENPRINT_MICRO_VERSION]=GUTENPRINT_MICRO_VERSION
118[GUTENPRINT_EXTRA_VERSION]=GUTENPRINT_EXTRA_VERSION
119[GUTENPRINT_CURRENT_INTERFACE]=GUTENPRINT_CURRENT_INTERFACE
120[GUTENPRINT_INTERFACE_AGE]=0
121[GUTENPRINT_BINARY_AGE]=GUTENPRINT_BINARY_AGE
122[GUTENPRINT_VERSION]=GUTENPRINT_VERSION
123[GUTENPRINTUI2_CURRENT_INTERFACE]=GUTENPRINTUI2_CURRENT_INTERFACE
124[GUTENPRINTUI2_INTERFACE_AGE]=0
125[GUTENPRINTUI2_BINARY_AGE]=GUTENPRINTUI2_BINARY_AGE
126popdef([GUTENPRINT_MAJOR_VERSION])
127popdef([GUTENPRINT_MINOR_VERSION])
128popdef([GUTENPRINT_MICRO_VERSION])
129popdef([GUTENPRINT_EXTRA_VERSION])
130popdef([GUTENPRINT_CURRENT_INTERFACE])
131popdef([GUTENPRINT_BINARY_AGE])
132popdef([GUTENPRINTUI2_CURRENT_INTERFACE])
133popdef([GUTENPRINTUI2_BINARY_AGE])
134
135configure_args=
136
137for arg in "$@" ; do
138    if test -n "$configure_args" ; then
139        configure_args="$configure_args "
140    fi
141    if echo "$arg" | grep -q '[\s]' ; then
142        arg="'$arg'"
143    fi
144    configure_args="$configure_args$arg"
145done
146
147AC_SUBST([GUTENPRINT_MAJOR_VERSION])
148AC_SUBST([GUTENPRINT_MINOR_VERSION])
149AC_SUBST([GUTENPRINT_MICRO_VERSION])
150AC_SUBST([GUTENPRINT_CURRENT_INTERFACE])
151AC_SUBST([GUTENPRINT_INTERFACE_AGE])
152AC_SUBST([GUTENPRINT_BINARY_AGE])
153AC_SUBST([GUTENPRINT_VERSION])
154AC_SUBST([GUTENPRINTUI2_CURRENT_INTERFACE])
155AC_SUBST([GUTENPRINTUI2_INTERFACE_AGE])
156AC_SUBST([GUTENPRINTUI2_BINARY_AGE])
157
158dnl Make sure we inherit common compiler options from the environment...
159CFLAGS="${CFLAGS:=}"
160CPPFLAGS="${CPPFLAGS:=}"
161CXXFLAGS="${CXXFLAGS:=}"
162LDFLAGS="${LDFLAGS:=}"
163LIBS="${LIBS:=}"
164
165dnl Initialize automake stuff.
166dnl We use our own NEWS file check, as explained in Makefile.am.
167AM_INIT_AUTOMAKE(1.9 dist-xz dist-bzip2 no-dist-gzip tar-ustar gnu)
168m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
169popdef([GUTENPRINT_NAME])
170popdef([GUTENPRINT_VERSION])
171
172
173dnl In the following script, there are a the following variants
174dnl of cflags and variables
175dnl
176dnl *_CFLAGS:   cflags for compiling libraries and example progs
177dnl *_LIBS:     libraries for linking programs. ONLY to be used
178dnl             to generate ${gutenprint_libs}
179dnl *_LIBDEPS:  libraries for linking libraries against
180dnl *_libdeps:  library dependencies for pkg-config
181dnl *_cflags:   cflags for pkg-config
182dnl *_libs:     libs for pkg-config
183
184GUTENPRINT_LIBS="-lgutenprint"
185GUTENPRINTUI2_LIBS="-lgutenprintui2"
186gutenprint_version=${GUTENPRINT_VERSION}
187gutenprintui2_version=${GUTENPRINT_VERSION}
188
189GUTENPRINTUI2_LIBDEPS="${GUTENPRINTUI2_LIBDEPS} \$(GUTENPRINT_LIBS)"
190
191dnl Specify a configuration file.
192AM_CONFIG_HEADER([config.h])
193
194dnl Available languages (translations)
195ALL_LINGUAS="ca cs da de el en_GB es fi fr gl hu it ja nb nl pl pt ru sk sl sv tr uk vi zh_CN zh_TW"
196AC_SUBST(ALL_LINGUAS)
197
198dnl Set up libtool scripts.
199dnl Disable static library building to speed up the build
200LT_INIT[(dlopen)]
201
202# We need static libraries for CUPS genppd program for now, for bug 865265
203# --rlk 20031223
204AC_ENABLE_STATIC(yes)
205#AC_DISABLE_SHARED
206LT_INIT
207AC_SUBST(LIBTOOL_DEPS)
208dnl define HAVE_GNU_LD if GNU ld is present
209if test "$ac_cv_prog_gnu_ld" = "yes" ; then
210  AC_DEFINE(HAVE_GNU_LD,, [Define if GNU ld is present.])
211fi
212
213dnl Set up maintainer mode
214AM_MAINTAINER_MODE
215if test x${USE_MAINTAINER_MODE} = xyes ; then
216  MAINTAINER_MODE="true"
217  BUILD_TEST="yes"
218  BUILD_DOC="yes"
219  AC_DEFINE(HAVE_MAINTAINER_MODE,, [Define if maintainer-mode is to be used.])
220fi
221
222dnl Check canonical system/host (a kludge: replace me with something better).
223if test x${host_os} = xlinux-gnu ; then
224  OSTYPE="linux"
225elif test "`echo ${host_os} | sed 's/^\(linux\).*$/\1/'`" = "linux" ; then
226  OSTYPE="linux"
227elif test "`echo ${host_os} | sed 's/^\(irix\).*$/\1/'`" = "irix" ; then
228  OSTYPE="irix"
229else
230  OSTYPE="${host_os}"
231fi
232AC_DEFINE_UNQUOTED(OSTYPE, ["${OSTYPE}"], [The operating system to build for])
233
234
235dnl Command line options.
236AC_ARG_WITH([cups-config],
237  [AS_HELP_STRING([--with-cups-config=path], [Specify path to cups-config executable.])],
238  [with_cups_config="$withval"],
239  [with_cups_config=system]
240)
241AS_IF([test "x$with_cups_config" != "xsystem"], [
242    CUPS_CONFIG=$with_cups_config
243  ], [
244    AC_PATH_TOOL(CUPS_CONFIG, [cups-config])
245    AS_IF([test -z "$CUPS_CONFIG"], [
246      FOUND_CUPS_CONFIG=no
247   ],
248   [
249      FOUND_CUPS_CONFIG=yes
250   ])
251])
252
253missing_cups_error="
254
255******* ERROR ******
256You do not have the necessary software installed to build the CUPS driver.
257This is most likely not what you want, as the resulting installation will
258not be usable as part of a normal printing system.  If you are certain
259that this is what you want, please run configure with --without-cups.
260Otherwise, please read the README and install the necessary development
261package, most likely named 'cups-devel', and re-run configure.
262
263"
264
265STP_ARG_WITH_DETAILED(
266  [cups],
267  [=PREFIX],
268  [whether to build CUPS driver],
269  [(default PREFIX=/usr)],
270  [BUILD_CUPS],
271  [(automatic)],
272  [
273    yes)
274         if test "$FOUND_CUPS_CONFIG" == "yes" ; then
275	   [BUILD_CUPS]="yes"
276	   AC_MSG_RESULT([yes])
277	   cups_prefix="/usr"
278	 else
279	   AC_MSG_ERROR([$missing_cups_error])
280	 fi
281	 ;;
282    no) [BUILD_CUPS]="no" ; AC_MSG_RESULT([no]) ; cups_prefix="/usr" ;;
283    *) if test -d ${withval} ; then
284         [BUILD_CUPS]="yes"
285	 AC_MSG_RESULT([yes (using specified prefix)])
286         cups_prefix="${withval}"
287       else
288         AC_MSG_RESULT([unknown])
289         AC_MSG_ERROR([${withval}: no such directory for --with-cups])
290       fi ;;
291  ],[
292     if test "$FOUND_CUPS_CONFIG" == "yes" ; then
293       cups_prefix="${prefix}"
294       [BUILD_CUPS]="yes"
295     else
296       AC_MSG_ERROR([$missing_cups_error])
297     fi
298  ])
299
300dnl GNU gettext checks.
301AM_GNU_GETTEXT_VERSION([0.16])
302AM_GNU_GETTEXT([external])
303
304AM_CONDITIONAL(USE_NLS, test x${USE_NLS} = xyes)
305
306STP_ARG_ENABLE([nls-macosx],
307               [build CUPS PPD files],
308               [USE_NLS_OSX],
309               [(automatic)])
310
311USE_LEVEL3_PS=no
312BUILD_CUPS_PPDS="${BUILD_CUPS}"
313BUILD_TRANSLATED_CUPS_PPDS=no
314BUILD_CUPS_1_2="no"
315if test -n "${CUPS_CONFIG}" -a "${BUILD_CUPS}" = "yes" ; then
316  cups_version=`${CUPS_CONFIG} --version | sed -e '1,$s/svn$/.0/'`
317dnl Quote to protect sed regexes
318dnl Some relases may be 1.xrc1 or 1.xsvn. Grab only what is needed.
319  [cups_major=`echo $cups_version | sed -e 's/\([0-9][0-9]*\).*/\1/'`]
320  [cups_minor=`echo $cups_version | sed -e 's/\([0-9][0-9]*\).\([0-9][0-9]*\).*/\2/'`]
321  [cups_point=`echo $cups_version | sed -e 's/\([0-9][0-9]*\).\([0-9][0-9]*\).\([0-9][0-9]*\).*/\3/'`]
322dnl There was no CUPS 1.0.15 or the like
323  if test "$cups_major" -gt 1 -o "$cups_minor" -gt 1 -o "$cups_point" -gt 14 ; then
324    USE_LEVEL3_PS=yes
325  fi
326  if test "$cups_major" -gt 1 -o "$cups_minor" -gt 1 ; then
327    BUILD_CUPS_PPDS="no"
328    BUILD_CUPS_1_2="yes"
329  fi
330fi
331
332STP_ARG_ENABLE([cups-ppds],
333               [build CUPS PPD files],
334               [BUILD_CUPS_PPDS],
335               [(automatic)])
336
337STP_ARG_ENABLE([cups-1_2-enhancements],
338               [build CUPS 1.2 enhancements],
339               [BUILD_CUPS_1_2],
340               [(automatic)])
341
342if test "$USE_NLS" != no -a "$BUILD_CUPS_PPDS" = yes ; then
343   BUILD_TRANSLATED_CUPS_PPDS="yes"
344fi
345
346STP_ARG_ENABLE([translated-cups-ppds],
347               [build translated CUPS PPD files],
348               [BUILD_TRANSLATED_CUPS_PPDS],
349               [(automatic)])
350
351if test "$BUILD_CUPS_1_2" = yes -a "$BUILD_TRANSLATED_CUPS_PPDS" = yes ; then
352   BUILD_GLOBALIZED_CUPS_PPDS=yes
353else
354   BUILD_GLOBALIZED_CUPS_PPDS=no
355fi
356
357STP_ARG_ENABLE([globalized-cups-ppds],
358               [build globalized CUPS PPD files],
359               [BUILD_GLOBALIZED_CUPS_PPDS],
360               [(automatic)])
361
362STP_ARG_ENABLE_DETAILED([simplified-cups-ppds],
363			[],
364			[build simplified CUPS PPD files],
365			[(options: yes, no, only)],
366			[BUILD_SIMPLIFIED_CUPS_PPDS],
367			[no],
368			[
369    yes) [WHICH_PPDS]="-a"; BUILD_SIMPLIFIED_CUPS_PPDS=yes; AC_MSG_RESULT([yes]) ;;
370    no) [WHICH_PPDS]=""; BUILD_SIMPLIFIED_CUPS_PPDS=no; AC_MSG_RESULT([no]) ;;
371    only) [WHICH_PPDS]="-s"; BUILD_SIMPLIFIED_CUPS_PPDS=only; AC_MSG_RESULT([only]) ;;
372    *) AC_MSG_ERROR([${enableval}: not a valid option ('yes', 'no', or 'only')]) ;;
373				   ])
374
375STP_ARG_ENABLE([cups-ppds-at-top-level],
376	       [place CUPS PPD files at top level],
377	       [CUPS_PPDS_AT_TOP_LEVEL],
378	       [no])
379
380STP_ARG_ENABLE([cups-level3-ppds],
381               [generate PostScript level 3 PPD files],
382               [USE_LEVEL3_PS],
383               [(automatic)])
384
385STATIC_GENPPD="$enable_static"
386STP_ARG_ENABLE([static-genppd],
387               [build a statically-linked cups-genppd and rastertogutenprint.  WARNING: Please read the README and NEWS (release notes) CAREFULLY before using --disable-static-genppd!],
388	       [STATIC_GENPPD],
389	       [(automatic)])
390
391ENABLE_STATIC="$enable_static"
392AC_DEFINE_UNQUOTED(ENABLE_STATIC, "${ENABLE_STATIC}", [Static libraries are built.])
393AC_SUBST(ENABLE_STATIC)
394
395ENABLE_SHARED="$enable_shared"
396AC_DEFINE_UNQUOTED(ENABLE_SHARED, "${ENABLE_SHARED}", [Shared libraries are built.])
397AC_SUBST(ENABLE_SHARED)
398
399STP_ARG_WITH_DETAILED([modules],
400                      [],
401                      [enable loadable modules],
402	              [(options: ltdl, dlopen, static)],
403	              [WITH_MODULES],
404	              [(automatic)],[
405    yes) [WITH_MODULES]="yes";  AC_MSG_RESULT([yes]) ;;
406    no) [WITH_MODULES]="no";  AC_MSG_RESULT([no]) ;;
407    ltdl) [WITH_MODULES]="ltdl";  AC_MSG_RESULT([ltdl]) ;;
408    dlopen) [WITH_MODULES]="dlopen";  AC_MSG_RESULT([dlopen]) ;;
409    static) [WITH_MODULES]="static";  AC_MSG_RESULT([static]) ;;
410    *) AC_MSG_ERROR([${withval}: not a valid module loader]) ;;
411                      ],[
412    # if static libraries are enabled, modules must be static
413    if test x$enable_static = xyes; then
414      [WITH_MODULES]="static"
415    else
416      [WITH_MODULES]="yes"]
417    fi)
418
419# Abort if a broken configuration was required
420if test x$enable_static = xyes; then
421  if test $WITH_MODULES = no; then
422    :
423  elif test $WITH_MODULES = static; then
424    :
425  else
426    AC_MSG_ERROR([--disable-static must be used with --with-modules])
427  fi
428fi
429
430STP_ARG_ENABLE([debug],
431               [turn on debugging in build],
432               [ENABLE_DEBUG],
433               [no])
434
435STP_ARG_ENABLE([profile],
436               [turn on profiling in build],
437               [ENABLE_PROFILE],
438               [no])
439
440STP_ARG_WITH_DETAILED([readline], ,
441                      [use readline],
442                      [(default tries -lncurses, -lcurses, -ltermcap)],
443                      [USE_READLINE],
444                      [yes],[
445    yes) [USE_READLINE]="yes" ; AC_MSG_RESULT([yes]) ;;
446    no) [USE_READLINE]="no" ; AC_MSG_RESULT([no]) ;;
447    only) [USE_READLINE]="yes"
448          [EXTRA_LIBREADLINE_DEPS]=" "
449          AC_MSG_RESULT([yes (using only readline)]) ;;
450    *) [USE_READLINE]="yes"
451       [EXTRA_LIBREADLINE_DEPS]="${withval}"
452       AC_MSG_RESULT([yes (using extra libraries ${withval})]) ;;
453             ])
454dnl if test -z "${[EXTRA_LIBREADLINE_DEPS]}" ; then
455dnl   [EXTRA_LIBREADLINE_DEPS]=""
456dnl fi
457
458# libusb-1.0 (For CUPS backends, but only bother if CUPS is enabled)
459AS_IF([test "x$BUILD_CUPS" = "xyes"], [
460 PKG_CHECK_MODULES([LIBUSB], [libusb-1.0],
461                   [HAVE_LIBUSB=yes
462                    BUILD_LIBUSB_BACKENDS=yes],
463                   [HAVE_LIBUSB=no
464	            BUILD_LIBUSB_BACKENDS=no])
465])
466
467STP_ARG_ENABLE([user-install],
468               [install GIMP plugin in home directory],
469               [USER_INSTALL],
470               [no])
471if test x$USER_INSTALL = xyes ; then
472  PLUG_IN_PATH="bin"
473else
474  PLUG_IN_PATH="admin-bin"
475fi
476
477AC_PATH_TOOL([GIMPTOOL2_CHECK], [gimptool-2.0 gimptool])
478if test -z "${GIMPTOOL2_CHECK}" ; then
479  BUILD_GIMP2="no"
480else
481  # Check we have version 2.0
482  gimptool_check_version=`${GIMPTOOL2_CHECK} --version`
483dnl Quote to protect sed regexes
484  [gimptool_check_major=`echo "$gimptool_check_version" | sed -e 's/\([0-9][0-9]*\).\([0-9][0-9]*\).\([0-9][0-9]*\).*/\1/'`]
485  [gimptool_check_minor=`echo "$gimptool_check_version" | sed -e 's/\([0-9][0-9]*\).\([0-9][0-9]*\).\([0-9][0-9]*\).*/\2/'`]
486  if test "$gimptool_check_major" -eq 2; then
487    BUILD_GIMP2="yes"
488    if test "$gimptool_check_minor" -ge 4 ; then
489      BUILD_GIMP2_AS_GUTENPRINT="yes"
490    else
491      BUILD_GIMP2_AS_GUTENPRINT="no"
492    fi
493  else
494    BUILD_GIMP2="no"
495    BUILD_GIMP2_AS_GUTENPRINT="no"
496  fi
497  if test x${BUILD_GIMP2} = xyes ; then
498    AC_MSG_CHECKING([for GIMP 2.0 plug-in directory])
499    GIMPTOOL2_OUTPUT=`$GIMPTOOL2_CHECK --dry-run --install-${PLUG_IN_PATH} print | tail -n 1`
500    GIMP2_PLUGIN_DIR=`echo "$GIMPTOOL2_OUTPUT" | cut -d ' ' -f 3 | tr -d "\'"`
501    AC_MSG_RESULT([$GIMP2_PLUGIN_DIR])
502    if test "x$NO_PKGCONFIG_PATHS" = x; then
503      gimp2_plug_indir="${GIMP2_PLUGIN_DIR}"
504    else
505      gimp2_plug_indir="${prefix}/lib/gimp/2.0/plug-ins"
506    fi
507
508  fi
509fi
510
511PKG_CHECK_MODULES([GTK2], [gtk+-2.0],
512                  [HAVE_GTK2=yes
513                   BUILD_LIBGUTENPRINTUI2=yes
514                   GUTENPRINTUI2_LIBDEPS="${GUTENPRINTUI2_LIBDEPS} ${GTK2_LIBS}"],
515                  [HAVE_GTK2=no
516	           BUILD_LIBGUTENPRINTUI2=no])
517# Require both gimptool and pkg-config to succeed
518AS_IF([test "x$BUILD_GIMP2" = "xyes"], [
519  PKG_CHECK_MODULES([GIMP2], [gimpui-2.0], [BUILD_GIMP2=yes], [BUILD_GIMP2=no])
520])
521
522STP_ARG_WITH([gimp2],
523             [build GIMP 2.x Print plugin],
524             [BUILD_GIMP2],
525             [(automatic)])
526
527STP_ARG_WITH([gimp2-as-gutenprint],
528             [name GIMP 2.x Print plugin gutenprint (requires GIMP 2.2; normally used with GIMP 2.4 or above)],
529             [BUILD_GIMP2_AS_GUTENPRINT],
530             [(automatic)])
531
532STP_ARG_ENABLE([libgutenprintui2],
533               [build Gutenprint GTK+-2.0 user interface library],
534               [BUILD_LIBGUTENPRINTUI2],
535               [(automatic)])
536
537STP_ARG_ENABLE([samples],
538               [install sample images],
539               [INSTALL_SAMPLES],
540               [yes])
541
542STP_ARG_ENABLE([escputil],
543               [build escputil],
544               [BUILD_ESCPUTIL],
545               [yes])
546
547STP_ARG_ENABLE([test],
548               [build test programs],
549               [BUILD_TEST],
550               [yes])
551
552STP_ARG_WITH([doc],
553	     [build Gutenprint documentation],
554	     [BUILD_DOC],
555	     [yes])
556
557if test "$BUILD_TEST" = "yes" ; then
558  BUILD_TESTPATTERN="yes"
559else
560  BUILD_TESTPATTERN="no"
561fi
562
563STP_ARG_ENABLE([testpattern],
564               [build testpattern generator],
565               [BUILD_TESTPATTERN],
566               [(automatic)])
567
568dnl aclocal flags.
569dnl AM_ACLOCAL_INCLUDE(m4 m4local)
570
571dnl Checks for programs used in the build process
572AM_ICONV_LINK
573AC_SEARCH_LIBS([strerror],[cposix])
574AC_PROG_AWK
575AC_PROG_CC
576AM_PROG_CC_STDC
577AM_PROG_CC_C_O
578AC_PROG_INSTALL
579AC_PROG_LN_S
580AM_PROG_LEX
581AC_PROG_YACC
582AC_PROG_MKDIR_P
583AC_PATH_PROG([TEST], [test])
584AC_PATH_PROG([TRUE], [true])
585AC_PATH_PROG([FIND], [find])
586AC_PATH_PROG([PERL], [perl])
587AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums])
588AC_PATH_PROG([CONVERT], [convert])
589AC_PATH_PROG([BASHREAL], [bash])
590if test x${USE_MAINTAINER_MODE} = xyes ; then
591  if test x${CONVERT} = x ; then
592    AC_MSG_WARN([PostScript developer's guide cannot be regenerated!])
593  fi
594fi
595AC_PATH_PROG(TEXI2HTML, texi2html)
596if test x${USE_MAINTAINER_MODE} = xyes ; then
597  if test x${TEXI2HTML} = x ; then
598    AC_MSG_WARN([HTML documentation cannot be regenerated!])
599  fi
600fi
601AC_PATH_PROG(DVIPS, dvips)
602if test x${USE_MAINTAINER_MODE} = xyes ; then
603  if test x${DVIPS} = x ; then
604    AC_MSG_WARN([PostScript documentation cannot be regenerated!])
605  fi
606fi
607AC_PATH_PROG(DB2PDF, db2pdf)
608if test x${USE_MAINTAINER_MODE} = xyes ; then
609  if test x${DB2PDF} = x ; then
610    AC_MSG_WARN([PDF developer's guide cannot be regenerated!])
611  fi
612fi
613AC_PATH_PROGS(DVIPDF, dvipdf dvipdfm)
614if test x${USE_MAINTAINER_MODE} = xyes ; then
615  if test x${DVIPDF} = x ; then
616    AC_MSG_WARN([PDF documentation cannot be regenerated!])
617  fi
618fi
619AC_PATH_PROG(DB2PS, db2ps)
620if test x${USE_MAINTAINER_MODE} = xyes ; then
621  if test x${DB2PS} = x ; then
622    AC_MSG_WARN([PostScript developer's guide cannot be regenerated!])
623  fi
624fi
625AC_PATH_PROG(DB2HTML, db2html)
626if test x${USE_MAINTAINER_MODE} = xyes ; then
627  if test x${DB2HTML} = x ; then
628    AC_MSG_WARN([HTML developer's guide cannot be regenerated!])
629  fi
630fi
631AC_PATH_PROG(DOXYGEN, doxygen)
632if test x${USE_MAINTAINER_MODE} = xyes ; then
633  if test x${DOXYGEN} = x ; then
634    AC_MSG_WARN([HTML developer's guide cannot be regenerated!])
635  fi
636fi
637
638AC_PATH_PROG([XZ], [xz])
639AC_PATH_PROG([GZIP], [gzip])
640AC_PATH_PROG([BZIP2], [bzip2])
641AC_PATH_PROG([LRZIP], [lrzip])
642AC_PATH_PROG([RZIP], [rzip])
643AC_PATH_PROG([ZPAQ], [zpaq])
644AC_PATH_PROG([BASH], [bash])
645if test x${ZPAQ} != x ; then
646  COMPRESS='$(top_builddir)/scripts/wzpaq -z -q'
647  CSUF=.zpaq
648elif test x${LRZIP} != x ; then
649  COMPRESS="${LRZIP} -z -q"
650  CSUF=.lrz
651elif test x${XZ} != x ; then
652  COMPRESS="${XZ} -e -9"
653  CSUF=.xz
654elif test x${RZIP} != x ; then
655  COMPRESS="${RZIP} -9"
656  CSUF=.rz
657elif test x${BZIP2} != x ; then
658  COMPRESS="${BZIP2} -9"
659  CSUF=.bz2
660else
661  COMPRESS="${GZIP} -9"
662  CSUF=.gz
663fi
664AC_SUBST(COMPRESS)
665AC_SUBST(CSUF)
666
667GUTENPRINT_RELEASE_VERSION=${GUTENPRINT_MAJOR_VERSION}.${GUTENPRINT_MINOR_VERSION}
668AH_TEMPLATE(GUTENPRINT_RELEASE_VERSION,, [Gutenprint release version])
669AC_DEFINE_UNQUOTED(GUTENPRINT_RELEASE_VERSION, "${GUTENPRINT_RELEASE_VERSION}")
670GUTENPRINT_BASE_VERSION=${GUTENPRINT_MAJOR_VERSION}.${GUTENPRINT_MINOR_VERSION}.${GUTENPRINT_MICRO_VERSION}
671AH_TEMPLATE(GUTENPRINT_BASE_VERSION,, [Gutenprint base version])
672AC_DEFINE_UNQUOTED(GUTENPRINT_BASE_VERSION, "${GUTENPRINT_BASE_VERSION}")
673
674dnl Set PACKAGE_LOCALE_DIR in config.h
675AH_TEMPLATE(PACKAGE_LOCALE_DIR,, [Package locale directory])
676if test "x${prefix}" = "xNONE"; then
677  AC_DEFINE_UNQUOTED(PACKAGE_LOCALE_DIR, ["${ac_default_prefix}/share/locale"])
678else
679  AC_DEFINE_UNQUOTED(PACKAGE_LOCALE_DIR, ["${prefix}/share/locale"])
680fi
681
682dnl Set PACKAGE_DATA_DIR in config.h.
683AH_TEMPLATE(PACKAGE_DATA_DIR,, [Package data directory])
684if test "x${datadir}" = 'x${prefix}/share'; then
685  if test "x${prefix}" = "xNONE"; then
686    PACKAGE_DATA_DIR="${ac_default_prefix}/share/${PACKAGE}"
687  else
688    PACKAGE_DATA_DIR="${prefix}/share/${PACKAGE}"
689  fi
690elif test "x${datadir}" = 'x${datarootdir}'; then
691  if test "x${datarootdir}" = 'x${prefix}/share'; then
692    if test "x${prefix}" = "xNONE"; then
693      PACKAGE_DATA_DIR="${ac_default_prefix}/share/${PACKAGE}"
694    else
695      PACKAGE_DATA_DIR="${prefix}/share/${PACKAGE}"
696    fi
697  else
698    PACKAGE_DATA_DIR="${datarootdir}/${PACKAGE}"
699  fi
700else
701  PACKAGE_DATA_DIR="${datadir}/${PACKAGE}"
702fi
703
704AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${PACKAGE_DATA_DIR}")
705
706dnl Set PACKAGE_LIB_DIR in config.h.
707AH_TEMPLATE(PACKAGE_LIB_DIR,, [Package lib directory])
708if test "x${libdir}" = 'x${exec_prefix}/lib'; then
709  if test "x${exec_prefix}" = "xNONE"; then
710    if test "x${prefix}" = "xNONE"; then
711      PACKAGE_LIB_DIR="${ac_default_prefix}/lib/${PACKAGE}"
712    else
713      PACKAGE_LIB_DIR="${prefix}/lib/${PACKAGE}"
714    fi
715  else
716    PACKAGE_LIB_DIR="${exec_prefix}/lib/${PACKAGE}"
717  fi
718else
719  PACKAGE_LIB_DIR="${libdir}/${PACKAGE}"
720fi
721
722AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, ["${PACKAGE_LIB_DIR}"])
723
724dnl Set PACKAGE_BIN_DIR in config.h.
725AH_TEMPLATE(PACKAGE_BIN_DIR,, [Package bin directory])
726if test "x${bindir}" = 'x${exec_prefix}/bin'; then
727  if test "x${exec_prefix}" = "xNONE"; then
728    if test "x${prefix}" = "xNONE"; then
729      PACKAGE_BIN_DIR="${ac_default_prefix}/bin"
730    else
731      PACKAGE_BIN_DIR="${prefix}/bin"
732    fi
733  else
734    PACKAGE_BIN_DIR="${exec_prefix}/bin"
735  fi
736else
737  PACKAGE_BIN_DIR="${bindir}"
738fi
739
740AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, ["${PACKAGE_BIN_DIR}"])
741
742AH_TEMPLATE(PKGXMLDATADIR,, [Package XML data directory])
743PKGXMLDATADIR="${PACKAGE_DATA_DIR}/${GUTENPRINT_RELEASE_VERSION}/xml"
744AC_DEFINE_UNQUOTED(PKGXMLDATADIR, ["$PKGXMLDATADIR"], )
745
746AH_TEMPLATE(PKGMODULEDIR,, [Package module directory])
747PKGMODULEDIR="${PACKAGE_LIB_DIR}/${GUTENPRINT_RELEASE_VERSION}/modules"
748AC_DEFINE_UNQUOTED(PKGMODULEDIR, ["$PKGMODULEDIR"])
749
750dnl Compiler flags
751if test x$ac_compiler_gnu = "xyes"; then
752  STP_ADD_COMPILER_ARGS([-Wall -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wwrite-strings -Werror-implicit-function-declaration -Winline -Wformat=2 -finline-limit=131072 -Wformat -Werror=format-security -Wmissing-prototypes],, [GNUCFLAGS])
753  if test x${USE_MAINTAINER_MODE} = xyes ; then
754    STP_ADD_COMPILER_ARGS([-D_POSIX_C_SOURCE=200809L -std=c99 -pedantic -Waggregate-return -Wcast-qual -Wshadow -Wredundant-decls],, [GNUCFLAGS])
755  fi
756  if test x$ENABLE_DEBUG = xyes ; then
757    STP_ADD_COMPILER_ARG([-g])
758  else
759    STP_ADD_FIRST_COMPILER_ARG([-O3 -O2 -O1 -O])
760  fi
761else
762  if test x$ENABLE_DEBUG = xyes ; then
763    STP_ADD_COMPILER_ARG([-g])
764  else
765    STP_ADD_FIRST_COMPILER_ARG([-O])
766  fi
767fi
768if test x$ENABLE_PROFILE = xyes ; then
769  STP_ADD_COMPILER_ARG([-pg])
770fi
771AC_SUBST(GNUCFLAGS)
772
773AH_TEMPLATE([HAVE_GCC_ATTRIBUTES],
774            [Define to 1 if GCC special attributes are supported])
775AC_MSG_CHECKING([if $CC supports __attribute__ syntax])
776AC_COMPILE_IFELSE([AC_LANG_PROGRAM([typedef struct __attribute__((__packed__)) {
777   unsigned char foo;
778   char bar;
779   long baz;
780} test_struct_t;],
781                                   [test_struct_t mystruct;])],
782                  [AC_MSG_RESULT([yes])]
783                   AC_DEFINE([HAVE_GCC_ATTRIBUTES], 1),
784                  [AC_MSG_RESULT([no])])
785
786AH_VERBATIM([HAVE_GCC_ATTRIBUTES_BOILERPLATE],
787[#if !defined(HAVE_GCC_ATTRIBUTES) && !defined(__attribute__)
788/* This should really be a C99 anonymous variadic macro. */
789#define __attribute__(attr)
790#endif])
791
792dnl Checks for libraries.
793dnl When checking readline, check using extra libraries first.
794dnl We want to protect against the link somehow succeeding, but only
795dnl failing at runtime, as seems to happen on some BSD systems.
796AH_TEMPLATE(HAVE_LIBREADLINE, [Is libreadline present?])
797if test "$USE_READLINE" = yes ; then
798  if test "$EXTRA_LIBREADLINE_DEPS" = "" ; then
799    unset ac_cv_lib_readline_readline
800    AC_CHECK_LIB(readline, readline, HAVE_LIBREADLINE=true,
801		 HAVE_LIBREADLINE=false, -lncurses)
802    if test x${HAVE_LIBREADLINE} = xtrue ; then
803      echo "  Using -lreadline -lncurses"
804      EXTRA_LIBREADLINE_DEPS=-lncurses
805      AC_DEFINE(HAVE_LIBREADLINE, [1])
806    else
807      unset ac_cv_lib_readline_readline
808      AC_CHECK_LIB(readline, readline, HAVE_LIBREADLINE=true,
809		   HAVE_LIBREADLINE=false, -lcurses)
810      if test x${HAVE_LIBREADLINE} = xtrue ; then
811	echo "  Using -lreadline -lcurses"
812	EXTRA_LIBREADLINE_DEPS=-lcurses
813	AC_DEFINE(HAVE_LIBREADLINE, [1])
814      else
815	unset ac_cv_lib_readline_readline
816	AC_CHECK_LIB(readline, readline, HAVE_LIBREADLINE=true,
817		     HAVE_LIBREADLINE=false, -ltermcap)
818	if test x${HAVE_LIBREADLINE} = xtrue ; then
819	  echo "  Using -lreadline -ltermcap"
820	  EXTRA_LIBREADLINE_DEPS=-ltermcap
821	  AC_DEFINE(HAVE_LIBREADLINE, [1])
822	else
823	  unset ac_cv_lib_readline_readline
824	  AC_CHECK_LIB(readline, readline, HAVE_LIBREADLINE=true,
825		       HAVE_LIBREADLINE=false)
826	  if test x${HAVE_LIBREADLINE} = xtrue ; then
827	    AC_DEFINE(HAVE_LIBREADLINE, [1])
828	  else
829	    AC_DEFINE(HAVE_LIBREADLINE, [0])
830	  fi
831	fi
832      fi
833    fi
834  else
835    unset ac_cv_lib_readline_readline
836    AC_CHECK_LIB(readline, readline, HAVE_LIBREADLINE=true,
837		 HAVE_LIBREADLINE=false, ${EXTRA_LIBREADLINE_DEPS})
838    if test x${HAVE_LIBREADLINE} = xtrue ; then
839      echo "  Using -lreadline ${EXTRA_LIBREADLINE_DEPS}"
840      AC_DEFINE(HAVE_LIBREADLINE, [1])
841    else
842      AC_DEFINE(HAVE_LIBREADLINE, [0])
843    fi
844  fi
845else
846  HAVE_LIBREADLINE=false
847  AC_DEFINE(HAVE_LIBREADLINE, [0])
848fi
849
850dnl libltdl, used for dynamic module loading
851AC_CHECK_LIB(ltdl, lt_dlopen, [LTDL_LIBS="-lltdl"])
852
853AC_CHECK_LIB(dl, dlopen, [DLOPEN_LIBS="-ldl"])
854
855AC_CHECK_LIB(m,pow,
856             GUTENPRINT_LIBDEPS="${GUTENPRINT_LIBDEPS} -lm"
857             gutenprint_libdeps="${gutenprint_libdeps} -lm"
858             GUTENPRINTUI2_LIBDEPS="${GUTENPRINTUI2_LIBDEPS} -lm"
859             gutenprintui2_libdeps="${gutenprintui2_libdeps} -lm"
860	     LIBM=-lm
861)
862
863dnl CUPS stuff
864STP_CUPS_PATH
865STP_CUPS_LIBS
866
867dnl Checks for header files.
868AC_HEADER_STDC
869AC_CHECK_HEADERS(getopt.h)
870AC_CHECK_HEADER(readline/readline.h,
871  HAVE_READLINE_READLINE_H=true,
872  HAVE_READLINE_READLINE_H=false)
873if test x${HAVE_READLINE_READLINE_H} = xtrue ; then
874  AC_DEFINE(HAVE_READLINE_READLINE_H,, [Define if libreadline header is present.])
875  if test x${HAVE_LIBREADLINE} = xtrue ; then
876    LIBREADLINE_DEPS="-lreadline $EXTRA_LIBREADLINE_DEPS"
877  fi
878fi
879AC_CHECK_HEADERS(dlfcn.h, [HAVE_DLFCN_H=true])
880AC_CHECK_HEADERS(fcntl.h)
881AC_CHECK_HEADERS(limits.h)
882AC_CHECK_HEADERS(locale.h)
883AC_CHECK_HEADERS(ltdl.h, [HAVE_LTDL_H=true])
884AC_CHECK_HEADERS(stdarg.h stdlib.h string.h)
885AC_CHECK_HEADERS(sys/time.h sys/types.h)
886AC_CHECK_HEADERS(time.h)
887AC_CHECK_HEADERS(unistd.h)
888
889dnl Checks for typedefs, structures, and compiler characteristics.
890AC_C_CONST
891AC_C_INLINE
892AC_TYPE_OFF_T
893AC_TYPE_SIZE_T
894
895dnl Checks for library functions.
896AC_CHECK_FUNCS([nanosleep poll usleep])
897AC_CHECK_FUNCS([getopt_long])
898
899dnl finite() is non-standard, isfinite() is ISO-standard, figure out
900dnl which to use...
901AC_SEARCH_LIBS(finite, m, CFLAGS="-Disfinite=finite $CFLAGS")
902
903dnl Define what has to be built
904AM_CONDITIONAL(BUILD_CUPS, test x${BUILD_CUPS} = xyes)
905
906AM_CONDITIONAL(BUILD_CUPS_1_2, test x${BUILD_CUPS_1_2} = xyes)
907
908AM_CONDITIONAL(BUILD_CUPS_PPDS, test x${BUILD_CUPS_PPDS} = xyes)
909
910AM_CONDITIONAL(CUPS_PPDS_AT_TOP_LEVEL, test x${CUPS_PPDS_AT_TOP_LEVEL} = xyes)
911
912AM_CONDITIONAL(BUILD_TRANSLATED_CUPS_PPDS, test x${BUILD_TRANSLATED_CUPS_PPDS} = xyes )
913
914AM_CONDITIONAL(BUILD_GLOBALIZED_CUPS_PPDS, test x${BUILD_GLOBALIZED_CUPS_PPDS} = xyes )
915
916AM_CONDITIONAL(BUILD_SIMPLIFIED_CUPS_PPDS, test x${BUILD_SIMPLIFIED_CUPS_PPDS} = xyes)
917
918if test x${USE_LEVEL3_PS} = xno ; then
919  CUPS_PPD_PS_LEVEL=2
920else
921  CUPS_PPD_PS_LEVEL=3
922fi
923
924AM_CONDITIONAL(USE_LEVEL3_PS, test x${USE_LEVEL3_PS} = xyes)
925
926AM_CONDITIONAL(BUILD_ESCPUTIL, test x${BUILD_ESCPUTIL} = xyes)
927
928AM_CONDITIONAL(BUILD_TEST, test x${BUILD_TEST} = xyes)
929
930AM_CONDITIONAL(BUILD_TESTPATTERN, test x${BUILD_TESTPATTERN} = xyes)
931
932AM_CONDITIONAL(BUILD_LIBGUTENPRINTUI2, test x${BUILD_LIBGUTENPRINTUI2} = xyes)
933
934AM_CONDITIONAL(BUILD_GIMP2, test x${BUILD_GIMP2} = xyes)
935
936AM_CONDITIONAL(BUILD_DOC, test x${BUILD_DOC} = xyes)
937
938AM_CONDITIONAL(BUILD_GIMP2_AS_GUTENPRINT, test x${BUILD_GIMP2_AS_GUTENPRINT} = xyes)
939
940AM_CONDITIONAL(INSTALL_SAMPLES, test x${INSTALL_SAMPLES} = xyes)
941
942AM_CONDITIONAL(INSTALL_USER_GUIDE, test x${INSTALL_USER_GUIDE} = xyes)
943
944AM_CONDITIONAL(BUILD_LIBUSB_BACKENDS, test x${BUILD_LIBUSB_BACKENDS} = xyes)
945
946
947# loadable modules
948# portable sh has no AND test...
949if test -n "$HAVE_LTDL_H"; then
950  if test -n "$LTDL_LIBS"; then
951    LTDL_POSSIBLE="true"
952  fi
953fi
954if test -n "$HAVE_DLFCN_H"; then
955  if test -n "$DLOPEN_LIBS"; then
956    DLOPEN_POSSIBLE="true"
957  fi
958fi
959
960# define what the user chose to build, if possible.
961# Prefer dlopen over ltdl.
962if test x$WITH_MODULES = xyes; then
963  if test x$DLOPEN_POSSIBLE = xtrue; then
964    USE_DLOPEN="true"
965  elif test x$LDTL_POSSIBLE = xtrue; then
966    USE_LTDL="true"
967  fi
968elif test x$WITH_MODULES = xltdl; then
969  if test x$LTDL_POSSIBLE = xtrue; then
970    USE_LTDL="true"
971  fi
972elif test x$WITH_MODULES = xdlopen; then
973  if test x$DLOPEN_POSSIBLE = xtrue; then
974    USE_DLOPEN="true"
975  fi
976fi
977
978# The current backends can use dlopen or libltdl
979if test x$BUILD_LIBUSB_BACKENDS = xyes; then
980  if test x$DLOPEN_POSSIBLE = xtrue; then
981    USE_DLOPEN="true"
982  elif test x$LDTL_POSSIBLE = xtrue; then
983    USE_LTDL="true"
984  fi
985fi
986
987# define what module system is to be used
988AC_MSG_CHECKING([which module system will be used])
989if test x$USE_LTDL = xtrue; then
990  if test -z "$WITH_MODULES" -o x$WITH_MODULES = xno -o x$WITH_MODULES = xstatic ; then
991    MODULE="false"
992  else
993    MODULE="true"
994    AC_DEFINE(MODULE, "1", [Build a modular libgutenprint])
995    GUTENPRINT_LIBDEPS="${GUTENPRINT_LIBDEPS} ${LTDL_LIBS}"
996    gutenprint_libdeps="${gutenprint_libdeps} ${LTDL_LIBS}"
997  fi
998  LIBUSB_BACKEND_LIBDEPS="${LIBUSB_BACKEND_LIBDEPS} ${LTDL_LIBS}"
999  AC_DEFINE(USE_LTDL, "1", [Use GNU libltdl as module loader])
1000  AC_MSG_RESULT([ltdl])
1001elif test x$USE_DLOPEN = xtrue; then
1002  if test -z "$WITH_MODULES" -o x$WITH_MODULES = xno -o x$WITH_MODULES = xstatic ; then
1003    MODULE="false"
1004  else
1005    MODULE="true"
1006    AC_DEFINE(MODULE, "1", [Build a modular libgutenprint])
1007    GUTENPRINT_LIBDEPS="${GUTENPRINT_LIBDEPS} ${DLOPEN_LIBS}"
1008    gutenprint_libdeps="${gutenprint_libdeps} ${DLOPEN_LIBS}"
1009  fi
1010  LIBUSB_BACKEND_LIBDEPS="${LIBUSB_BACKEND_LIBDEPS} ${DLOPEN_LIBS}"
1011  AC_DEFINE(USE_DLOPEN, "1", [Use libdl/dlopen as module loader])
1012  AC_MSG_RESULT([dlopen])
1013else
1014  MODULE="false"
1015  AC_MSG_RESULT([static])
1016fi
1017AM_CONDITIONAL(BUILD_MODULES, test x$MODULE = xtrue)
1018
1019AM_CONDITIONAL(BUILD_GENPPD_STATIC, test x"$STATIC_GENPPD" = xyes)
1020
1021dnl Define LTLIBOBJS
1022AC_CONFIG_COMMANDS_PRE(
1023[LTLIBOBJS=`echo "$LIB@&t@OBJS" | sed 's/\.o/.lo/g'`
1024AC_SUBST(LTLIBOBJS)
1025LTALLOCA=`echo "$ALLOCA" | sed 's/\.o/.lo/g'`
1026AC_SUBST(LTALLOCA)])
1027
1028dnl Definitions
1029AC_DEFINE_UNQUOTED(CUPS_DATADIR, "${cups_conf_datadir}", [CUPS data directory.])
1030
1031AH_TEMPLATE(CUPS_MODELDIR,, [CUPS PPD file directory])
1032if test "${CUPS_PPDS_AT_TOP_LEVEL}" = yes ; then
1033  AC_DEFINE_UNQUOTED(CUPS_MODELDIR, "${cups_conf_datadir}/model/")
1034else
1035  AC_DEFINE_UNQUOTED(CUPS_MODELDIR, "${cups_conf_datadir}/model/${PACKAGE}/${GUTENPRINT_RELEASE_VERSION}/")
1036fi
1037
1038AC_ARG_WITH(cups_nickname, [  --with-cups-nickname="nickname suffix"
1039                          Suffix to add to PPD NickName, default=" - CUPS+Gutenprint v"],
1040  CUPS_PPD_NICKNAME_STRING="$withval",
1041  CUPS_PPD_NICKNAME_STRING=" - CUPS+Gutenprint v")
1042
1043AH_TEMPLATE(CUPS_PPD_NICKNAME_STRING,, [CUPS PPD Nickname string])
1044AC_DEFINE_UNQUOTED(CUPS_PPD_NICKNAME_STRING, "$CUPS_PPD_NICKNAME_STRING")
1045
1046
1047AC_DEFINE_UNQUOTED(CUPS_PPD_PS_LEVEL, ${CUPS_PPD_PS_LEVEL}, [CUPS PPD PostScript level])
1048STP_RELEASE_DATE
1049
1050MINIMAL_PRINTERS_TO_TEST="escp2-r1800 escp2-3880 \
1051	pcl-g_4 pcl-g_5c pcl-500 \
1052	mitsubishi-p95d shinko-chcs2145 kodak-1400 canon-cp910 mitsubishi-9800d \
1053	bjc-s200 bjc-PIXMA-Pro9000mk2 \
1054	datamax_oneil_I4212e \
1055	lexmark-z43"
1056
1057AC_DEFINE_UNQUOTED(MINIMAL_PRINTERS_TO_TEST, ${MINIMAL_PRINTERS_TO_TEST},
1058					     [Printers to test in minimal run])
1059
1060dnl Some versions of make get very grouchy about $(RM)
1061RM='rm'
1062
1063PKGROOT=`pwd`
1064
1065dnl Substitutions
1066AC_SUBST(prefix)
1067AC_SUBST(exec_prefix)
1068AC_SUBST(cups_prefix)
1069AC_SUBST(cups_exec_prefix)
1070AC_SUBST(cups_bindir)
1071AC_SUBST(cups_sbindir)
1072AC_SUBST(cups_conf_datadir)
1073AC_SUBST(cups_conf_serverbin)
1074AC_SUBST(cups_conf_serverroot)
1075AC_SUBST(CUPS_CFLAGS)
1076AC_SUBST(CUPS_LIBS)
1077AC_SUBST(CUPS_PPD_PS_LEVEL)
1078AC_SUBST(GENPPD_LIBS)
1079AC_SUBST(RM)
1080AC_SUBST(GIMP2_CFLAGS)
1081AC_SUBST(GIMP2_LIBS)
1082AC_SUBST(gimp2_plug_indir)
1083AC_SUBST(GUTENPRINT_CFLAGS)
1084AC_SUBST(GUTENPRINT_LIBS)
1085AC_SUBST(GUTENPRINT_LIBDEPS)
1086AC_SUBST(GUTENPRINT_VERSION)
1087AC_SUBST(GUTENPRINTUI2_CFLAGS)
1088AC_SUBST(GUTENPRINTUI2_LIBS)
1089AC_SUBST(GUTENPRINTUI2_LIBDEPS)
1090AC_SUBST(GUTENPRINTUI2_VERSION)
1091AC_SUBST(gutenprint_cflags)
1092gutenprint_libs="${GUTENPRINT_LIBS} ${gutenprint_libdeps}"
1093AC_SUBST(gutenprint_libs)
1094AC_SUBST(gutenprint_libdeps)
1095AC_SUBST(gutenprintui2_cflags)
1096gutenprintui2_libs="${GUTENPRINTUI2_LIBS} ${gutenprintui2_libdeps}"
1097AC_SUBST(gutenprintui2_libs)
1098AC_SUBST(gutenprintui2_libdeps)
1099AC_SUBST(LIBM)
1100AC_SUBST(LIBREADLINE_DEPS)
1101AC_SUBST(MAINTAINER_CFLAGS)
1102AC_SUBST(WHICH_PPDS)
1103AC_SUBST(BUILD_CUPS_PPDS)
1104AC_SUBST(GUTENPRINT_BASE_VERSION)
1105AC_SUBST(GUTENPRINT_RELEASE_VERSION)
1106AC_SUBST(LIBUSB_BACKEND_LIBDEPS)
1107AC_SUBST(PKGROOT)
1108AC_SUBST(MINIMAL_PRINTERS_TO_TEST)
1109
1110dnl Optional architecture options to be applied after all autoconf tests
1111dnl are done...
1112AC_ARG_WITH(archflags, [  --with-archflags="..."  additional options for CFLAGS and LDFLAGS],
1113    CFLAGS="$CFLAGS $withval"
1114    LDFLAGS="$LDFLAGS $withval")
1115
1116dnl Output files
1117
1118AC_CONFIG_FILES([Makefile])
1119AC_CONFIG_FILES([doc/Makefile])
1120AC_CONFIG_FILES([doc/gutenprint.dox])
1121AC_CONFIG_FILES([doc/gutenprintui2.dox])
1122AC_CONFIG_FILES([doc/developer/Makefile])
1123AC_CONFIG_FILES([include/Makefile])
1124AC_CONFIG_FILES([include/gutenprint/Makefile])
1125AC_CONFIG_FILES([include/gutenprintui2/Makefile])
1126AC_CONFIG_FILES([include/gutenprint/gutenprint-version.h])
1127AC_CONFIG_FILES([man/Makefile])
1128AC_CONFIG_FILES([man/cups-calibrate.8])
1129AC_CONFIG_FILES([man/cups-genppd.8])
1130AC_CONFIG_FILES([man/cups-genppdupdate.8])
1131AC_CONFIG_FILES([man/escputil.1])
1132AC_CONFIG_FILES([po/Makefile.in])
1133AC_CONFIG_FILES([samples/Makefile])
1134AC_CONFIG_FILES([src/Makefile])
1135AC_CONFIG_FILES([src/cups/Makefile])
1136AC_CONFIG_FILES([src/cups/Info.plist])
1137CONFIG_FILE_EXEC([src/cups/cups-genppdupdate])
1138CONFIG_FILE_EXEC([src/cups/test-ppds.test])
1139CONFIG_FILE_EXEC([src/cups/min-pagesize])
1140AC_CONFIG_FILES([src/escputil/Makefile])
1141CONFIG_FILE_EXEC([src/testpattern/compare-image-files])
1142CONFIG_FILE_EXEC([src/testpattern/run-testpattern])
1143CONFIG_FILE_EXEC([src/testpattern/run-testpattern-1.test])
1144CONFIG_FILE_EXEC([src/testpattern/run-testpattern-2])
1145CONFIG_FILE_EXEC([src/testpattern/run-testpattern-2.test])
1146CONFIG_FILE_EXEC([src/testpattern/compare-checksums])
1147CONFIG_FILE_EXEC([src/testpattern/compress-checksums])
1148CONFIG_FILE_EXEC([src/cups/test-rastertogutenprint])
1149CONFIG_FILE_EXEC([src/cups/test-rastertogutenprint.test])
1150AC_CONFIG_FILES([src/testpattern/Makefile])
1151AC_CONFIG_FILES([src/gimp2/Makefile])
1152AC_CONFIG_FILES([src/main/Makefile])
1153AC_CONFIG_FILES([src/main/gutenprint.pc])
1154AC_CONFIG_FILES([src/xml/Makefile])
1155AC_CONFIG_FILES([src/xml/dither/Makefile])
1156AC_CONFIG_FILES([src/xml/papers/Makefile])
1157AC_CONFIG_FILES([src/xml/printers/Makefile])
1158AC_CONFIG_FILES([src/xml/escp2/Makefile])
1159AC_CONFIG_FILES([src/xml/escp2/media/Makefile])
1160AC_CONFIG_FILES([src/xml/escp2/mediasizes/Makefile])
1161AC_CONFIG_FILES([src/xml/escp2/model/Makefile])
1162AC_CONFIG_FILES([src/xml/escp2/model/base/Makefile])
1163AC_CONFIG_FILES([src/xml/escp2/inputslots/Makefile])
1164AC_CONFIG_FILES([src/xml/escp2/inks/Makefile])
1165AC_CONFIG_FILES([src/xml/escp2/weaves/Makefile])
1166AC_CONFIG_FILES([src/xml/escp2/qualitypresets/Makefile])
1167AC_CONFIG_FILES([src/xml/escp2/resolutions/Makefile])
1168AC_CONFIG_FILES([src/gutenprintui2/Makefile])
1169AC_CONFIG_FILES([src/gutenprintui2/gutenprintui2.pc])
1170AC_CONFIG_FILES([test/Makefile])
1171CONFIG_FILE_EXEC([test/compress-5level.sh])
1172CONFIG_FILE_EXEC([test/compress-6level.sh])
1173CONFIG_FILE_EXEC([test/uncompress-5level.sh])
1174CONFIG_FILE_EXEC([test/uncompress-6level.sh])
1175CONFIG_FILE_EXEC([test/parse-bjc])
1176CONFIG_FILE_EXEC([test/parse-escp2])
1177CONFIG_FILE_EXEC([test/run-testdither.test])
1178CONFIG_FILE_EXEC([test/run-weavetest.test])
1179CONFIG_FILE_EXEC([test/test-curve.test])
1180AC_CONFIG_FILES([scripts/Makefile])
1181CONFIG_FILE_EXEC([scripts/mkgitlog])
1182CONFIG_FILE_EXEC([scripts/gversion])
1183CONFIG_FILE_EXEC([scripts/test-gversion])
1184CONFIG_FILE_EXEC([scripts/wzpaq])
1185AC_CONFIG_COMMANDS([default], [
1186echo
1187],
1188[GUTENPRINT_RELEASE_VERSION=${GUTENPRINT_RELEASE_VERSION}]
1189[GUTENPRINT_BASE_VERSION=${GUTENPRINT_BASE_VERSION}]
1190)
1191
1192AC_OUTPUT
1193
1194warnings_emitted=0
1195echo
1196echo "Gutenprint Configuration Summary:" |tee config.summary
1197echo "---------- ------------- --------" |tee -a config.summary
1198echo |tee -a config.summary
1199echo "If you have any problems, please report the information below to" |tee -a config.summary
1200echo "$PACKAGE_BUGREPORT" |tee -a config.summary
1201echo |tee -a config.summary
1202echo "================================================================" |tee -a config.summary
1203echo "  Release: $PACKAGE_STRING generated on $RELEASE_DATE" |tee -a config.summary
1204echo "  Generated at `date` by $LOGNAME" |tee -a config.summary
1205echo |tee -a config.summary
1206echo "  Features:" |tee -a config.summary
1207if test "$BUILD_CUPS" != "no" ; then
1208    echo "    Build CUPS:                                 $BUILD_CUPS, installing in $cups_prefix" |tee -a config.summary
1209    echo "        Build CUPS 1.2 enhancements:            $BUILD_CUPS_1_2" |tee -a config.summary
1210    echo "        Build CUPS PPD files:                   $BUILD_CUPS_PPDS" |tee -a config.summary
1211    if test "$BUILD_CUPS_PPDS" != "no" ; then
1212        echo "            Build translated CUPS PPD files:    $BUILD_TRANSLATED_CUPS_PPDS" |tee -a config.summary
1213        echo "                Build global CUPS PPD files:    $BUILD_GLOBALIZED_CUPS_PPDS" |tee -a config.summary
1214        echo "            Build simplified CUPS PPD files:    $BUILD_SIMPLIFIED_CUPS_PPDS" |tee -a config.summary
1215        echo "            Install CUPS PPDs at top level:     $CUPS_PPDS_AT_TOP_LEVEL" |tee -a config.summary
1216    fi
1217    if test "$BUILD_CUPS_PPDS" != "no" -o "$BUILD_CUPS_1_2" != "no" ; then
1218        echo "        Generate PS level 3 CUPS PPD files:     $USE_LEVEL3_PS" |tee -a config.summary
1219    fi
1220    echo "        Build genppd statically:                $STATIC_GENPPD" |tee -a config.summary
1221
1222    if test "$STATIC_GENPPD" = "no" ; then
1223        echo "            ***WARNING: Use of --disable-static-genppd or --disable-static" |tee -a config.summary
1224        echo "                        when building CUPS is very dangerous.  The build may" |tee -a config.summary
1225        echo "                        fail when building the PPD files, or may *SILENTLY*" |tee -a config.summary
1226        echo "                        build incorrect PPD files or cause other problems." |tee -a config.summary
1227        echo "                        Please review the README and release notes carefully!" |tee -a config.summary
1228        warnings_emitted=1
1229    fi
1230    echo "        Build CUPS dyesub USB backend:          $BUILD_LIBUSB_BACKENDS" |tee -a config.summary
1231else
1232    echo "    Build CUPS:                                 $BUILD_CUPS" |tee -a config.summary
1233fi
1234echo "    Build EPSON inkjet utility:                 $BUILD_ESCPUTIL" |tee -a config.summary
1235if test "$BUILD_GIMP2" != "no" ; then
1236    echo "    Build enhanced Print plugin for GIMP:       yes" |tee -a config.summary
1237    if test "$BUILD_GIMP2_AS_GUTENPRINT" != "no" ; then
1238        echo "        GIMP plugin will be named:              gutenprint" |tee -a config.summary
1239    else
1240        echo "        GIMP plugin will be named:              print" |tee -a config.summary
1241    fi
1242    echo "        Install plugin(s) in home directory:    $USER_INSTALL" |tee -a config.summary
1243else
1244    echo "    Build enhanced Print plugin for GIMP:       no" |tee -a config.summary
1245fi
1246echo "    Build test programs:                        $BUILD_TEST" |tee -a config.summary
1247echo "    Build testpattern generator:                $BUILD_TESTPATTERN" |tee -a config.summary
1248echo |tee -a config.summary
1249echo "  Installation summary:" |tee -a config.summary
1250echo "    Installation prefix:                        $prefix" |tee -a config.summary
1251# Configure intentionally does not expand exec_prefix to allow make
1252# to do so.
1253echo "    Exec prefix:                                `eval eval echo $exec_prefix` ($exec_prefix)" |tee -a config.summary
1254echo "    Data directory:                             $PACKAGE_DATA_DIR" |tee -a config.summary
1255echo "    Library directory:                          `eval eval echo $PACKAGE_LIB_DIR` ($PACKAGE_LIB_DIR)" |tee -a config.summary
1256echo "    Executable directory:                       `eval eval echo $PACKAGE_BIN_DIR` ($PACKAGE_BIN_DIR)" |tee -a config.summary
1257echo "    XML data directory:                         $PKGXMLDATADIR" |tee -a config.summary
1258echo "    Module directory:                           `eval eval echo $PKGMODULEDIR` ($PKGMODULEDIR)" |tee -a config.summary
1259echo "    Install sample images:                      $INSTALL_SAMPLES" |tee -a config.summary
1260echo |tee -a config.summary
1261echo "  General configuration:" |tee -a config.summary
1262echo "    Configure arguments:                        $configure_args" |tee -a config.summary
1263echo "    Compiler:                                   $CC" |tee -a config.summary
1264echo "    Compiler Version:                           `"$CC" -v 2>&1 |grep ' version '`" |tee -a config.summary
1265if test x$ac_compiler_gnu = "xyes"; then
1266    echo "    Compiler options:                           $CFLAGS $GNUCFLAGS" |tee -a config.summary
1267else
1268    echo "    Compiler options:                           $CFLAGS" |tee -a config.summary
1269fi
1270echo "    Build static libraries:                     $enable_static" |tee -a config.summary
1271echo "    Build shared libraries:                     $enable_shared" |tee -a config.summary
1272echo "    Maintainer mode:                            $USE_MAINTAINER_MODE" |tee -a config.summary
1273echo "    Use i18n:                                   $USE_NLS" |tee -a config.summary
1274echo "    Generate profiling information:             $ENABLE_PROFILE" |tee -a config.summary
1275echo "    Generate debugging symbols:                 $ENABLE_DEBUG" |tee -a config.summary
1276echo "    Use modules:                                $WITH_MODULES" |tee -a config.summary
1277if test -n "$EXTRA_LIBREADLINE_DEPS" ; then
1278    echo "    Use readline libraries:                     $USE_READLINE, extra arguments: $EXTRA_LIBREADLINE_DEPS" |tee -a config.summary
1279else
1280    echo "    Use readline libraries:                     $USE_READLINE" |tee -a config.summary
1281fi
1282echo "    uname -a output:                            `uname -a`" |tee -a config.summary
1283echo "================================================================" |tee -a config.summary
1284if test $warnings_emitted -ne 0 ; then
1285    echo
1286    echo '*** WARNING: Please review the warnings shown above carefully!'
1287fi
1288echo |tee -a config.summary
1289if test "$BUILD_GIMP2" = "no" -o "$BUILD_CUPS" = "no" ; then
1290    echo "VERY IMPORTANT:" |tee -a config.summary
1291    echo "If you expect to build the CUPS driver or the enhanced Print plugin for" |tee -a config.summary
1292    echo "GIMP, but the output above indicates that that component will not be built," |tee -a config.summary
1293    echo "it almost certainly indicates that development packages required to build" |tee -a config.summary
1294    echo "that component are not installed on your system.  Please read the README" |tee -a config.summary
1295    echo "file and install the necessary development packages before reporting any" |tee -a config.summary
1296    echo "error to the development team.  Depending upon your operating system version," |tee -a config.summary
1297    echo "you may have to install packages from the installation medium or over" |tee -a config.summary
1298    echo "the network." |tee -a config.summary
1299    echo |tee -a config.summary
1300fi
1301echo "Finished configuring.  Please review CAREFULLY the configuration summary above."
1302echo "This summary is also stored in config.summary"
1303echo "Type 'make clean' followed by 'make' to build the package"
1304echo "then 'make install' to install it."
1305