configure.in: quote LAME help test so it doesnt break VIMs syntax highlighting
[swftools.git] / configure.in
blob9cc3f23c2f32722148dd40705eab87f42bea4b76
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 DISABLE_LAME=
19 AC_ARG_ENABLE(checkmem,
20 [  --enable-checkmem       turn on ccmalloc debugging], CHECKMEM=true)
21 AC_ARG_ENABLE(debug,
22 [  --enable-debug          turn on debugging], DEBUG=true)
23 AC_ARG_ENABLE(profiling,
24 [  --enable-profiling      turn on profiling], PROFILING=true)
25 AC_ARG_ENABLE(warnings,
26 [  --enable-warnings       turn on compiler warnings], ENABLE_WARNINGS=true)
27 AC_ARG_ENABLE(optimizations,
28 [  --enable-optimizations  turn on compiler optimizations (recommended for avi2swf)], OPTIMIZE=true)
29 AC_ARG_ENABLE(lame,
30 [  --disable-lame          "don't compile any L.A.M.E. mp3 encoding code in"],
32 if test "x$enable_lame" = "xno";then
33     DISABLE_LAME=yes
34 fi,DISABLE_LAME=)
36 PACKAGE=swftools
37 VERSION=0.9.1
39 # ------------------------------------------------------------------
41 if test "x${srcdir}" != "x."; then
42     echo "--srcdir is not supported"
43     exit 1
46 WARNINGS="-Wimplicit -Wreturn-type -Wno-write-strings -Wformat"
47 if test "x$ENABLE_WARNINGS" '!=' "x";then
48     WARNINGS="-Wall -Wno-unused -Wno-format -Wno-redundant-decls -Wno-write-strings -D_FORTIFY_SOURCE=2 "
51 if test "x$CHECKMEM" '!=' "x";then
52     DEBUG=yes
54 if test "x$PROFILING" '!=' "x";then
55     DEBUG=yes
57 if test "x$DEBUG" '!=' "x";then
58     if test "x$PROFILING" = "x";then
59         CFLAGS="$WARNINGS -O2 -g $CFLAGS"
60         CXXFLAGS="$WARNINGS -O2 -g $CXXFLAGS"
61         LDFLAGS="-g $LDFLAGS"
62     else
63         CFLAGS="$WARNINGS -O2 -g -pg $CFLAGS"
64         CXXFLAGS="$WARNINGS -O2 -g -pg $CXXFLAGS"
65         LDFLAGS="-g -pg $LDFLAGS"
66     fi
67 else if test "x$OPTIMIZE" '!=' "x"; then
68     CFLAGS="$WARNINGS -O3 -fomit-frame-pointer -Winline $CFLAGS"
69     CXXFLAGS="$WARNINGS -O3 -fomit-frame-pointer -Winline $CXXFLAGS"
70 else
71     CFLAGS="$WARNINGS -O -fomit-frame-pointer $CFLAGS"
72     CXXFLAGS="$WARNINGS -O -fomit-frame-pointer $CXXFLAGS"
76 CFLAGS="-fPIC $CFLAGS"
77 CXXFLAGS="-fPIC $CFLAGS"
79 #OLDGCC=1
80 #if test "x$OLDGCC" '!=' "x";then
81 #     #CFLAGS="$CFLAGS --std=c89 -ansi -pendantic"
82 #     #CXXFLAGS="$CXXFLAGS --std=c89 -ansi -pendantic"
83 #     CFLAGS="$CFLAGS -ansi -pendantic"
84 #     CXXFLAGS="$CXXFLAGS -ansi -pendantic"
85 #fi
87 export PACKAGE VERSION CFLAGS CXXFLAGS
89 dnl Checks for programs.
91 AC_CANONICAL_HOST
93 SLEXT="so"
94 SHARED="-shared"
95 MACOSX=
96 case $host_os in
97     *darwin* ) 
98         MACOSX=yes
99         CFLAGS="$CFLAGS"
100         CXXFLAGS="$CXXFLAGS -fno-rtti"
101         SHARED="-bundle"
102         SLEXT="bundle"
103         if test -d /opt/local/include && test -d /opt/local/lib; then
104             CPPFLAGS="${CPPFLAGS} -I/opt/local/include"
105             LDFLAGS="${LDFLAGS} -L/opt/local/lib"
106         fi
107         # Use fink packages if available.
108         #if test -d /sw/include && test -d /sw/lib; then
109         #    CPPFLAGS="${CPPFLAGS} -I/sw/include"
110         #    LDFLAGS="${LDFLAGS} -L/sw/lib"
111         #fi
112         ;;
113 esac
115 AC_SUBST(SHARED)
117 dnl Checks for programs.
118  AC_PROG_CC
119  AC_PROG_CXX
122 RFX_CHECK_OLDGCC
124 if test "x$GCC_IS_OK" '=' "x";then
125     echo "***************************************************"
126     echo "* Your gcc is too old to compile this!"
127     echo "* "
128     echo "* The last version compileable by this compiler is "
129     echo "* swftools 0.7.0, which you can download from "
130     echo "* http://www.swftools.org/swftools-0.7.0.tar.gz "
131     echo "* ."
132     echo "* Newer versions require at least gcc 3.0.0 "
133     echo "***************************************************"
134     exit 1
136     
137 if test "x$CHECKMEM" '!=' "x";then
138     CC="ccmalloc $CC"
139     CXX="ccmalloc $CXX"
140     #echo running again
141     #unset ac_cv_prog_CC
142     #unset ac_cv_prog_CXX
143     #AC_PROG_CC
144     #AC_PROG_CXX
146  AC_PROG_CPP
148  AC_PROG_RANLIB
149  AC_PROG_MAKE_SET
150  AC_PROG_INSTALL
151  AC_PROG_LN_S
152  AC_CHECK_PROGS(UNCOMPRESS, gzip uncompress compress, )
154 dnl PKG_PROG_PKG_CONFIG
156 dnl Checks for system services
157 OBJEXT="o"
158 AREXT=".a"
159 CXXLIBS="-lstdc++"
161 AC_EXEEXT
163 if test "x$EXEEXT" = "x.exe";then
164     OBJEXT="obj"
165     AREXT=".lib"
166     CXXLIBS=""
168 AC_SUBST(OBJEXT)
169 AC_SUBST(AREXT)
171 RFX_CHECK_MING
173 if test "x${MINGW}" != "xyes"; then
174     # no mingW
175     AC_DEFINE([O_BINARY], [0], [Not defined on mingw])
176 else
177     # mingW
178     SLEXT="dll"
179     CXXLIBS=""
181 export SLEXT
182 AC_SUBST(SLEXT)
183 AC_SUBST(CXXLIBS)
185 # The following tries to make use of includes and libraries in
186 # /usr/local, too. Notice: A -I/usr/local/include might break
187 # things (MingW, cross-compiling etc.) in the same way as -I/usr/include, 
188 # especially on systems which link /usr/local to /usr, so it has yet
189 # to be seen how useful this is.
190 if test -d /usr/local/lib; then
191     LDFLAGS="$LDFLAGS -L/usr/local/lib"
193 if test -d /usr/local/include; then
194 # Leave that alone. It's causing trouble e.g. with gcc 3.2 on gentoo.
195 #   CPPFLAGS="$CPPFLAGS -I/usr/local/include"
196     echo > /dev/null
198 if test "$prefix" != "NONE" -a "$prefix" != "/usr/local" -a "$prefix" != "/usr/local/"; then
199     # if the user has a special prefix (like /opt), there might also be $prefix/lib
200     # and $prefix/include, which should be included in our search paths for libraries
201     # and includes.
202     LDFLAGS="$LDFLAGS -L${libdir}"
203     CPPFLAGS="$CPPFLAGS -I${includedir}"
204     # TODO- test whether gcc still works after this
207 #Mac OS:
208 #LDFLAGS "-L/sw/lib" ; CPPFLAGS "-I/sw/include -I/sw/include/lame"
211 # this must be done after (I believe) AC_PROG_MAKE_SET
212 if test "x$DEBUG" '!=' "x" -o "x$STRIP" = "x";then
213     if test "$MACOSX";then
214         STRIP=dsymutil
215     else
216         STRIP="@echo debug enabled, not stripping "
217     fi
218     export STRIP
219     AC_SUBST(STRIP)
222 dnl Checks for libraries.
223  AC_CHECK_LIB(m, sin,, 
224  echo "Error: Math library not found.";
225  exit;
227  AC_CHECK_LIB(z, deflate,, ZLIBMISSING=true)
229 if test "x$ZLIBMISSING" = "xtrue";then
230     echo 
231     echo "ERROR:"
232     echo "You need zlib to compile swftools"
233     echo
234     exit
237 AC_CHECK_LIB(pdf, PDF_open_file,, PDFLIBMISSING=true)
238 AC_CHECK_LIB(jpeg, jpeg_write_raw_data,, JPEGLIBMISSING=true)
239 AC_CHECK_LIB(ungif, DGifOpen,, UNGIFMISSING=true)
240 if test "$UNGIFMISSING";then
241     UNGIFMISSING=
242     AC_CHECK_LIB(gif, DGifOpen,, UNGIFMISSING=true)
244 AC_CHECK_LIB(zzip, zzip_file_open,, ZZIPMISSING=true)
246 RFX_CHECK_BYTEORDER
247 AC_SUBST(WORDS_BIGENDIAN)
248 RFX_CHECK_SYSTEM_BACKTICKS
249 AC_SUBST(SYSTEM_BACKTICKS)
251 AC_ARG_PROGRAM
253 dnl Checks for header files.
254  AC_CONFIG_HEADER(config.h)
255  AC_HEADER_DIRENT
256  AC_HEADER_STDC
258  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)
260 AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
261 AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])
262 AC_SUBST(PACKAGE)
263 AC_SUBST(VERSION)
265 AC_SUBST(HAVE_UNISTD_H)
266 AC_SUBST(EXEEXT)
268 dnl Checks for typedefs, structures, and compiler characteristics.
269  AC_C_CONST
270  AC_C_INLINE
271  AC_TYPE_OFF_T
272  AC_TYPE_SIZE_T
273  AC_STRUCT_TM
274  AC_CHECK_TYPE(boolean,int) #needed for jpeglib
275  AC_CHECK_FUNCS(popen wcschr wcsdup mkstemp stat mmap lrand48 rand srand48 srand bcopy bzero time getrusage mallinfo open64 calloc)
277 AC_CHECK_SIZEOF([signed char])
278 AC_CHECK_SIZEOF([signed short])
279 AC_CHECK_SIZEOF([signed])
280 AC_CHECK_SIZEOF([signed long long])
281 AC_CHECK_SIZEOF([void*])
283 RFX_CHECK_FREETYPE
285 RFX_CHECK_FONTCONFIG
287 RFX_CHECK_FFTW
289 # RFX_CHECK_OPENGL
290 # if test "$HAVE_OPENGL";then
291 #     DEVICE_OPENGL='devices/opengl.$(O)'
292 #     AC_SUBST(DEVICE_OPENGL)
293 # fi
294 AC_SUBST(DEVICE_OPENGL)
296 lame_in_source= 
297 lame_makefile=
298 if test "x${DISABLE_LAME}" = "xtrue"; then
299     echo "*" Disabling lame support...
300 else
301     # old lame code at lib/lame
302     if test -f lib/lame/Makefile.in; then
303         lame_in_source='$(lame_objects)'
304         lame_makefile="lib/lame/Makefile"
305         CPPFLAGS="$CPPFLAGS -Ilame -Ilib/lame"
306         AC_DEFINE([HAVE_LAME], [1], [have/use internal l.a.m.e. mp3 library])
307     else
308         if test -d /usr/include/lame; then
309             CPPFLAGS="$CPPFLAGS -I /usr/include/lame"
310         else
311             if test -d /usr/local/include/lame; then
312                 CPPFLAGS="$CPPFLAGS -I /usr/local/include/lame"
313             fi
314         fi
315         AC_CHECK_LIB(mp3lame, lame_init,, NO_LIBMP3LAME=1)
316         HASLAMEHEADER=
317         AC_CHECK_HEADERS(lame.h,HASLAMEHEADER=1)
318         if test "x$NO_LIBMP3LAME" "!=" "x1" -a "x$HASLAMEHEADER" '!=' "x";then
319             AC_DEFINE([HAVE_LAME], [1])
320         fi
321     fi
323 AC_SUBST(lame_in_source)
325 splash_in_source='$(splash_objects)'
326 xpdf_in_source='$(xpdf_objects)'
328 dnl if test "x$USE_POPPLER" = "xtrue"; then
329 dnl     xpdf_in_source=
330 dnl     splash_in_source=
331 dnl     AC_DEFINE([HAVE_POPPLER],[1],[use poppler])
332 dnl     PKG_CHECK_MODULES([POPPLER],[poppler poppler-splash],,[poppler_pkgconfig=no])
333 dnl     if test "x$poppler_pkgconfig" = "xno"; then
334 dnl         AC_LANG_PUSH([C++])
335 dnl         AC_CHECK_HEADERS([OutputDev.h],[
336 dnl            AC_CHECK_LIB([poppler],[main],,[])
337 dnl         ],[AC_MSG_ERROR([No poppler library found. This library is required.])])
338 dnl         AC_LANG_POP
339 dnl     else
340 dnl     CPPFLAGS="$CPPFLAGS $POPPLER_CFLAGS"
341 dnl         AC_DEFINE([HAVE_POPPLER], [1])
342 dnl         LIBS="$LIBS $POPPLER_LIBS"
343 dnl     fi
344 dnl fi
346 AC_SUBST([xpdf_in_source])
347 AC_SUBST([splash_in_source])
349 # ------------------------------------------------------------------
351 RFX_CHECK_LOWERCASE_UPPERCASE
352 RFX_CHECK_AVI2SWF
353 if test "x${AVIFILE}" = "xtrue"; then
354     VIDEO_LIBS="$VIDEO_LIBS $AVIFILE_LIBS"
355     VIDEO_CFLAGS="$VIDEO_CFLAGS $AVIFILE_CFLAGS"
356     AC_DEFINE([HAVE_AVIFILE], [1], [Define if avifile is present])
359 if test "x${WIN32}" != "x"; then
360     #AC_CHECK_LIB(avifil32, AVIFileInit,AVIFIL32=true)
361     #if test "x${AVIFIL32}" != "x"; then
362     #  VIDEO_LIBS="$VIDEO_LIBS -lavifil32"
363     #fi
364     VIDEO_LIBS="$VIDEO_LIBS -lavifil32"
365     AVIFIL32=true
368 AC_SUBST(VIDEO_LIBS)
369 AC_SUBST(VIDEO_CFLAGS)
370 # ------------------------------------------------------------------
372 if test "x${UNCOMPRESS}" = "xgzip"; then
373     AC_DEFINE([USE_GZIP], [1], [Define if gzip is present])
375 AC_SUBST(USE_GZIP)
377 # ------------------------------------------------------------------
379 RFX_CHECK_PYTHON
381 if test "x$PYTHON_OK" '!=' "xyes";then
382     echo all install uninstall clean: > lib/python/Makefile
383     # fail silently- the most users won't have any need for the
384     # python interface anyway
385 else
386     pythongfx="lib/python/Makefile"
389 # ------------------------------------------------------------------
391 RFX_CHECK_RUBY
393 if test "x$RUBY_OK" '!=' "xyes";then
394     if test -d "lib/ruby/";then
395         echo all install uninstall clean: > lib/ruby/Makefile
396     fi
397     # fail silently- the most users won't have any need for the
398     # ruby interface anyway
399 else
400     if test -f "lib/ruby/Makefile.in";then
401         rubygfx="lib/ruby/Makefile"
402     fi
405 # ------------------------------------------------------------------
407 AC_MSG_CHECKING([for missing libraries])
409 if test "x$ZLIBMISSING" = "xtrue";then
410     MISSINGLIBS="${MISSINGLIBS} zlib"
411     DISABLEPNG2SWF=true
412     PARTIAL=true
414 if test "x$JPEGLIBMISSING" = "xtrue";then
415     MISSINGLIBS="${MISSINGLIBS} jpeglib"
416     DISABLEPDF2SWF=true
417     DISABLEJPEG2SWF=true
418     PARTIAL=true
420 if test "x$PDFLIBMISSING" = "xtrue";then
421     DISABLEPDF2PDF=true;
423 #if test "x$T1LIBMISSING" = "xtrue";then
424 #    MISSINGLIBS="${MISSINGLIBS} t1lib"
426 if test "x$UNGIFMISSING" = "xtrue";then
427     DISABLEGIF2SWF=true
428     MISSINGLIBS="${MISSINGLIBS} ungif"
429     PARTIAL=true
432 if test "x${ac_cv_header_pdflib_h}" '!=' "xyes";then
433     DISABLEPDF2PDF=true;
435 if test "x${ac_cv_header_jpeglib_h}" '!=' "xyes"; then
436     DISABLEPDF2SWF=true;
437     DISABLEJPEG2SWF=true;
438     MISSINGLIBS="${MISSINGLIBS} jpeglib.h"
439     PARTIAL=true
441 if test "x$HAVE_FREETYPE" '!=' "x1"; then
442     DISABLEPDF2SWF=true;
443     MISSINGLIBS="${MISSINGLIBS} freetype"
444     PARTIAL=true
446 #if test "x${ac_cv_header_t1lib_h}" '!=' "xyes"; then
447 #    MISSINGLIBS="${MISSINGLIBS} t1lib.h"
449 if test "x${ac_cv_header_gif_lib_h}" '!=' "xyes"; then
450     DISABLEGIF2SWF=true
451     MISSINGLIBS="${MISSINGLIBS} gif_lib.h"
452     PARTIAL=true
454 if test "x${ac_cv_header_zlib_h}" '!=' "xyes"; then
455     DISABLEPNG2SWF=true;
456     MISSINGLIBS="${MISSINGLIBS} zlib.h"
457     PARTIAL=true
459 #if test "x${AVIFILE}" '!=' "xtrue" -a "x${AVIFIL32}" '!=' "xtrue"; then
460 #    MISSINGLIBS="${MISSINGLIBS} avifile"
463 AC_MSG_RESULT(${MISSINGLIBS})
465 # ------------------------------------------------------------------
467 if test "x${MISSINGLIBS}" '!=' "x"; then
468   echo "***************************************************"
469   echo "* The following headers/libraries are missing: " ${MISSINGLIBS}
472 avi2swf="avi2swf/Makefile"
473 if test "x${AVIFILE}" '!=' "xtrue" -a "x${AVIFIL32}" '!=' "xtrue"; then
474  #don't whine, avi2swf is outdated anyway
475  #echo "* Disabling avi2swf tool..."
476  echo all install uninstall clean: > avi2swf/Makefile
477  avi2swf=
480 pdf2swf_makefile="lib/pdf/Makefile"
481 PDF2SWF='pdf2swf$(E)'
482 LIBPDF='libpdf$(A)'
484 if test "x${DISABLEPDF2SWF}" = "xtrue"; then
485   echo "* Disabling pdf2swf tool..."
486   rm -f lib/pdf/Makefile
487   echo all install uninstall clean libpdf libgfxpdf: > lib/pdf/Makefile
488   pdf2swf_makefile=""
489   PDF2SWF=
490   LIBPDF=
492 AC_SUBST(PDF2SWF)
493 AC_SUBST(LIBPDF)
495 PDF2PDF='pdf2pdf$(E)'
496 DEVICE_PDF='devices/pdf.$(O)'
497 if test "x${DISABLEPDF2PDF}" = "xtrue"; then
498   #echo "* Disabling pdf2pdf tool..."
499   PDF2PDF=
500   DEVICE_PDF=
502 AC_SUBST(DEVICE_PDF)
503 AC_SUBST(PDF2PDF)
505 if test "x${ZLIBMISSING}" = "xtrue"; then
506   echo
507   echo "* Warning! Without zlib, you will not be able to read"
508   echo "* or write compressed Flash MX files!"
511 JPEG2SWF='jpeg2swf$(E)'
512 if test "x${DISABLEJPEG2SWF}" = "xtrue"; then
513   echo "* Disabling jpeg2swf tool..."
514   JPEG2SWF=
516 export JPEG2SWF
517 AC_SUBST(JPEG2SWF)
519 GIF2SWF='gif2swf$(E)'
520 if test "x${DISABLEGIF2SWF}" = "xtrue"; then
521   echo "* Disabling gif2swf tool..."
522   GIF2SWF=
524 export GIF2SWF
525 AC_SUBST(GIF2SWF)
527 PNG2SWF='png2swf$(E)'
528 if test "x${DISABLEPNG2SWF}" = "xtrue"; then
529   echo "* Disabling png2swf tool..."
530   PNG2SWF=
532 export PNG2SWF
533 AC_SUBST(PNG2SWF)
535 if test "x${MISSINGLIBS}" '!=' "x"; then
536   if test "x${PARTIAL}" '=' "x"; then
537     echo "* (never mind)"
538   fi
539   echo "***************************************************"
542 # ------------------------------------------------------------------
544 AH_TOP([
545 #ifndef __config_h__
546 #define __config_h__
549 AH_BOTTOM([
550 #ifdef HAVE_ZLIB_H
551 #ifdef HAVE_LIBZ
552 #define HAVE_ZLIB
553 #endif
554 #endif
556 #ifdef HAVE_JPEGLIB_H
557 #ifdef HAVE_LIBJPEG
558 #define HAVE_JPEGLIB
559 #endif
560 #endif
562 #ifdef HAVE_FT2BUILD_H
563 #define HAVE_FREETYPE_H 1
564 #endif
566 #ifdef HAVE_GL_GL_H
567 #ifdef HAVE_GL_GLUT_H
568 #ifdef HAVE_OPENGL
569 #define USE_OPENGL
570 #endif
571 #endif
572 #endif
574 #ifdef HAVE_POPPLER
575 #define GString GooString
576 #define GHash GooHash
577 #endif
579 #ifdef HAVE_ZZIP_LIB_H
580 #ifdef HAVE_LIBZZIP
581 #define HAVE_ZZIP 1
582 #endif
583 #endif
585 // supply a substitute calloc function if necessary
586 #ifndef HAVE_CALLOC
587 #define calloc rfx_calloc_replacement
588 #endif
590 #endif // __config_h__
593 if test -f "release.in"; then release_in="./release"; fi
594 if test -f "Makefile.new.in"; then mk_in="./Makefile.new"; fi
595 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"
596 AC_OUTPUT(${FILES})
598 dnl new autoconf
599 dnl AC_CONFIG_FILES([${FILES}])
600 dnl AC_OUTPUT
603 # On development trees, create snapshots of config.status
605 if test -f snapshot -a "x$CHECKMEM" = "x" -a "x$PROFILING" = "x";then
606     if test "x${MINGW}" = "xyes"; then
607         echo cp config.status config.status.win32
608         cp config.status config.status.win32
609     else
610         if test "x$DEBUG" '=' "x" -a "x$OPTIMIZE"  '=' "x";then
611             echo cp config.status config.status.linux
612             cp config.status config.status.linux
613         fi
614         if test "x$DEBUG" '!=' "x" -a "x$OPTIMIZE"  '=' "x";then
615             echo cp config.status config.status.debug
616             cp config.status config.status.debug
617         fi
618         if test "x$DEBUG"    = "x" -a "x$OPTIMIZE" '!=' "x"; then
619             echo cp config.status config.status.optimize
620             cp config.status config.status.optimize
621         fi
622     fi