1dnl
2dnl This is the configuration file for GNU oleo.
3dnl
4dnl $Id: configure.in,v 1.89 2001/03/08 08:28:15 danny Exp $
5dnl
6dnl Process this file with autoconf to produce a configure script.
7dnl
8AC_INIT(src/init.c)
9
10dnl
11dnl Need to be processed with Autoconf >= 2.13
12dnl
13AC_PREREQ(2.13)
14
15AM_INIT_AUTOMAKE([oleo], [1.99.16])
16GNU_PACKAGE="GNU $PACKAGE"
17AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE")
18
19dnl
20dnl Use of this macro will keep unexpected things from happening if
21dnl you're not familiar with automake.
22dnl
23dnl    if test -z "$enable_maintainer_mode"
24dnl    then
25dnl        enable_maintainer_mode=yes
26dnl    fi
27AM_MAINTAINER_MODE
28
29dnl Define available languages
30ALL_LINGUAS="en nl fr"
31
32AC_ARG_PROGRAM
33AM_CONFIG_HEADER(config.h)
34
35dnl
36dnl Find a C compiler, detect strange systems.
37dnl The order is important here.
38dnl
39AC_PROG_CC
40AC_AIX
41AC_ISC_POSIX
42AC_CYGWIN
43AC_EXEEXT
44
45dnl
46dnl for intl/
47dnl
48AC_CHECK_SIZEOF(short, 2)
49AC_CHECK_SIZEOF(int, 4)
50AC_CHECK_SIZEOF(long, 4)
51
52dnl
53dnl Dmalloc is a library to debug memory allocation.
54dnl Get it from www.dmalloc.com
55dnl
56AM_WITH_DMALLOC
57
58dnl
59dnl Now at last we can do checks for programs.
60dnl
61AC_PROG_YACC
62AC_PROG_INSTALL
63AC_PROG_LN_S
64AC_PROG_RANLIB
65
66AC_CHECK_PROG(HAVE_TEXI2HTML, texi2html, yes)
67AM_CONDITIONAL(HaveTexi2Html, test x$HAVE_TEXI2HTML = xyes)
68
69dnl
70dnl Get perl's location for texi2html
71dnl
72AC_PATH_PROG(HAVE_PERL, perl)
73AC_SUBST(HAVE_PERL)
74AM_CONDITIONAL(HavePerl, test x$HAVE_PERL != x)
75
76
77dnl
78dnl Dirty trick
79dnl
80if test -d /usr/local ; then
81dnl	CFLAGS="-I/usr/local/include $CFLAGS "
82	INCLUDES="-I/usr/local/include $INCLUDES "
83	LIBS="-L/usr/local/lib $LIBS "
84fi
85
86dnl
87dnl How good is the C compiler ?
88dnl
89AM_C_PROTOTYPES
90
91dnl
92dnl Checks for libraries.
93dnl
94AC_CHECK_LIB(ncurses, waddch, ,
95	AC_CHECK_LIB(curses, addch, ,
96		AC_CHECK_LIB(termlib, tgetent, ,
97			AC_CHECK_LIB(termcap, tgetent))))
98
99AC_CHECK_HEADERS(ncurses.h, break, ac_cv_lib_ncurses_waddch="no")
100
101dnl Check for sys_errlist[] and sys_nerr, check for declaration
102AC_MSG_CHECKING([for sys_errlist and sys_nerr])
103AC_CACHE_VAL(oleo_cv_sys_errlist,
104[AC_TRY_LINK([#include <errno.h>
105#include <stdio.h>],
106[  char *msg = sys_errlist[sys_nerr - 1];],
107      oleo_cv_sys_errlist=yes, oleo_cv_sys_errlist=no)])dnl
108      AC_MSG_RESULT($oleo_cv_sys_errlist)
109      if test $oleo_cv_sys_errlist = yes; then
110      AC_DEFINE(HAVE_SYS_ERRLIST)
111      fi
112
113dnl
114dnl This library is required on FreeBSD.
115dnl
116AC_CHECK_LIB(mytinfo, tputs)
117
118dnl
119dnl Good i18n on FreeBSD requires the XPG4 library
120dnl
121AC_CHECK_LIB(xpg4, setlocale)
122
123dnl
124dnl Check existence of a working math library
125dnl	The good old check with sqrtf fails on some systems.
126dnl	Is there a function that works on all ?
127dnl	Yes: "main" just detects presence of the library.
128dnl
129AC_CHECK_LIB(m, main)
130
131dnl
132dnl Checks for X11
133dnl
134AC_PATH_XTRA
135
136dnl There are cases where motif may be installed on a system, but X may not
137dnl be (Default on hppa1.1-hp-hpux10.20) therefor this this must all be wrapped
138if test "$no_x" = ""; then
139    dnl
140    dnl Motif (LessTif)
141    dnl
142    AC_ARG_WITH(motif,
143	[  --without-motif              do not use Motif, even if detected],
144	[		case "${withval}" in
145	    y | ye | yes )	usemotif=yes ;;
146	    n | no )		usemotif=no ;;
147	    * )			usemotif=yes ;;
148	    esac],
149	[		with_motif=yes])
150
151    dnl
152    dnl If you ask not to have Xbae then you can't have Motif either.
153    dnl And the other way around.
154    dnl
155    dnl To make sure people know about this, we'll be harsh and abort.
156    dnl
157    if test "$with_Xbae" = "no" -a "$with_motif" = "yes" ; then
158	AC_MSG_ERROR(Cannot build Motif/LessTif interface without Xbae)
159    fi
160    if test "$with_Xbae" = "yes" -a "$with_motif" = "no" ; then
161	AC_MSG_ERROR(Cannot use Xbae without Motif/LessTif)
162    fi
163
164    dnl
165    dnl Checks for Motif
166    dnl These should not happen if --without-motif has been used.
167    dnl
168    if test "$with_motif" = "yes"; then
169	AC_FIND_MOTIF
170    fi
171    if test "$with_motif" = "yes"; then
172	AC_FIND_XBAE
173	if test "$with_xbae" = "no" ; then
174	    AC_MSG_ERROR(
175	      [Xbae not found; you must install it or use "--without-motif"])
176	    with_motif=no
177	fi
178    fi
179    if test "$with_motif" = "yes"; then
180	ICE_FIND_XmHTML
181	AC_FIND_XLT
182	if test "x$XLT_LIBS" != "x"; then
183	    CFLAGS="$XLT_CFLAGS $MOTIF_CFLAGS $X_CFLAGS $CFLAGS"
184	    LIBS="$XLT_LIBS $MOTIF_LIBS $X_LIBS $X_PRE_LIBS -lXt -lX11 -lXext $X_EXTRA_LIBS $LIBS"
185	    AC_DEFINE(HAVE_SciPlot_H)
186	else
187	    ICE_FIND_SciPlot
188	    CFLAGS="$MOTIF_CFLAGS $X_CFLAGS $CFLAGS"
189	    LIBS="$MOTIF_LIBS $X_LIBS $X_PRE_LIBS -lXt -lX11 $X_EXTRA_LIBS $LIBS"
190	fi
191	AC_CHECK_LIB(Xpm, main)
192    fi
193    if test "$with_motif" = "no"; then
194	dnl
195	dnl Add link to X11
196	dnl	This is only for the non-motif case.
197	dnl
198	with_x=yes
199	AC_LINK_X
200    fi
201fi dnl "$no_x" = "yes"
202
203dnl
204dnl This is an automake variable which allows you to use conditionals
205dnl in makefiles. We'll use it in the src/ directory to figure out
206dnl which files to compile.
207dnl
208AM_CONDITIONAL(UseMotif, test x$with_motif = xyes)
209
210dnl
211dnl Check whether a recent version of GNU PlotUtils is around
212dnl	This needs to be done after the X and Motif tests, because
213dnl	the libplot from GNU plotutils sometimes requires linking the
214dnl	X and Motif libraries
215dnl
216if test "$with_motif" = "yes"; then
217  AC_CHECK_LIB(plot, pl_openpl_r,
218	AC_DEFINE(HAVE_LIBPLOT)
219	LIBS="$LIBS -lplot")
220
221  AC_CHECK_LIB(sciplot, sp_begin_plot)
222    if test x$ac_cv_lib_sciplot_sp_begin_plot = xyes; then
223	AC_DEFINE(HAVE_LIBSCIPLOT)
224    fi
225fi
226
227dnl Checks for Guile
228dnl AC_CHECK_LIB(guile, scm_boot_guile)
229
230dnl Checks if -DDEBUG is requested
231AC_ARG_WITH(debug,
232[  --with-debug                 Send debugging info to stderr],
233[              case "${withval}" in
234                 y | ye | yes )         usedebug=yes ;;
235                 n | no )               usedebug=no ;;
236                 * )                    usedebug=yes ;;
237               esac],
238[              with_debug=no])
239
240if test $with_debug = yes; then
241  CFLAGS="$CFLAGS -DDEBUG"
242  if test "x$GCC" = "xyes"; then
243    if test -z "`echo "$CFLAGS" | grep "\-Wall" 2> /dev/null`"; then
244      CFLAGS="$CFLAGS -Wall"
245    fi
246  fi
247fi
248
249dnl
250dnl Checks for header files.
251dnl
252AC_HEADER_DIRENT
253AC_HEADER_STDC
254AC_CHECK_HEADERS(fcntl.h limits.h malloc.h strings.h sys/time.h unistd.h)
255AC_CHECK_HEADERS(locale.h time.h math.h libintl.h)
256
257dnl
258dnl
259AC_CHECK_FUNC(XltCreateFontChooser, AC_DEFINE(HAVE_XLT_FONTCHOOSER))
260
261dnl
262dnl GNU GSL (GNU Scientific Library)
263dnl
264AC_CHECK_LIB(gsl, gsl_error,
265	LIBS="$LIBS -lgsl -lgslblas"
266	AC_DEFINE(HAVE_GSL),,
267	-lgslblas)
268
269dnl
270dnl MySQL client library ?
271dnl
272AC_CHECK_LIB(mysqlclient, mysql_connect)
273AM_CONDITIONAL(HaveMySQL, test x$ac_cv_lib_mysqlclient_mysql_connect = xyes)
274
275dnl
276dnl Checks for typedefs, structures, and compiler characteristics.
277dnl
278AC_C_CONST
279AC_C_INLINE
280AC_TYPE_SIZE_T
281AC_HEADER_TIME
282AC_STRUCT_TM
283AC_STRUCT_TIMEZONE
284
285dnl
286dnl Checks for library functions.
287dnl
288AC_FUNC_ALLOCA
289AC_TYPE_SIGNAL
290AC_FUNC_STRFTIME
291AC_FUNC_VPRINTF
292AC_CHECK_FUNCS(ftime gethostname gettimeofday mktime select strdup strstr)
293AC_CHECK_FUNCS(putenv strcasecmp strerror getcwd rename)
294AM_FUNC_MKTIME
295AM_FUNC_OBSTACK
296
297dnl
298dnl CUPS is the Common UNIX Printing System
299dnl	http://www.cups.org
300dnl
301AC_CHECK_LIB(cups, cupsGetPrinters)
302
303dnl
304dnl
305dnl Xbase support (to read DBF files).
306dnl	You'll need to uncomment the lines below for Xbase support,
307dnl	as is indicated in the FAQ.
308dnl
309dnl AC_PROG_CXX
310AC_PROG_CXX_NONFATAL
311dnl
312dnl End Xbase support lines
313dnl
314if test "$CXX" != "no"; then
315  AC_LANG_SAVE
316  AC_LANG_CPLUSPLUS
317  AC_CHECK_LIB(xbase, main)
318  if test x$ac_cv_lib_xbase_main = xno; then
319    AC_CHECK_LIB(xdb, main)
320    AM_CONDITIONAL(HaveXbase, test x$ac_cv_lib_xdb_main = xyes)
321  else
322    AM_CONDITIONAL(HaveXbase, test x$ac_cv_lib_xbase_main = xyes)
323  fi
324  AC_LANG_RESTORE
325else
326  AM_CONDITIONAL(HaveXbase, false)
327fi
328
329dnl See if we're GNU Gettext friendly
330dnl
331AM_GNU_GETTEXT
332
333dnl
334dnl This used to cause all kinds of problems in an earlier revision
335dnl	of oleo. (Mostly because of using earlier auto* tools.)
336dnl
337dnl AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
338
339dnl
340dnl Pass information about where we install to the source, to be
341dnl	able to read AFM files. Note this doesn't work if you
342dnl	install via "make install DESTDIR=/xxx"
343dnl
344if test "$prefix" != "NONE"; then
345	BUILD_PREFIX=$prefix
346else
347	BUILD_PREFIX=$ac_default_prefix
348fi
349AC_SUBST(BUILD_PREFIX)
350
351dnl
352dnl
353dnl
354
355AC_SUBST(LIBOBJS)
356
357AC_SUBST(include_motif)
358AC_SUBST(link_motif)
359AC_SUBST(include_xbae)
360AC_SUBST(link_xbae)
361AC_SUBST(include_xmhtml)
362AC_SUBST(link_xmhtml)
363AC_SUBST(include_sciplot)
364AC_SUBST(link_sciplot)
365
366AC_OUTPUT([Makefile oleobug doc/Makefile doc/texi2html lib/Makefile src/Makefile intl/Makefile m4/Makefile po/Makefile.in Xresources/Makefile examples/Makefile oleo.spec afm/Makefile],[sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile])
367