1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_COPYRIGHT([Fig2dev: Translate Fig code to various Devices
5Copyright (c) 1991 by Micah Beck
6Parts Copyright (c) 1985-1988 by Supoj Sutanthavibul
7Parts Copyright (c) 1989-2015 by Brian V. Smith
8Parts Copyright (c) 2015-2020 by Thomas Loimer
9
10Any party obtaining a copy of these files is granted, free of charge, a
11full and unrestricted irrevocable, world-wide, paid up, royalty-free,
12nonexclusive right and license to deal in this software and documentation
13files (the "Software"), including without limitation the rights to use,
14copy, modify, merge, publish, distribute, sublicense and/or sell copies
15of the Software, and to permit persons who receive copies from any such
16party to do so, with the only requirement being that the above copyright
17and this permission notice remain intact.
18])
19
20#
21# configure.ac
22# Author: Thomas Loimer, 2015-2020.
23#
24
25dnl Define m4 variables for use in AC_INIT and AC_DEFINE below.
26dnl VERS=3.2 and AC_INIT(...,$VERS..) does not work. (These variables
27dnl are probably only expanded when ./configure is run.) See also
28dnl info automake, section 16 "Rebuilding Makefiles".
29dnl defines m4-variables FIG_VERSION and RELEASEDATE
30m4_include([version.m4])
31
32dnl The minimum autoconf version to process this file. In version 2.60,
33dnl the directory variables changed, see info autoconf, section 4.8.3.
34AC_PREREQ([2.60])
35
36#
37# Initialize.
38#
39AC_INIT([fig2dev], [FIG_VERSION], [thomas.loimer@tuwien.ac.at],[],
40	[https://sourceforge.net/projects/mcj])
41dnl AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS],
42dnl	[TARNAME], [URL])
43dnl TARNAME defaults to FULL-PACKAGE-NAME, converted to lower case
44dnl and all characters other than alphanumerics and _ changed to -.
45dnl defines PACKAGE_NAME, PACKAGE_TARNAME, PACKAGE_VERSION, PACKAGE_STRING,
46dnl PACKAGE_BUGREPORT and PACKAGE_URL
47
48# Set automake options.
49dnl The options are written to AUTOMAKE_OPTIONS. A minimum version
50dnl of automake, e.g., 1.6.1, can also be put into AM_INIT_AUTOMAKE.
51AM_INIT_AUTOMAKE([-Wall foreign dist-xz no-dist-gzip subdir-objects])
52dnl AM_INIT_AUTOMAKE([-Wall -Werror foreign])
53dnl  -Wall.....enable all (automake) warnings
54dnl  -Werror...and report them as error
55dnl  foreign...do no require the files ChangeLog COPYING AUTHORS NEWS
56dnl		README INSTALL
57dnl  subdir-objects...place objects into the dir where the corresponding
58dnl		source file resides, not into the current build directory
59
60AC_CONFIG_MACRO_DIR([m4])
61
62# Check whether ./configure resides in the correct directory
63AC_CONFIG_SRCDIR([CHANGES])
64
65# Write the variables determined by ./configure into config.h.
66# Therefore, make sure to #include "config.h" in each source file.
67AC_CONFIG_HEADERS([config.h])
68
69AC_SUBST([RELEASE_DATE], "RELEASEDATE")
70
71#
72# Checks for programs.
73#
74AC_PROG_CC
75# Needed to pack the convenience library fig2dev/dev/fig2dev.a
76AC_PROG_RANLIB
77AM_PROG_AR
78
79# Define LN_S for use in the Makefiles
80AC_PROG_LN_S
81# For use in the testsuite.
82# Need to take over the variables in fig2dev/tests/atlocal.in
83AC_PROG_FGREP
84AC_PROG_SED
85
86# Ghostscript 7.10 says, the executable for Windows 95/98 is called
87# gswin32, for Dos or Windows 3 it is called gs386. Ancient enough.
88AC_CHECK_PROGS([GSEXE],[gs gswin32c gsos2 gswin32 gs386])
89AC_ARG_VAR([GSEXE], [ghostscript command])
90# If ghostscript is not found, GSEXE is set to the empty string.
91# However, we do "#ifdef GSEXE" etc., hence undef GSEXE, if empty.
92AS_IF([test "x$GSEXE" != x],dnl
93    [AC_DEFINE_UNQUOTED([GSEXE], ["$GSEXE"],
94	[Define to the name of the ghostscript command.])])dnl
95
96#
97# Checks for libraries.
98#
99AC_SEARCH_LIBS([cos], [m])
100
101
102#
103# Checks for header files.
104#
105
106# Check for iconv.h. If found, try to compile and link a custom-made
107# test program. On Darwin, iconv.h typedef's iconv() to libiconv(). Therefore,
108# one cannot use AC_SEARCH_LIBS to search for the iconv symbol, but must use a
109# test program that includes iconv.h.
110AC_CHECK_HEADER([iconv.h],
111    [TL_SEARCH_LIBS_SOURCE([iconv], [iconv], [],
112	[#include <iconv.h>
113	int main(void)
114	{char *a; return iconv(0, &a, (size_t*)a, &a, (size_t*)a);}])dnl
115    AS_IF([test "$tl_cv_search_source_iconv" != no],
116	[AC_DEFINE([HAVE_ICONV], 1,
117	    [Define to 1 if you have the <iconv.h> header and libiconv.])])],
118    [], [AC_INCLUDES_DEFAULT])
119
120# Check for headers, but do not define preprocessor-variables in config.h.
121# If the headers below are missing, the program will not compile.
122AS_VAR_SET([headers_missing], [no])
123AC_CHECK_HEADER([limits.h], [], [headers_missing=yes
124    AC_MSG_WARN(limits.h is missing!)], [AC_INCLUDES_DEFAULT])
125AC_CHECK_HEADER([netinet/in.h], [], [headers_missing=yes
126    AC_MSG_WARN(netinet/in.h is missing!)], [AC_INCLUDES_DEFAULT])
127AC_CHECK_HEADER([sys/file.h], [], [headers_missing=yes
128    AC_MSG_WARN(sys/file.h is missing!)], [AC_INCLUDES_DEFAULT])
129AC_CHECK_HEADER([sys/param.h], [], [headers_missing=yes
130    AC_MSG_WARN(sys/param.h is missing!)], [AC_INCLUDES_DEFAULT])
131# AC_INCLUDES_DEFAULT anyhow requires stdio.h and checks for
132# sys/types.h, sys/stat.h, stdlib.h, string.h, strings.h, inttypes.h,
133# stdint.h, unistd.h, and optionally stddef.h and memory.h. The
134# variables HAVE_SYS_TYPES_H, HAVE_SYS_STAT_H, HAVE_STDLIB_H etc. are
135# defined in config.h.
136
137# Some headers are checked implicitly by testing for functions provided
138# by them: <pwd.h> by getpwuid(), <errno.h> by strerror(). Really,
139# strerror() is not defined in errno.h, but it is save to assume that
140# errno.h exists if strerror() is found.
141
142# Check for header files and libraries
143dnl First search for the header, only then search for the libs. The other way
144dnl round, the library found would be prepended to LIBS, unnecessarily.
145AC_CHECK_HEADER([zlib.h],
146    [AC_SEARCH_LIBS([deflate], [z],
147	[AC_DEFINE([HAVE_ZLIB_H], 1,
148	    [Define to 1 if you have the zlib library and <zlib.h> header.])])],
149    [], [AC_INCLUDES_DEFAULT])
150
151
152#
153# Check user options.
154#
155AC_ARG_ENABLE(versioning, [AS_HELP_STRING([--enable-versioning],
156	[enable changing the version number, only useful for \
157	 hacking (default: disable)])],
158    [],[enableval=no])dnl
159AM_CONDITIONAL([ENABLE_VERSIONING], [test "x$enableval" = xyes])dnl
160
161AC_ARG_ENABLE(transfig, [AS_HELP_STRING([--enable-transfig],
162	[build the transfig program (default: do not build)])],
163    [],[enableval=no])dnl
164AM_CONDITIONAL([ENABLE_TRANSFIG],[test "x$enableval" = xyes])
165
166AC_ARG_ENABLE(letterpaper, [AS_HELP_STRING([--enable-letterpaper],
167	[set default papersize to letter for dxf \
168		and ibmgl-drivers (default: A4)])],
169    [],[enableval=no])dnl
170AS_IF([test "x$enableval" = xno || test "x$enableval" = xA4 || \
171	test "x$enableval" = xa4],dnl
172    [AC_DEFINE([A4], 1,dnl
173	[Define to 1 if the default papersize for the dxf- \
174		and ibmgl-drivers is A4, not letter.])dnl
175# Used in fig2dev.1.in
176     AC_SUBST(DEFAULT_PAPERSIZE, ["ISO A4"])dnl
177     AC_SUBST(ALTERNATE_PAPERSIZE, ["ANSI A"])],dnl
178    [AC_SUBST(DEFAULT_PAPERSIZE, ["ANSI A"])dnl
179     AC_SUBST(ALTERNATE_PAPERSIZE, ["ISO A4"])])dnl
180
181AC_ARG_ENABLE([i18n], [AS_HELP_STRING([--disable-i18n],
182	[disable internationalization of text input \
183		for some drivers (default: enable)])],
184    [i18nman="/dev/null"],
185    [enableval=yes; i18nman="$srcdir/man/i18n.man"])dnl
186AS_IF([test "x$enableval" = xyes],dnl
187    [AC_DEFINE([I18N], 1,dnl
188	[Define to 1 to use internationalization of text input \
189		for some drivers.])dnl
190# The directory where internationalization data is installed to.
191# fig2dev/dev/Makefile.am defines -DI18N_DATADIR
192# i18ndir is used in fig2dev/i18n/Makefile.am
193     AC_SUBST([i18ndir],['$(pkgdatadir)/i18n'])])
194AM_CONDITIONAL([ENABLE_I18N],[test "x$enableval" = xyes])
195dnl Substitute the file fragment named by i18nman, defined above,
196dnl into man/fig1dev.1 (or not)
197AC_SUBST_FILE([i18nman])
198
199AC_ARG_ENABLE([NFSS], [AS_HELP_STRING([--disable-NFSS],
200	[disable LaTeX New Font Selection Scheme (default: enable)])],
201    [nfssman="/dev/null"],[enableval=yes; nfssman="$srcdir/man/nfss.man"])dnl
202AS_IF([test "x$enableval" = xyes],dnl
203    [AC_DEFINE([NFSS], 1,dnl
204	 [Define to 1 to use the New Font Selection Scheme for LaTeX.])])dnl
205AC_SUBST_FILE([nfssman])
206
207AC_ARG_ENABLE([latex2e_graphicx], [AS_HELP_STRING([--disable-latex2e_graphicx],
208	[disable LaTeX2e-graphics commands in pstex- \
209		and latex-drivers (default: enable)])],
210    [],[enableval=yes])dnl
211AS_IF([test "x$enableval" = xyes],dnl
212    [AC_DEFINE([LATEX2E_GRAPHICS], 1,dnl
213	[Define to 1 to use LaTeX2e-graphics in pstex- \
214		and latex-drivers.])])dnl
215
216AC_ARG_ENABLE([scale-pict2e], [AS_HELP_STRING([--enable-scale-pic2t2e],
217	[enable scaling of pict2e-graphics, e.g., \
218		with \XFigwidth (default: disable)])],
219    [],[enableval=no])dnl
220AS_IF([test "x$enableval" = xyes],dnl
221    [AC_DEFINE([SCALE_PICT2E], 1,dnl
222	 [Define to 1 if pict2e-graphics should honor \
223		\XFigwidth or \XFigheight.])])dnl
224
225AC_ARG_ENABLE([IBM-GEC], [AS_HELP_STRING([--disable-IBM-GEC],
226	[disable instruction set for IBM Graphics Enhancement \
227		Cartridge (default: enable)])],
228    [],[enableval=yes])dnl
229AS_IF([test "x$enableval" = xyes],dnl
230    [AC_DEFINE([IBMGEC], 1,dnl
231	[Define to 1 if the ibmgl-driver should create instructions \
232		for the IBM Graphics Enhancement Cartridge.])dnl
233     AC_SUBST([WITH_IBMGEC],[without])],dnl
234    [AC_SUBST([WITH_IBMGEC],[with])])dnl
235
236AC_ARG_ENABLE([baseline-shift], [AS_HELP_STRING([--disable-baseline-shift],
237	[disable use of baseline-shift in the svg-driver (default: enable)])],
238    [],[enableval=yes])dnl
239AS_IF([test "x$enableval" != xyes],dnl
240    [AC_DEFINE([NOSUPER], 1,dnl
241	 [Define to 1 to not use baseline-shift sub/superscripts \
242		in the svg-driver])])dnl
243
244AC_ARG_ENABLE([round-box], [AS_HELP_STRING([--disable-round-box],
245	[disable use of boxes with rounded corners \
246		in the tpic-driver (default: enable)])],
247    [],[enableval=yes])dnl
248AS_IF([test "x$enableval" = xyes],dnl
249    [AC_DEFINE([TPIC_ARC_BOX], 1,dnl
250	 [Define to 1 to use boxes with rounded corners \
251		in the tpic-driver.])])dnl
252
253AC_ARG_WITH(png,
254    [AS_HELP_STRING([--without-png],
255		[disable reading png-images (default: enable)])],
256    [],[with_png=try])dnl
257
258AS_IF([test "x$with_png" != xno],
259    [# -lz is not necessary for shared libraries
260    # AC_SEARCH_LIBS([deflate], [z])dnl
261    AC_SEARCH_LIBS([png_read_info], [png],
262	[AC_CHECK_HEADER([png.h],
263	    [AC_DEFINE([HAVE_PNG_H], 1,dnl
264		[Define to 1 if you have the <png.h> header file.])],
265	    [], [AC_INCLUDES_DEFAULT])])])dnl
266
267AM_CONDITIONAL([WITH_PNG], [test "$ac_cv_header_png_h" = yes])
268
269AC_ARG_WITH(rgbfile, [AS_HELP_STRING([--with-rgbfile=<path>],
270	[specify full path of X color file (default: /etc/X11/rgb.txt)])],
271	[],[withval=/etc/X11/rgb.txt])
272AC_DEFINE_UNQUOTED([RGB_FILE], ["$withval"],dnl
273	[Define to the full path of the X color database file.])
274
275
276#
277# Checks for typedefs, structures, and compiler characteristics.
278#
279AC_C_CONST
280AC_C_INLINE
281dnl to silence a warning on calling iconv() from genemf.c
282dnl see the commit after 2b3711d
283dnl AC_C_RESTRICT
284AC_C_BIGENDIAN
285
286dnl  Check for declarations. In any case defines, e.g., HAVE_DECL_M_PI.
287dnl  Sets it to 0 if not found, to 1 if found.
288dnl AC_CHECK_DECLS([M_PI, M_PI_2, M_PI_4], [], [], [#include <math.h>])
289dnl Just provide our own pi
290
291# Check, whether sdtbool.h exists and whether the type _Bool is defined.
292# Defines HAVE_STDBOOL_H and HAVE__BOOL. See info autoconf for a usage
293# example.
294AC_HEADER_STDBOOL
295AC_TYPE_SIZE_T
296AC_TYPE_SSIZE_T
297
298#
299# Checks for library functions.
300#
301
302# Check for functions and set, e.g., HAVE_STRERROR if found.
303# Assume that errno.h exists if strerror() is available. Otherwise, do
304# not use strerror() at all. Do not try to replace strerror() with the
305# obsolete sys_nerr, sys_errlist and the declaration "int errno".
306# If getpwuid() is found, <pwd.h> is assumed to exist.
307AC_CHECK_FUNCS_ONCE([gethostname strerror getpwuid mkstemp fdopen])
308
309# Under Windows, the _setmode() function is defined in io.h. It accepts two
310# arguments and sets the file access mode to text or binary. O_TEXT and O_BINARY
311# are defined in fcntl.h. Under BSD, another _setmode() function exists, that
312# accepts one argument. Here, define HAVE__SETMODE, if (i) _setmode() compiles
313# and links with two arguments given, and (ii) <io.h> and <fcntl.h> can be
314# #included. As long as Windows does not have sh, this test probably only
315# succeeds under cygwin.
316AC_CACHE_CHECK([for _setmode],[tl_cv_func__setmode],
317	[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <io.h>
318#include <fcntl.h>]],[[_setmode(1, O_BINARY);]])],
319		[tl_cv_func__setmode=yes],[tl_cv_func__setmode=no])])
320AS_IF([test "$tl_cv_func__setmode" = yes],
321	[AC_DEFINE([HAVE__SETMODE], 1, [Define to 1 if you are under Windows \
322		and have _setmode() to set file modes to text or binary.])])
323
324# Check for functions and, if not found, use the corresponding
325# replacement, e.g., strstr.c, in the top srcdir. Sets, e.g.,
326# HAVE_STRSTR. Except possibly getopt(), any modern system should have these
327# functions, so all except one are obsolete checks.
328AC_REPLACE_FUNCS([getline getopt isascii strstr strchr strrchr \
329	strcasecmp strncasecmp strdup])
330
331# Place the replacement functions into this dir.
332AC_CONFIG_LIBOBJ_DIR([fig2dev/lib])
333
334#
335# Autotest infrastructure.
336#
337AC_CONFIG_TESTDIR([fig2dev/tests])
338AM_MISSING_PROG([AUTOM4TE], [autom4te])
339
340# Create these files from the Makefile.in templates. The Makefile.in, in
341# turn, is created from Makefile.am with automake or just autoreconf.
342AC_CONFIG_FILES([Makefile
343		man/Makefile
344		man/fig2dev.1
345		fig2dev/Makefile
346		fig2dev/dev/Makefile
347		fig2dev/i18n/Makefile
348		fig2dev/tests/Makefile
349		fig2dev/tests/atlocal
350		fig2dev/tests/data/patterns.svg
351		fig2dev/tests/data/fillswclip.svg
352		transfig/Makefile])
353
354AC_OUTPUT
355
356#
357# Diagnostic output
358#
359# TODO: Add a hint for unusual search paths.
360# Macports by default installs under /opt/local, fink under /sw.
361# Cygwin may install under /usr/include/noX (/X11), /lib/noX.
362# Therefore, libpaths may be /opt/local/lib /sw/lib /opt/X11/lib /lib/noX
363# Include paths may be /opt/local/include /sw/include /opt/X11/include
364# if with-png!=no && ac_cv_search_png_read_info = no;
365#	missingfuncs = "png_read_info " # $missingfuncs
366#	missinglibs = "-lpng " # $missinglibs
367#	if ac_cv_header_png_h != yes
368#		missingheaders = "png.h "
369# test "$tl_cv_search_source_iconv" = no],
370# test "x$with_xpm" != xno &&
371#    ac_cv_search_XpmReadFileToXpmImage], [Xpm],
372#  [test "x$ac_cv_header_X11_xpm_h" = xyes])
373
374AS_IF([test "$headers_missing" = yes],dnl
375	[AC_MSG_WARN([headers are missing!
376	*** The program will not compile.    ***
377	*** Look for WARNING-messages above. ***])])
378AC_MSG_NOTICE([Results:
379  preprocessor		CPP:		$CPP
380  preprocessor flags	CPPFLAGS:	${CPPFLAGS:-<empty>}
381  compiler		CC:		$CC
382  compiler flags	CFLAGS:		${CFLAGS:-<empty>}
383  linker flags		LDFLAGS:	${LDFLAGS:-<empty>}
384  libraries		LIBS:		${LIBS:-<empty>}
385  install location	prefix:		$prefix
386
387Files will be installed under $prefix.])
388