1dnl -- Release version, to bump up right after official releases
2dnl -- last release was 0.4.7
3dnl --
4AC_INIT(ming, 0.4.8)
5MAJOR_VERSION=0
6MINOR_VERSION=4
7MICRO_VERSION=8
8
9MING_VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}
10
11dnl Tell configure to look in the config subdirectory
12dnl for config.guess, config.sub, etc
13AC_CONFIG_AUX_DIR(config)
14
15AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
16m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
17
18AM_MAINTAINER_MODE
19
20dnl -- Version info for libtool, to bump right after official releases
21dnl -- last release was 5:4:6
22dnl --
23INTERFACE_CURRENT=5
24INTERFACE_AGE=4
25INTERFACE_REVISION=7
26
27AC_SUBST(INTERFACE_CURRENT)
28AC_SUBST(INTERFACE_REVISION)
29AC_SUBST(INTERFACE_AGE)
30
31
32dnl GNU recommended way to determine host variables (OS, etc)
33AC_CANONICAL_HOST
34
35AC_PROG_CC
36AC_PROG_CXX
37AC_PROG_INSTALL
38
39dnl AM_PROG_CC_C_O seems to be the better choice when working with automake
40dnl AC_PROG_CC_C_O
41AM_PROG_CC_C_O
42
43dnl necessary to make regenerating configure in maintainer-mode work
44dnl set in Makefile.am for autoreconf too
45dnl AC_SUBST(ACLOCAL_AMFLAGS, "-I macros")
46
47AC_ARG_ENABLE(
48[cpp],
49[  --enable-cpp            Enable C++ support (default: enabled)],
50[case "${enableval}" in
51  yes) cpp_support=yes ;;
52   no) cpp_support=no ;;
53    *) AC_MSG_ERROR([bad value ${enableval} for --enable-c++ option]) ;;
54esac],
55cpp_support=yes)
56
57dnl --------------------------------------------
58dnl Check if we should build python extension
59dnl --------------------------------------------
60AC_PATH_PROG(PYTHON, python)
61AM_CONDITIONAL(HAVE_PYTHON, test x"$PYTHON" != x)
62AC_ARG_ENABLE(
63[python],
64[  --enable-python         Enable build of python extension (default: disabled)],
65[case "${enableval}" in
66  yes) python_ext=yes ;;
67   no) python_ext=no ;;
68    *) AC_MSG_ERROR([bad value ${enableval} for --enable-python-ext option]) ;;
69esac],
70python_ext=no)
71
72if test x"$python_ext" = xyes; then
73	if test x"$PYTHON" = x; then
74		AC_MSG_ERROR([Can't build python extension, as python executable could not be found])
75	fi
76
77	AC_PYTHON_DEVEL
78fi
79
80AM_CONDITIONAL(BUILD_PYTHON_EXTENSION, test x"$python_ext" = xyes)
81
82
83dnl --------------------------------------------
84dnl Check if we should build perl extension
85dnl --------------------------------------------
86
87AC_PATH_PROG(PERL, perl)
88AM_CONDITIONAL(HAVE_PERL, test x"$PERL" != x)
89
90AC_ARG_ENABLE(
91[perl],
92[  --enable-perl           Enable build of perl extension (default: disabled)],
93[case "${enableval}" in
94  yes) perl_ext=yes ;;
95   no) perl_ext=no ;;
96    *) AC_MSG_ERROR([bad value ${enableval} for --enable-perl-ext option]) ;;
97esac], perl_ext=no)
98
99if test x"$perl_ext" = xyes; then
100	if test x"$PERL" = x; then
101		AC_MSG_ERROR([Can't build perl extension, as perl executable could not be found])
102	fi
103fi
104
105AM_CONDITIONAL(BUILD_PERL_EXTENSION, test x"$perl_ext" = xyes)
106
107dnl --------------------------------------------
108dnl Check if we should build php extension
109dnl --------------------------------------------
110
111AC_PATH_PROG(PHP, php)
112AC_PATH_PROG(PHPIZE, phpize)
113dnl AM_CONDITIONAL(HAVE_PHP, test x"$PHP" != x)
114
115AC_ARG_ENABLE(
116[php],
117[  --enable-php            Enable build of php extension (default: disabled)],
118[case "${enableval}" in
119  yes) php_ext=yes ;;
120   no) php_ext=no ;;
121    *) AC_MSG_ERROR([bad value ${enableval} for --enable-php-ext option]) ;;
122esac], php_ext=no)
123
124if test x"$php_ext" = xyes; then
125	if test x"$PHP" = x -o x"$PHPIZE" = x ; then
126		AC_MSG_ERROR([Can't build php extension, as php or phpize executable could not be found])
127	fi
128fi
129
130AM_CONDITIONAL(BUILD_PHP_EXTENSION, test x"$php_ext" = xyes)
131
132dnl --------------------------------------------
133dnl Check if we should build tcl extension
134dnl --------------------------------------------
135
136AC_PATH_PROG(TCL, tclsh)
137AM_CONDITIONAL(HAVE_TCL, test x"$TCL" != x)
138
139AC_ARG_ENABLE(
140[tcl],
141[  --enable-tcl            Enable build of tcl extension (default: disabled)],
142[case "${enableval}" in
143  yes) tcl_ext=yes ;;
144   no) tcl_ext=no ;;
145    *) AC_MSG_ERROR([bad value ${enableval} for --enable-tcl-ext option]) ;;
146esac], tcl_ext=no)
147
148if test x"$tcl_ext" = xyes; then
149	if test x"$TCL" = x; then
150		AC_MSG_ERROR([Can't build tcl extension, as tcl executable could not be found])
151	fi
152
153tclbindir=`dirname $TCL`
154
155tcllibdirs_default="\
156$prefix/lib/itcl \
157$prefix/lib \
158$HOME/local/lib \
159$HOME/lib \
160/usr/local/lib \
161/usr/lib64 \
162/usr/lib \
163`dirname $tclbindir`/lib"
164
165	for i in $tcllibdirs_default; do
166	  for suf in 8.3 8.4 ""; do
167	    if test -f $i/libtcl$suf.so || test -f $i/libtcl$suf.a; then
168	     TCL_LIB_DIR=$i
169	     break
170	    fi
171	  done
172	done
173
174	if test -z "$TCL_LIB_DIR"; then
175	  AC_MSG_ERROR(Unable to find a Tcl library.)
176	fi
177
178tclincdirs_default="\
179/usr/include/tcl-private/generic \
180/usr/include/tk-private/generic \
181/usr/include/itcl-private/generic \
182/usr/include/tcl8.4 \
183/usr/include/tcl8.4/tcl-private/generic \
184/usr/include/tcl8.4/tk-private/generic \
185/usr/include/tcl8.4/itcl-private/generic \
186/usr/include/tcl8.4 \
187/usr/include/tcl8.3/tcl-private/generic \
188/usr/include/tcl8.3/tk-private/generic \
189/usr/include/tcl8.3/itcl-private/generic \
190/usr/include/tcl8.3 \
191/usr/include/tcl8.2/generic \
192$prefix/include/itcl \
193/usr/include/itcl3.1/generic/ \
194$prefix/include \
195$HOME/local/include \
196$HOME/include \
197/usr/local/include \
198/usr/include/tcl \
199/usr/include \
200`dirname $tclbindir`/include"
201
202	for i in $tclincdirs_default; do
203	   if test -f $i/tcl.h; then
204	     TCL_INC_DIR=$i
205	     break
206	   fi
207	done
208
209	if test -z "$TCL_INC_DIR"; then
210	  AC_MSG_ERROR(Unable to find a Tcl header.)
211	fi
212
213fi
214
215AM_CONDITIONAL(BUILD_TCL_EXTENSION, test x"$tcl_ext" = xyes)
216AC_SUBST(TCL_LIB_DIR)
217AC_SUBST(TCL_INC_DIR)
218
219dnl --------------------------------------------
220dnl Check for required programs
221dnl --------------------------------------------
222
223
224dnl AC_PROG_YACC
225
226AC_CHECK_PROGS(YACC, 'bison -y' byacc yacc)
227if test x"$YACC" = x; then
228	echo "To compile ming please install bison:"
229	echo " as .deb user: sudo apt-get install bison"
230	AC_MSG_ERROR([Could not detect yacc/bison!])
231fi
232
233AC_CHECK_PROGS(LEX, flex lex)
234if test x"$LEX" = x; then
235	echo "To compile ming please install flex:"
236	echo " as .deb user: sudo apt-get install flex"
237	AC_MSG_ERROR([Could not find lex/flex!])
238fi
239
240AC_PROG_LIBTOOL
241if test x"$LIBTOOL" = x; then
242	AC_MSG_ERROR([could not detect libtool, bailing out])
243fi
244
245dnl Check if the X libraries are installed (needed for libungif on at least Solaris)
246AC_CHECK_LIB(X11, XGetImage, XLIB="-lX11", XLIB="")
247
248AC_ARG_ENABLE(
249[freetype],
250[  --disable-freetype      Disable freetype support (default: enabled)],
251[case "${enableval}" in
252  yes) freetype_support=yes ;;
253   no) freetype_support=no ;;
254    *) AC_MSG_ERROR([bad value ${enableval} for --enable-freetype option]) ;;
255esac],
256freetype_support=yes)
257
258if test "$freetype_support" = "yes"; then
259	dnl Check for the freetype library
260	PKG_PROG_PKG_CONFIG
261	PKG_CHECK_MODULES(FREETYPE, freetype2, HAS_FREETYPE=true,
262		AC_MSG_ERROR([Could not find freetype])
263	)
264fi
265
266dnl Check for the ungif or gif (new or old) libraries
267AC_CHECK_LIB(gif, GifErrorString, GIFLIB="-lgif", GIFLIB="")
268AC_CHECK_LIB(gif, PrintGifError, GIFLIB="-lgif")
269if test x"${GIFLIB}" = x; then
270AC_CHECK_LIB(ungif, PrintGifError, GIFLIB="-lungif")
271fi
272dnl MinGW check for libungif
273AC_CHECK_LIB(ungif, DGifOpen, GIFLIB="-lungif")
274dnl Solaris needs -lX11 on the linker line for ungif to work
275AC_CHECK_LIB(gif, GifErrorString, GIFLIB="-lgif",, "-lX11")
276AC_CHECK_LIB(gif, PrintGifError, GIFLIB="-lgif",, "-lX11")
277if test x"${GIFLIB}" = x; then
278AC_CHECK_LIB(ungif, PrintGifError, GIFLIB="-lungif",, "-lX11")
279fi
280AC_CHECK_HEADERS([gif_lib.h], GIFINC="true", GIFINC="")
281
282dnl Check for the png library
283dnl Solaris needs -lm on the linker line, and other platforms aren't bothered having it there. :)
284AC_CHECK_LIB(png, png_read_image, PNGLIB="-lpng", PNGLIB="", "-lm")
285
286dnl Check for the zlib library
287AC_CHECK_LIB(z, compress2,
288	ZLIB="-lz",
289	dnl Windows has the zlib library, but its named zdll instead
290	AC_CHECK_LIB(zdll, compress2, ZLIB="-lzdll", ZLIB="")
291)
292AC_CHECK_HEADERS([zlib.h], ZLIB_INC="true", ZLIB_INC="")
293AC_CHECK_HEADERS([getopt.h])
294
295dnl Check if the vasprintf function exists on this platform
296dnl (It's not present on MinGW and Solaris 10 at the time of this coding)
297dnl Also check for the presence of the mkstemp function (it's not on MinGW)
298AC_CHECK_FUNCS(vasprintf mkstemp)
299
300dnl Check for various getopt functions
301AC_CHECK_FUNCS(getopt getopt_long)
302
303AC_CHECK_FUNC(sin, MATHLIB="", [
304        AC_CHECK_LIB(m, sin, MATHLIB="-lm", [
305		AC_ERROR([I can't find sin() function !!!])]
306	)]
307)
308
309AC_DEFINE(TRACK_ALLOCS, 1, [Define this if you want Ming to track all objects allocations. Ming will mantain a doubly linked list of allocated objects, call Ming_collectGarbage() to get rid of them all])
310
311AM_CONDITIONAL(USE_CXX, [test "x${CXX}" != x -a "x${cpp_support}" = "xyes"])
312if test -n "${CXX}" -a "x${cpp_support}" = "xyes"; then
313	AC_DEFINE([USE_CXX], [1], [Use c++])
314fi
315
316AM_CONDITIONAL(USE_ZLIB, test x${ZLIB} != x -a x${ZLIB_INC} != x)
317if test -n "${ZLIB}" -a -n "${ZLIB_INC}"; then
318	AC_DEFINE([USE_ZLIB], [1], [Use zlib])
319fi
320
321AM_CONDITIONAL(USE_FREETYPE, test x${HAS_FREETYPE} != x)
322if test x${HAS_FREETYPE} = xtrue ; then
323       AC_DEFINE(USE_FREETYPE, [1], [Use freetype library])
324fi
325
326AM_CONDITIONAL(GIFLIB_GIFERRORSTRING, test x"$ac_cv_lib_gif_GifErrorString" = xyes)
327if test x"$ac_cv_lib_gif_GifErrorString" = xyes; then
328	AC_DEFINE(GIFLIB_GIFERRORSTRING, [1], [Use giflib with GifErrorString, introduced 4.2.0])
329fi
330AM_CONDITIONAL(USE_GIF, test x"${GIFINC}" != x -a x"${GIFLIB}" != x)
331if test x"${GIFINC}" != x -a x"${GIFLIB}" != x; then
332	AC_DEFINE(USE_GIF, [1], [Use a gif library])
333fi
334
335AM_CONDITIONAL(USE_PNG, test x${PNGLIB} != x)
336if test -n "${PNGLIB}"; then
337 	AC_DEFINE(USE_PNG, [1], [Use png library])
338fi
339
340MACHINE=`uname -m`
341case "$MACHINE" in
342"x86_64")
343	CFLAGS="$CFLAGS -Wall -fPIC"
344	;;
345"alpha")
346	CFLAGS="$CFLAGS -Wall -fPIC"
347	;;
348"ia64")
349	CFLAGS="$CFLAGS -Wall -fPIC"
350	;;
351"hppa")
352	CFLAGS="$CFLAGS -Wall -fPIC"
353	;;
354"sun4u")
355	CFLAGS="$CFLAGS -fPIC -features=extensions"
356	;;
357*)
358	CFLAGS="$CFLAGS -Wall"
359	;;
360esac
361
362
363dnl -------------------------------------------
364dnl Byteorder check
365dnl -------------------------------------------
366AC_C_BIGENDIAN(CFLAGS="$CFLAGS -DSWF_BIG_ENDIAN", CFLAGS="$CFLAGS -DSWF_LITTLE_ENDIAN")
367
368AC_SUBST(SHCFLAGS)
369AC_SUBST(GIFLIB)
370AC_SUBST(PNGLIB)
371AC_SUBST(MATHLIB)
372AC_SUBST(XLIB)
373AC_SUBST(ZLIB)
374AC_SUBST(MAJOR_VERSION)
375AC_SUBST(MINOR_VERSION)
376AC_SUBST(MICRO_VERSION)
377AC_SUBST(MING_VERSION)
378
379AM_CONFIG_HEADER(src/ming_config.h)
380AH_TOP(
381#ifndef __MING_CONFIG_H
382#define __MING_CONFIG_H
383)
384AH_BOTTOM(
385#endif
386)
387
388dnl AC_OUTPUT(Makefile.config src/ming.h util/ming-config)
389AC_OUTPUT([
390	docs/Makefile
391	docs/man/Makefile
392	Makefile
393	src/actioncompiler/Makefile
394	src/blocks/Makefile
395	src/Makefile
396	src/ming.h
397	src/libming.pc
398	perl_ext/Makefile
399	perl_ext/SWF.pm
400	php_ext/Makefile
401	py_ext/Makefile
402	py_ext/setup.py
403	tcl_ext/Makefile
404	test/Makefile
405	test/Media/Makefile
406	test/Movie/Makefile
407	test/Movie/Background/Makefile
408	test/Movie/Dimension/Makefile
409	test/Movie/add/Makefile
410	test/Movie/new/Makefile
411	test/Movie/nextFrame/Makefile
412	test/Movie/NumFrames/Makefile
413	test/Movie/FrameLabel/Makefile
414	test/Movie/Protect/Makefile
415	test/Movie/Rate/Makefile
416	test/Movie/addMetadata/Makefile
417	test/Movie/setSoundStream/Makefile
418	test/Movie/setTabIndex/Makefile
419	test/Movie/setScriptLimits/Makefile
420	test/Movie/setNetworkAccess/Makefile
421	test/Movie/replace/Makefile
422	test/Movie/assignSymbol/Makefile
423	test/Movie/defineScene/Makefile
424	test/Movie/importCharacter/Makefile
425	test/Filter/Makefile
426	test/Morph/Makefile
427	test/Video/Makefile
428	test/actionscript/Makefile
429	test/Shape/Makefile
430	test/Shape/addSolidFill/Makefile
431	test/LineStyle/Makefile
432	test/MovieClip/Makefile
433	test/Gradient/Makefile
434	test/FillStyle/Makefile
435	test/Font/Makefile
436	test/Text/Makefile
437	test/Bitmap/Makefile
438	test/BrowserFont/Makefile
439	test/TextField/Makefile
440	test/PrebuiltClip/Makefile
441	test/Button/Makefile
442	test/Action/Makefile
443	test/Sound/Makefile
444	test/SoundStream/Makefile
445	macros/Makefile
446	util/Makefile
447	util/ming-config
448	ming.spec
449])
450
451
452chmod +x "$srcdir"/config/install-sh
453
454echo "Config summary: "
455
456if test x"$CXX" != x -a "x$cpp_support" = "xyes"; then
457	echo "  C++ enabled"
458else
459	echo "  C++ disabled"
460fi
461if test x"$perl_ext" = "xyes"; then
462	echo "  Perl extension enabled"
463else
464	echo "  Perl extension disabled"
465fi
466
467if test x"$php_ext" = "xyes"; then
468	echo "  PHP extension enabled"
469else
470	echo "  PHP extension disabled"
471fi
472
473if test x"$python_ext" = "xyes"; then
474	echo "  Python extension enabled"
475else
476	echo "  Python extension disabled"
477fi
478
479if test x"$tcl_ext" = "xyes"; then
480	echo "  Tcl extension enabled"
481else
482	echo "  Tcl extension disabled"
483fi
484
485if test x"$ZLIB" = "x" -o x"$ZLIB_INC" = x; then
486	echo "  ZLIB disabled"
487else
488	echo "  ZLIB enabled ($ZLIB)"
489fi
490
491if test x"$HAS_FREETYPE" = "x"; then
492	echo "  Freetype library disabled"
493else
494	echo "  Freetype library enabled ($FREETYPE_LIBS)"
495fi
496
497if test x"$GIFLIB" = "x" -o x"$GIFINC" = "x"; then
498	echo "  GIF library disabled"
499else
500	echo "  GIF library enabled ($GIFLIB)"
501fi
502
503if test x"$PNGLIB" = "x"; then
504	echo "  PNG library disabled"
505else
506	echo "  PNG library enabled ($PNGLIB)"
507fi
508
509