1dnl Process this file with autoconf to produce a configure script.
2AC_INIT([wv],[1.2.9],[wvware-devel@sourceforge.net])
3
4dnl This next section is courtesy gtk+
5dnl
6# Making releases:
7#   WV_MICRO_VERSION += 1;
8#   WV_INTERFACE_AGE += 1;
9#   WV_BINARY_AGE += 1;
10# if any functions have been added, set WV_INTERFACE_AGE to 0.
11# if backwards compatibility has been broken,
12# set WV_BINARY_AGE and WV_INTERFACE_AGE to 0.
13#
14WV_MAJOR_VERSION=1
15WV_MINOR_VERSION=2
16WV_MICRO_VERSION=9
17WV_INTERFACE_AGE=5
18WV_BINARY_AGE=5
19WV_VERSION=$WV_MAJOR_VERSION.$WV_MINOR_VERSION.$WV_MICRO_VERSION
20
21
22
23AC_CANONICAL_HOST
24AC_CONFIG_SRCDIR([wvWare.c])
25
26
27AC_SUBST(WV_MAJOR_VERSION)
28AC_SUBST(WV_MINOR_VERSION)
29AC_SUBST(WV_MICRO_VERSION)
30AC_SUBST(WV_INTERFACE_AGE)
31AC_SUBST(WV_BINARY_AGE)
32AC_SUBST(WV_VERSION)
33
34# libtool versioning
35LT_RELEASE=$WV_MAJOR_VERSION.$WV_MINOR_VERSION
36LT_CURRENT=`expr $WV_MICRO_VERSION - $WV_INTERFACE_AGE`
37LT_REVISION=$WV_INTERFACE_AGE
38LT_AGE=`expr $WV_BINARY_AGE - $WV_INTERFACE_AGE`
39AC_SUBST(LT_RELEASE)
40AC_SUBST(LT_CURRENT)
41AC_SUBST(LT_REVISION)
42AC_SUBST(LT_AGE)
43
44# For automake.
45VERSION=$WV_VERSION
46PACKAGE=wv
47
48dnl Initialize automake stuff
49AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
50
51# Specify a configuration file
52AM_CONFIG_HEADER(config.h)
53
54AH_TOP([
55#ifndef HAVE_WV_CONFIG_H
56#define HAVE_WV_CONFIG_H
57])
58
59dnl Checks for programs.
60
61AC_PROG_CC
62if test "x$GCC" = "xyes"; then
63	ANSI_CFLAGS="-ansi"
64else
65	ANSI_CFLAGS=""
66fi
67AC_SUBST(ANSI_CFLAGS)
68
69AC_PROG_CPP
70AC_PROG_AWK
71AC_PROG_INSTALL
72AC_PROG_LN_S
73AC_PROG_MAKE_SET
74
75AC_PROG_LIBTOOL
76
77AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
78
79# libgsf depends on glib and libxml2, so we should be fine
80libgsf_req='libgsf-1 >= 1.13.0'
81DEPS_PKGS="$libgsf_req"
82
83# required, pkg-config'd packages
84PKG_CHECK_MODULES(DEPS, [ $DEPS_PKGS ],,[AC_MSG_ERROR([$DEPS_PKG_ERRORS])])
85AC_SUBST(DEPS_PKGS)
86AC_SUBST(DEPS_CFLAGS)
87AC_SUBST(DEPS_LIBS)
88
89# optional deps
90OPT_CFLAGS=
91OPT_LIBS=
92
93# these conditionals are still used, albeit libxml2 seems to be unconditionally required
94AC_DEFINE(HAVE_LIBXML2,1,[Define if you have libxml2])
95AC_SUBST(HAVE_LIBXML2)
96
97dnl Checks for headers.
98
99AC_HEADER_STDC
100dnl AC_HEADER_SYS_WAIT
101dnl AC_TYPE_SIGNAL
102dnl AC_FUNC_WAIT3
103
104AC_CHECK_HEADERS(fcntl.h io.h malloc.h sys/file.h sys/ioctl.h unistd.h)
105
106case ${host_os} in
107  *mingw*)
108    link_win32_dll="yes"
109    ;;
110  *)
111    link_win32_dll="no"
112    ;;
113esac
114if test "$cross_compiling" = "yes"; then
115  dllwrap="dllwrap"
116else
117  dllwrap=${host}-"dllwrap"
118fi
119AC_PATH_PROG(DLLWRAP, $dllwrap)
120
121dnl Checks for typedefs, structures, and compiler characteristics.
122
123AC_C_CONST
124
125dnl zlib support
126dnl =======================================================
127
128_cppflags=$CPPFLAGS
129_ldflags=$LDFLAGS
130
131AC_ARG_WITH(zlib,[  --with-zlib=DIR         use libz in DIR],[
132	if test "x$withval" = "xyes"; then
133		ZLIB_DIR=""
134	elif test "x$withval" != "xno"; then
135		ZLIB_DIR="$withval"
136		CPPFLAGS="$CPPFLAGS -I$withval/include"
137		LDFLAGS="$LDFLAGS -L$withval/lib"
138	else
139		AC_MSG_WARN([No zlib? Are you sure? I think I'll look for it anyway...])
140		ZLIB_DIR=""
141	fi
142],[	ZLIB_DIR=""
143])
144
145AC_CHECK_HEADER(zlib.h,[
146	AC_CHECK_LIB(z,gzread,[
147		AC_DEFINE(HAVE_ZLIB,1,[Define if you want zlib to uncompress wmf files])
148		HAVE_ZLIB=1
149		if test "x$ZLIB_DIR" != "x"; then
150			ZLIB_CFLAGS="-I$ZLIB_DIR/include"
151			ZLIB_LIBS="-L$ZLIB_DIR/lib -lz"
152		else
153			ZLIB_CFLAGS=""
154			ZLIB_LIBS="-lz"
155		fi
156	],[	AC_CHECK_LIB(gz,gzread,[
157			AC_DEFINE(HAVE_ZLIB,1,[Define if you want zlib to uncompress wmf files])
158			HAVE_ZLIB=1
159			if test "x$ZLIB_DIR" != "x"; then
160				ZLIB_CFLAGS="-I$ZLIB_DIR/include"
161				ZLIB_LIBS="-L$ZLIB_DIR/lib -lgz"
162			else
163				ZLIB_CFLAGS=""
164				ZLIB_LIBS="-lgz"
165			fi
166		],[	dnl Shouldn't this be an error?
167			AC_MSG_WARN([* * * Unable to find zlib, which is kinda necessary. * * *])
168			HAVE_ZLIB=0
169			ZLIB_CFLAGS=""
170			ZLIB_LIBS=""
171		])
172	])
173])
174
175OPT_CFLAGS="$OPT_CFLAGS $ZLIB_CFLAGS"
176OPT_LIBS="$OPT_LIBS $ZLIB_LIBS"
177
178CPPFLAGS=$_cppflags
179LDFLAGS=$_ldflags
180
181dnl system png support
182dnl ========================================================
183
184_cppflags=$CPPFLAGS
185_ldflags=$LDFLAGS
186
187dnl libpng requires zlib
188CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS"
189
190AC_ARG_WITH(png,[  --with-png=DIR          use png library in DIR],[
191	if test "x$withval" = "xyes"; then
192		PNG_DIR=""
193	elif test "x$withval" != "xno"; then
194		PNG_DIR=$withval
195		CPPFLAGS="$CPPFLAGS -I$withval/include"
196		LDFLAGS="$LDFLAGS -L$withval/lib"
197	else
198		AC_MSG_WARN([No libpng? Are you sure? I think I'll look for it anyway...])
199		PNG_DIR=""
200	fi
201],[	PNG_DIR=""
202])
203
204AC_CHECK_HEADER(png.h,[
205	AC_CHECK_HEADER(pngconf.h,[
206		AC_CHECK_LIB(png, png_free,[
207			AC_DEFINE(HasPNG,1,[define if you have libpng])
208			HAVE_PNG=1
209			if test "x$PNG_DIR" != "x"; then
210				PNG_CFLAGS="-I$PNG_DIR/include"
211				PNG_LIBS="-L$PNG_DIR/lib -lpng"
212			else
213				PNG_CFLAGS=""
214				PNG_LIBS="-lpng"
215			fi
216		],[	dnl Shouldn't this be an error?
217			AC_MSG_WARN([* * * Unable to find libpng, which is kinda necessary. * * *])
218			HAVE_PNG=0
219			PNG_CFLAGS=""
220			PNG_LIBS=""
221		],$ZLIB_LIBS -lm)
222	],[	dnl Shouldn't this be an error?
223		AC_MSG_WARN([* * * Missing "pngconf.h" header file * * *])
224		HAVE_PNG=0
225		PNG_CFLAGS=""
226		PNG_LIBS=""
227	],[#if HAVE_ZLIB
228#include <zlib.h>
229#endif
230	])
231],[	dnl Shouldn't this be an error?
232	AC_MSG_WARN([* * * Missing "png.h" header file * * *])
233	HAVE_PNG=0
234	PNG_CFLAGS=""
235	PNG_LIBS=""
236])
237
238OPT_CFLAGS="$OPT_CFLAGS $PNG_CFLAGS"
239OPT_LIBS="$OPT_LIBS $PNG_LIBS"
240
241CPPFLAGS=$_cppflags
242LDFLAGS=$_ldflags
243
244dnl system libwmf support
245dnl ========================================================
246
247dnl Check for libwmf-0.2.1 or higher
248
249_cppflags=$CPPFLAGS
250_ldflags=$LDFLAGS
251
252have_libwmf=no
253
254AC_ARG_WITH(libwmf,[  --with-libwmf=DIR       use libwmf(2) in DIR],[
255	if [ test "x$withval" != "xno" ]; then
256		if [ test "x$withval" != "xyes" ]; then
257			LIBWMF_DIR=$withval
258		fi
259		search_for_libwmf=yes
260	else
261		search_for_libwmf=no
262	fi
263],[	search_for_libwmf=no
264])
265
266if [ test $search_for_libwmf != no ]; then
267	if [ test -n "$LIBWMF_DIR" ]; then
268		AC_PATH_PROG(LIBWMF_CONFIG,libwmf-config, ,[$LIBWMF_DIR/bin:$PATH])
269	else
270		AC_PATH_PROG(LIBWMF_CONFIG,libwmf-config)
271	fi
272
273	if [ test -n "$LIBWMF_CONFIG" ]; then
274		libwmf_cflags=`$LIBWMF_CONFIG --cflags`
275		libwmf_libs=`$LIBWMF_CONFIG --libs`
276	else
277		AC_MSG_ERROR(* * * unable to find libwmf-config; unable to continue * * *)
278	fi
279
280	CPPFLAGS="$CPPFLAGS $libwmf_cflags"
281	LDFLAGS="$LDFLAGS $libwmf_libs"
282
283	AC_CHECK_HEADER(libwmf/api.h,[
284		AC_CHECK_LIB(wmf,wmf_stream_create,have_libwmf=yes,[
285			AC_MSG_ERROR(* * * libwmf >= 0.2.1 required * * *)
286		],$libwmf_libs)
287		AC_CHECK_HEADER(libwmf/foreign.h,[
288			AC_DEFINE(HAVE_LIBWMF_FOREIGN_H,1,[Define if libwmf(2) has support for reading 'foreign' image formats])
289		],[	AC_MSG_WARN(* * * libwmf >= 0.2.2 recommended * * *)
290		])
291	])
292
293	if [ test $have_libwmf != no]; then
294		AC_DEFINE(HAVE_LIBWMF,1,[Define if you have libwmf(2) and want it to convert wmf to png files])
295
296		WMF_CFLAGS="$libwmf_cflags"
297		WMF_LIBS="$libwmf_libs"
298	fi
299fi
300
301CPPFLAGS=$_cppflags
302LDFLAGS=$_ldflags
303
304OPT_CFLAGS="$OPT_CFLAGS $WMF_CFLAGS"
305OPT_LIBS="$OPT_LIBS $WMF_LIBS"
306
307AC_SUBST(OPT_CFLAGS)
308AC_SUBST(OPT_LIBS)
309
310AC_LANG_C
311
312CPPFLAGS=$_cppflags
313LDFLAGS=$_ldflags
314
315dnl ========================================================
316dnl begin of possible optimization tests
317dnl read notes/optimization
318
319AC_CHECK_SIZEOF(char,1)
320AC_CHECK_SIZEOF(short,2)
321AC_CHECK_SIZEOF(int,4)
322AC_CHECK_SIZEOF(long,4)
323
324if [test "$SIZEOF_CHAR" != "1" ]; then
325    if [test "$SIZEOF_SHORT" != "2" ]; then
326        if [test "$SIZEOF_INT" != "4" ]; then
327            AC_DEFINE(MATCHED_TYPE,1,[Define if sizeof({char,short,int}) != {1,2,4}])
328        fi
329    fi
330fi
331
332if [ test "$cross_compiling" != "yes" ]; then
333    AC_C_BIGENDIAN
334dnl	here we will know the endianness
335	if [ test "$ac_cv_c_bigendian" = "no" ]; then
336	    AC_DEFINE(XML_BYTE_ORDER,12,[Define as 12 for little-endian, 21 for big-endian])
337	else
338		if [ test "$ac_cv_c_bigendian" = "yes" ]; then
339			AC_DEFINE(XML_BYTE_ORDER,21,[Define as 12 for little-endian, 21 for big-endian])
340		fi
341	fi
342else
343dnl	here we will not know the endianness, so we will
344dnl go with the mechanism that works everywhere
345    AC_DEFINE(WORDS_BIGENDIAN,1,[Define if byte order is big-endian])
346fi
347
348dnl given matched types and little endian we can read types larger
349dnl than a byte with fread and avoid byteswapping
350
351dnl at some later stage we will have a test to see if the compiler can
352dnl get rid of holes, for the moment we will assume only that we can
353dnl do it if we have __GNUC__ defined
354
355dnl end of possible optimization tests
356
357dnl check for getopt
358dnl
359AC_CHECK_FUNC(getopt_long,,[
360	AC_LIBOBJ(getopt1)
361	AC_LIBOBJ(getopt)
362])
363
364dnl check for strcasecmp
365dnl
366AC_CHECK_FUNC(strcasecmp,,[
367	AC_LIBOBJ(strcasecmp)
368])
369
370AC_EGREP_HEADER(strcasecmp,string.h,,[
371	AC_DEFINE(DEFINE_STRCASECMP,1,[Define this if strcasecmp must be defined])
372])
373
374dnl check for memcpy, if not there we'll use bcopy
375dnl
376AC_CHECK_FUNCS(memcpy)
377
378dnl check for mmap
379dnl
380AC_FUNC_MMAP
381
382AH_BOTTOM([
383#ifdef HAVE_UNISTD_H
384#include <unistd.h>
385#endif
386#ifdef HAVE_FCNTL_H
387#include <fcntl.h>
388#endif
389#if defined(HAVE_ERRNO_H)
390#include <errno.h>
391#endif
392#include <sys/types.h>
393#include <sys/stat.h>
394#include <limits.h>
395#include <stdarg.h>
396
397#if defined(__GNUC__) && !defined(WORDS_BIGENDIAN) && defined(MATCHED_TYPE)
398#define NO_HOLES
399#endif
400
401#ifndef HAVE_MEMCPY
402#define memcpy(d, s, n) bcopy ((s), (d), (n))
403#endif /* not HAVE_MEMCPY */
404
405/* redefs of things that are either in glibc or we have to include them ourselves */
406#if defined(WIN32) && !defined(__MWERKS__) && !defined(__WINE__)
407#define strcasecmp(s1,s2) stricmp(s1,s2)
408#else
409#if !defined(__GLIBC__) || (__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2)
410#ifdef DEFINE_STRCASECMP
411int strcasecmp (const char *s1, const char *s2);
412#endif
413#endif
414#endif
415
416#endif /* ! HAVE_WV_CONFIG_H */
417])
418
419AC_CONFIG_FILES([
420	wvAbw
421	wvDVI
422	wvPS
423	wvPDF
424	wvHtml
425	wvDocBook
426	wvLatex
427	wvCleanLatex
428	wvText
429	wvWml
430	wv-1.0.pc
431	version.c
432	GNUmakefile
433	xml/GNUmakefile
434	help/GNUmakefile
435	help/man/GNUmakefile
436	patterns/GNUmakefile
437	wingdingfont/GNUmakefile
438])
439AC_OUTPUT
440