build all programs by default
[swftools.git] / configure.in
blob3194db12bc2159d76c3d27a2b94a6272e2190cd7
1 dnl Process this file with autoconf to produce a configure script.
3 dnl old autoconf
4 AC_INIT(src/)
6 dnl new autoconf
7 dnl AC_INIT
8 dnl AC_CONFIG_SRCDIR([src/])
10 # ------------------- option parsing -------------------------------
12 DEBUG=
13 CHECKMEM=
14 PROFILING=
15 ENABLE_WARNINGS=
16 OPTIMIZE=
17 USE_POPPLER=
18 DISABLE_LAME=
20 AC_ARG_ENABLE(checkmem,
21 [  --enable-checkmem       turn on ccmalloc debugging], CHECKMEM=true)
22 AC_ARG_ENABLE(debug,
23 [  --enable-debug          turn on debugging], DEBUG=true)
24 AC_ARG_ENABLE(profiling,
25 [  --enable-profiling      turn on profiling], PROFILING=true)
26 AC_ARG_ENABLE(warnings,
27 [  --enable-warnings       turn on compiler warnings], ENABLE_WARNINGS=true)
28 AC_ARG_ENABLE(optimizations,
29 [  --enable-optimizations  turn on compiler optimizations (recommended for avi2swf)], OPTIMIZE=true)
30 AC_ARG_ENABLE(poppler,
31 [  --enable-poppler       link againist libpoppler], USE_POPPLER=true)
32 AC_ARG_ENABLE(lame,
33 [  --disable-lame          "don't compile any L.A.M.E. mp3 encoding code in"],
35 if test "x$enable_lame" = "xno";then
36     DISABLE_LAME=yes
37 fi,DISABLE_LAME=)
39 PACKAGE=swftools
40 VERSION=0.9.1
42 # ------------------------------------------------------------------
44 if test "x${srcdir}" != "x."; then
45     echo "--srcdir is not supported"
46     exit 1
49 WARNINGS="-Wimplicit -Wreturn-type -Wno-write-strings -Wformat"
50 if test "x$ENABLE_WARNINGS" '!=' "x";then
51     WARNINGS="-Wall -Wno-unused -Wno-format -Wno-redundant-decls -Wno-write-strings -D_FORTIFY_SOURCE=2 "
54 if test "x$CHECKMEM" '!=' "x";then
55     DEBUG=yes
57 if test "x$PROFILING" '!=' "x";then
58     DEBUG=yes
60 if test "x$DEBUG" '!=' "x";then
61     if test "x$PROFILING" = "x";then
62         CFLAGS="$WARNINGS -O2 -g $CFLAGS"
63         CXXFLAGS="$WARNINGS -O2 -g $CXXFLAGS"
64         LDFLAGS="-g $LDFLAGS"
65     else
66         CFLAGS="$WARNINGS -O2 -g -pg $CFLAGS"
67         CXXFLAGS="$WARNINGS -O2 -g -pg $CXXFLAGS"
68         LDFLAGS="-g -pg $LDFLAGS"
69     fi
70 else if test "x$OPTIMIZE" '!=' "x"; then
71     CFLAGS="$WARNINGS -O3 -fomit-frame-pointer -Winline $CFLAGS"
72     CXXFLAGS="$WARNINGS -O3 -fomit-frame-pointer -Winline $CXXFLAGS"
73 else
74     CFLAGS="$WARNINGS -O -fomit-frame-pointer $CFLAGS"
75     CXXFLAGS="$WARNINGS -O -fomit-frame-pointer $CXXFLAGS"
79 CFLAGS="-fPIC $CFLAGS"
80 CXXFLAGS="-fPIC $CFLAGS"
82 #OLDGCC=1
83 #if test "x$OLDGCC" '!=' "x";then
84 #     #CFLAGS="$CFLAGS --std=c89 -ansi -pendantic"
85 #     #CXXFLAGS="$CXXFLAGS --std=c89 -ansi -pendantic"
86 #     CFLAGS="$CFLAGS -ansi -pendantic"
87 #     CXXFLAGS="$CXXFLAGS -ansi -pendantic"
88 #fi
90 export PACKAGE VERSION CFLAGS CXXFLAGS
92 dnl Checks for programs.
94 AC_CANONICAL_HOST
96 SLEXT="so"
97 SHARED="-shared"
98 MACOSX=
99 case $host_os in
100     *darwin* ) 
101         MACOSX=yes
102         CFLAGS="$CFLAGS"
103         CXXFLAGS="$CXXFLAGS -fno-rtti"
104         SHARED="-bundle"
105         SLEXT="bundle"
106         if test -d /opt/local/include && test -d /opt/local/lib; then
107             CPPFLAGS="${CPPFLAGS} -I/opt/local/include"
108             LDFLAGS="${LDFLAGS} -L/opt/local/lib"
109         fi
110         # Use fink packages if available.
111         #if test -d /sw/include && test -d /sw/lib; then
112         #    CPPFLAGS="${CPPFLAGS} -I/sw/include"
113         #    LDFLAGS="${LDFLAGS} -L/sw/lib"
114         #fi
115         ;;
116 esac
118 AC_SUBST(SHARED)
120 dnl Checks for programs.
121  AC_PROG_CC
122  AC_PROG_CXX
125 RFX_CHECK_OLDGCC
127 if test "x$GCC_IS_OK" '=' "x";then
128     echo "***************************************************"
129     echo "* Your gcc is too old to compile this!"
130     echo "* "
131     echo "* The last version compileable by this compiler is "
132     echo "* swftools 0.7.0, which you can download from "
133     echo "* http://www.swftools.org/swftools-0.7.0.tar.gz "
134     echo "* ."
135     echo "* Newer versions require at least gcc 3.0.0 "
136     echo "***************************************************"
137     exit 1
139     
140 if test "x$CHECKMEM" '!=' "x";then
141     CC="ccmalloc $CC"
142     CXX="ccmalloc $CXX"
143     #echo running again
144     #unset ac_cv_prog_CC
145     #unset ac_cv_prog_CXX
146     #AC_PROG_CC
147     #AC_PROG_CXX
149  AC_PROG_CPP
151  AC_PROG_RANLIB
152  AC_PROG_MAKE_SET
153  AC_PROG_INSTALL
154  AC_PROG_LN_S
155  AC_CHECK_PROGS(UNCOMPRESS, gzip uncompress compress, )
157 dnl PKG_PROG_PKG_CONFIG
159 dnl Checks for system services
160 OBJEXT="o"
161 AREXT=".a"
162 CXXLIBS="-lstdc++"
164 AC_EXEEXT
166 if test "x$EXEEXT" = "x.exe";then
167     OBJEXT="obj"
168     AREXT=".lib"
169     CXXLIBS=""
171 AC_SUBST(OBJEXT)
172 AC_SUBST(AREXT)
174 RFX_CHECK_MING
176 if test "x${MINGW}" != "xyes"; then
177     # no mingW
178     AC_DEFINE([O_BINARY], [0], [Not defined on mingw])
179 else
180     # mingW
181     SLEXT="dll"
182     CXXLIBS=""
184 export SLEXT
185 AC_SUBST(SLEXT)
186 AC_SUBST(CXXLIBS)
188 # The following tries to make use of includes and libraries in
189 # /usr/local, too. Notice: A -I/usr/local/include might break
190 # things (MingW, cross-compiling etc.) in the same way as -I/usr/include, 
191 # especially on systems which link /usr/local to /usr, so it has yet
192 # to be seen how useful this is.
193 if test -d /usr/local/lib; then
194     LDFLAGS="$LDFLAGS -L/usr/local/lib"
196 if test -d /usr/local/include; then
197 # Leave that alone. It's causing trouble e.g. with gcc 3.2 on gentoo.
198 #   CPPFLAGS="$CPPFLAGS -I/usr/local/include"
199     echo > /dev/null
201 if test "$prefix" != "NONE" -a "$prefix" != "/usr/local" -a "$prefix" != "/usr/local/"; then
202     # if the user has a special prefix (like /opt), there might also be $prefix/lib
203     # and $prefix/include, which should be included in our search paths for libraries
204     # and includes.
205     LDFLAGS="$LDFLAGS -L${libdir}"
206     CPPFLAGS="$CPPFLAGS -I${includedir}"
207     # TODO- test whether gcc still works after this
210 #Mac OS:
211 #LDFLAGS "-L/sw/lib" ; CPPFLAGS "-I/sw/include -I/sw/include/lame"
214 # this must be done after (I believe) AC_PROG_MAKE_SET
215 if test "x$DEBUG" '!=' "x" -o "x$STRIP" = "x";then
216     if test "$MACOSX";then
217         STRIP=dsymutil
218     else
219         STRIP="@echo debug enabled, not stripping "
220     fi
221     export STRIP
222     AC_SUBST(STRIP)
225 dnl Checks for libraries.
226  AC_CHECK_LIB(m, sin,, 
227  echo "Error: Math library not found.";
228  exit;
230  AC_CHECK_LIB(z, deflate,, ZLIBMISSING=true)
232 if test "x$ZLIBMISSING" = "xtrue";then
233     echo 
234     echo "ERROR:"
235     echo "You need zlib to compile swftools"
236     echo
237     exit
240 AC_CHECK_LIB(pdf, PDF_open_file,, PDFLIBMISSING=true)
241 AC_CHECK_LIB(jpeg, jpeg_write_raw_data,, JPEGLIBMISSING=true)
242 AC_CHECK_LIB(ungif, DGifOpen,, UNGIFMISSING=true)
243 if test "$UNGIFMISSING";then
244     UNGIFMISSING=
245     AC_CHECK_LIB(gif, DGifOpen,, UNGIFMISSING=true)
247 AC_CHECK_LIB(zzip, zzip_file_open,, ZZIPMISSING=true)
249 RFX_CHECK_BYTEORDER
250 AC_SUBST(WORDS_BIGENDIAN)
251 RFX_CHECK_SYSTEM_BACKTICKS
252 AC_SUBST(SYSTEM_BACKTICKS)
254 AC_ARG_PROGRAM
256 dnl Checks for header files.
257  AC_CONFIG_HEADER(config.h)
258  AC_HEADER_DIRENT
259  AC_HEADER_STDC
261  AC_CHECK_HEADERS(zlib.h gif_lib.h io.h wchar.h jpeglib.h assert.h signal.h pthread.h sys/stat.h sys/mman.h sys/types.h dirent.h sys/bsdtypes.h sys/ndir.h sys/dir.h ndir.h time.h sys/time.h sys/resource.h pdflib.h zzip/lib.h)
263 AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
264 AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])
265 AC_SUBST(PACKAGE)
266 AC_SUBST(VERSION)
268 AC_SUBST(HAVE_UNISTD_H)
269 AC_SUBST(EXEEXT)
271 dnl Checks for typedefs, structures, and compiler characteristics.
272  AC_C_CONST
273  AC_C_INLINE
274  AC_TYPE_OFF_T
275  AC_TYPE_SIZE_T
276  AC_STRUCT_TM
277  AC_CHECK_TYPE(boolean,int) #needed for jpeglib
278  AC_CHECK_FUNCS(popen wcschr wcsdup mkstemp stat mmap lrand48 rand srand48 srand bcopy bzero time getrusage mallinfo open64 calloc)
280 AC_CHECK_SIZEOF([signed char])
281 AC_CHECK_SIZEOF([signed short])
282 AC_CHECK_SIZEOF([signed])
283 AC_CHECK_SIZEOF([signed long long])
284 AC_CHECK_SIZEOF([void*])
286 RFX_CHECK_FREETYPE
288 RFX_CHECK_FONTCONFIG
290 RFX_CHECK_FFTW
292 # RFX_CHECK_OPENGL
293 # if test "$HAVE_OPENGL";then
294 #     DEVICE_OPENGL='devices/opengl.$(O)'
295 #     AC_SUBST(DEVICE_OPENGL)
296 # fi
297 AC_SUBST(DEVICE_OPENGL)
299 lame_in_source= 
300 lame_makefile=
301 if test "x${DISABLE_LAME}" = "xtrue"; then
302     echo "*" Disabling lame support...
303 else
304     # old lame code at lib/lame
305     if test -f lib/lame/Makefile.in; then
306         lame_in_source='$(lame_objects)'
307         lame_makefile="lib/lame/Makefile"
308         CPPFLAGS="$CPPFLAGS -Ilame -Ilib/lame"
309         AC_DEFINE([HAVE_LAME], [1], [have/use internal l.a.m.e. mp3 library])
310     else
311         if test -d /usr/include/lame; then
312             CPPFLAGS="$CPPFLAGS -I /usr/include/lame"
313         else
314             if test -d /usr/local/include/lame; then
315                 CPPFLAGS="$CPPFLAGS -I /usr/local/include/lame"
316             fi
317         fi
318         AC_CHECK_LIB(mp3lame, lame_init,, NO_LIBMP3LAME=1)
319         HASLAMEHEADER=
320         AC_CHECK_HEADERS(lame.h,HASLAMEHEADER=1)
321         if test "x$NO_LIBMP3LAME" "!=" "x1" -a "x$HASLAMEHEADER" '!=' "x";then
322             AC_DEFINE([HAVE_LAME], [1])
323         fi
324     fi
326 AC_SUBST(lame_in_source)
328 xpdf_in_source=
329 splash_in_source=
330 xpdf_include=
332 if test "x$USE_POPPLER" = "xtrue"; then
333     AC_DEFINE([HAVE_POPPLER],[1],[use poppler])
334     PKG_CHECK_MODULES([POPPLER],[poppler poppler-splash],,[poppler_pkgconfig=no])
335     if test "x$poppler_pkgconfig" = "xno"; then
336         AC_LANG_PUSH([C++])
337         AC_CHECK_HEADERS([OutputDev.h],[
338            AC_CHECK_LIB([poppler],[main],,[])
339         ],[AC_MSG_ERROR([No poppler library found. This library is required.])])
340         AC_LANG_POP
341     else
342         CPPFLAGS="$CPPFLAGS $POPPLER_CFLAGS"
343         LIBS="$LIBS $POPPLER_LIBS"
344         AC_DEFINE([HAVE_POPPLER], [1])
345     fi
346 else
347     splash_in_source='$(splash_objects)'
348     xpdf_in_source='$(xpdf_objects)'
349     xpdf_include=' -I xpdf '
352 AC_SUBST([xpdf_in_source])
353 AC_SUBST([splash_in_source])
354 AC_SUBST([xpdf_include])
356 # ------------------------------------------------------------------
358 RFX_CHECK_LOWERCASE_UPPERCASE
359 RFX_CHECK_AVI2SWF
360 if test "x${AVIFILE}" = "xtrue"; then
361     VIDEO_LIBS="$VIDEO_LIBS $AVIFILE_LIBS"
362     VIDEO_CFLAGS="$VIDEO_CFLAGS $AVIFILE_CFLAGS"
363     AC_DEFINE([HAVE_AVIFILE], [1], [Define if avifile is present])
366 if test "x${WIN32}" != "x"; then
367     #AC_CHECK_LIB(avifil32, AVIFileInit,AVIFIL32=true)
368     #if test "x${AVIFIL32}" != "x"; then
369     #  VIDEO_LIBS="$VIDEO_LIBS -lavifil32"
370     #fi
371     VIDEO_LIBS="$VIDEO_LIBS -lavifil32"
372     AVIFIL32=true
375 AC_SUBST(VIDEO_LIBS)
376 AC_SUBST(VIDEO_CFLAGS)
377 # ------------------------------------------------------------------
379 if test "x${UNCOMPRESS}" = "xgzip"; then
380     AC_DEFINE([USE_GZIP], [1], [Define if gzip is present])
382 AC_SUBST(USE_GZIP)
384 # ------------------------------------------------------------------
386 RFX_CHECK_PYTHON
388 if test "x$PYTHON_OK" '!=' "xyes";then
389     echo all install uninstall clean: > lib/python/Makefile
390     # fail silently- the most users won't have any need for the
391     # python interface anyway
392 else
393     pythongfx="lib/python/Makefile"
394     rm -f lib/python/gfx.c
395     case $PY_VERSION in
396         *2* ) 
397             ln -s gfx2.c lib/python/gfx.c
398             ;;
399         *3* ) 
400             ln -s gfx3.c lib/python/gfx.c
401             ;;
402     esac
405 # ------------------------------------------------------------------
407 RFX_CHECK_RUBY
409 if test "x$RUBY_OK" '!=' "xyes";then
410     if test -d "lib/ruby/";then
411         echo all install uninstall clean: > lib/ruby/Makefile
412     fi
413     # fail silently- the most users won't have any need for the
414     # ruby interface anyway
415 else
416     if test -f "lib/ruby/Makefile.in";then
417         rubygfx="lib/ruby/Makefile"
418     fi
421 # ------------------------------------------------------------------
423 AC_MSG_CHECKING([for missing libraries])
425 if test "x$ZLIBMISSING" = "xtrue";then
426     MISSINGLIBS="${MISSINGLIBS} zlib"
427     DISABLEPNG2SWF=true
428     PARTIAL=true
430 if test "x$JPEGLIBMISSING" = "xtrue";then
431     MISSINGLIBS="${MISSINGLIBS} jpeglib"
432     DISABLEPDF2SWF=true
433     DISABLEJPEG2SWF=true
434     PARTIAL=true
436 if test "x$PDFLIBMISSING" = "xtrue";then
437     DISABLEPDF2PDF=true;
439 #if test "x$T1LIBMISSING" = "xtrue";then
440 #    MISSINGLIBS="${MISSINGLIBS} t1lib"
442 if test "x$UNGIFMISSING" = "xtrue";then
443     DISABLEGIF2SWF=true
444     MISSINGLIBS="${MISSINGLIBS} ungif"
445     PARTIAL=true
448 if test "x${ac_cv_header_pdflib_h}" '!=' "xyes";then
449     DISABLEPDF2PDF=true;
451 if test "x${ac_cv_header_jpeglib_h}" '!=' "xyes"; then
452     DISABLEPDF2SWF=true;
453     DISABLEJPEG2SWF=true;
454     MISSINGLIBS="${MISSINGLIBS} jpeglib.h"
455     PARTIAL=true
457 if test "x$HAVE_FREETYPE" '!=' "x1"; then
458     DISABLEPDF2SWF=true;
459     MISSINGLIBS="${MISSINGLIBS} freetype"
460     PARTIAL=true
462 #if test "x${ac_cv_header_t1lib_h}" '!=' "xyes"; then
463 #    MISSINGLIBS="${MISSINGLIBS} t1lib.h"
465 if test "x${ac_cv_header_gif_lib_h}" '!=' "xyes"; then
466     DISABLEGIF2SWF=true
467     MISSINGLIBS="${MISSINGLIBS} gif_lib.h"
468     PARTIAL=true
470 if test "x${ac_cv_header_zlib_h}" '!=' "xyes"; then
471     DISABLEPNG2SWF=true;
472     MISSINGLIBS="${MISSINGLIBS} zlib.h"
473     PARTIAL=true
475 #if test "x${AVIFILE}" '!=' "xtrue" -a "x${AVIFIL32}" '!=' "xtrue"; then
476 #    MISSINGLIBS="${MISSINGLIBS} avifile"
479 AC_MSG_RESULT(${MISSINGLIBS})
481 # ------------------------------------------------------------------
483 if test "x${MISSINGLIBS}" '!=' "x"; then
484   echo "***************************************************"
485   echo "* The following headers/libraries are missing: " ${MISSINGLIBS}
488 avi2swf="avi2swf/Makefile"
489 if test "x${AVIFILE}" '!=' "xtrue" -a "x${AVIFIL32}" '!=' "xtrue"; then
490  #don't whine, avi2swf is outdated anyway
491  #echo "* Disabling avi2swf tool..."
492  echo all install uninstall clean: > avi2swf/Makefile
493  avi2swf=
496 pdf2swf_makefile="lib/pdf/Makefile"
497 PDF2SWF='pdf2swf$(E)'
498 LIBPDF='libpdf$(A)'
500 if test "x${DISABLEPDF2SWF}" = "xtrue"; then
501   echo "* Disabling pdf2swf tool..."
502   rm -f lib/pdf/Makefile
503   echo all install uninstall clean libpdf libgfxpdf: > lib/pdf/Makefile
504   pdf2swf_makefile=""
505   PDF2SWF=
506   LIBPDF=
508 AC_SUBST(PDF2SWF)
509 AC_SUBST(LIBPDF)
511 PDF2PDF='pdf2pdf$(E)'
512 DEVICE_PDF='devices/pdf.$(O)'
513 if test "x${DISABLEPDF2PDF}" = "xtrue"; then
514   #echo "* Disabling pdf2pdf tool..."
515   PDF2PDF=
516   DEVICE_PDF=
518 AC_SUBST(DEVICE_PDF)
519 AC_SUBST(PDF2PDF)
521 if test "x${ZLIBMISSING}" = "xtrue"; then
522   echo
523   echo "* Warning! Without zlib, you will not be able to read"
524   echo "* or write compressed Flash MX files!"
527 JPEG2SWF='jpeg2swf$(E)'
528 if test "x${DISABLEJPEG2SWF}" = "xtrue"; then
529   echo "* Disabling jpeg2swf tool..."
530   JPEG2SWF=
532 export JPEG2SWF
533 AC_SUBST(JPEG2SWF)
535 GIF2SWF='gif2swf$(E)'
536 if test "x${DISABLEGIF2SWF}" = "xtrue"; then
537   echo "* Disabling gif2swf tool..."
538   GIF2SWF=
540 export GIF2SWF
541 AC_SUBST(GIF2SWF)
543 PNG2SWF='png2swf$(E)'
544 if test "x${DISABLEPNG2SWF}" = "xtrue"; then
545   echo "* Disabling png2swf tool..."
546   PNG2SWF=
548 export PNG2SWF
549 AC_SUBST(PNG2SWF)
551 if test "x${MISSINGLIBS}" '!=' "x"; then
552   if test "x${PARTIAL}" '=' "x"; then
553     echo "* (never mind)"
554   fi
555   echo "***************************************************"
558 # ------------------------------------------------------------------
560 AH_TOP([
561 #ifndef __config_h__
562 #define __config_h__
565 AH_BOTTOM([
566 #ifdef HAVE_ZLIB_H
567 #ifdef HAVE_LIBZ
568 #define HAVE_ZLIB
569 #endif
570 #endif
572 #ifdef HAVE_JPEGLIB_H
573 #ifdef HAVE_LIBJPEG
574 #define HAVE_JPEGLIB
575 #endif
576 #endif
578 #ifdef HAVE_FT2BUILD_H
579 #define HAVE_FREETYPE_H 1
580 #endif
582 #ifdef HAVE_GL_GL_H
583 #ifdef HAVE_GL_GLUT_H
584 #ifdef HAVE_OPENGL
585 #define USE_OPENGL
586 #endif
587 #endif
588 #endif
590 #ifdef HAVE_POPPLER
591 #define GString GooString
592 #define GHash GooHash
593 #define GHashIter GooHashIter
594 #endif
596 #ifdef HAVE_ZZIP_LIB_H
597 #ifdef HAVE_LIBZZIP
598 #define HAVE_ZZIP 1
599 #endif
600 #endif
602 // supply a substitute calloc function if necessary
603 #ifndef HAVE_CALLOC
604 #define calloc rfx_calloc_replacement
605 #endif
607 #endif // __config_h__
610 if test -f "release.in"; then release_in="./release"; fi
611 if test -f "Makefile.new.in"; then mk_in="./Makefile.new"; fi
612 FILES="$release_in $mk_in Makefile.common ${avi2swf} Makefile lib/Makefile lib/action/Makefile src/Makefile ${pdf2swf_makefile} swfs/Makefile ${pythongfx} ${rubygfx} ${lame_makefile} lib/readers/Makefile"
613 AC_OUTPUT(${FILES})
615 dnl new autoconf
616 dnl AC_CONFIG_FILES([${FILES}])
617 dnl AC_OUTPUT
620 # On development trees, create snapshots of config.status
622 if test -f snapshot -a "x$CHECKMEM" = "x" -a "x$PROFILING" = "x";then
623     if test "x${MINGW}" = "xyes"; then
624         echo cp config.status config.status.win32
625         cp config.status config.status.win32
626     else
627         if test "x$DEBUG" '=' "x" -a "x$OPTIMIZE"  '=' "x";then
628             echo cp config.status config.status.linux
629             cp config.status config.status.linux
630         fi
631         if test "x$DEBUG" '!=' "x" -a "x$OPTIMIZE"  '=' "x";then
632             echo cp config.status config.status.debug
633             cp config.status config.status.debug
634         fi
635         if test "x$DEBUG"    = "x" -a "x$OPTIMIZE" '!=' "x"; then
636             echo cp config.status config.status.optimize
637             cp config.status config.status.optimize
638         fi
639     fi