fixed a mem leak
[swftools.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2
3 dnl old autoconf
4 AC_INIT(src/)
5
6 dnl new autoconf
7 dnl AC_INIT
8 dnl AC_CONFIG_SRCDIR([src/])
9
10 # ------------------- option parsing -------------------------------
11
12 DEBUG=
13 CHECKMEM=
14 PROFILING=
15 ENABLE_WARNINGS=
16 OPTIMIZE=
17 DISABLE_LAME=
18
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],
31
32 if test "x$enable_lame" = "xno";then
33     DISABLE_LAME=yes
34 fi,DISABLE_LAME=)
35
36 PACKAGE=swftools
37 VERSION=2009-08-12-1514
38
39 # ------------------------------------------------------------------
40
41 if test "x${srcdir}" != "x."; then
42     echo "--srcdir is not supported"
43     exit 1
44 fi
45
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 "
49 fi
50
51 if test "x$CHECKMEM" '!=' "x";then
52     DEBUG=yes
53 fi
54 if test "x$PROFILING" '!=' "x";then
55     DEBUG=yes
56 fi
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"
73 fi
74 fi
75
76 CFLAGS="-fPIC $CFLAGS"
77 CXXFLAGS="-fPIC $CFLAGS"
78
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
86
87 export PACKAGE VERSION CFLAGS CXXFLAGS
88
89 dnl Checks for programs.
90
91 AC_CANONICAL_HOST
92
93 SHARED="-shared"
94 MACOSX=
95 case $host_os in
96     *darwin* ) 
97         MACOSX=yes
98         CFLAGS="$CFLAGS"
99         CXXFLAGS="$CXXFLAGS -fno-rtti"
100         SHARED="-bundle"
101         if test -d /opt/local/include && test -d /opt/local/lib; then
102             CPPFLAGS="${CPPFLAGS} -I/opt/local/include"
103             LDFLAGS="${LDFLAGS} -L/opt/local/lib"
104         fi
105         # Use fink packages if available.
106         #if test -d /sw/include && test -d /sw/lib; then
107         #    CPPFLAGS="${CPPFLAGS} -I/sw/include"
108         #    LDFLAGS="${LDFLAGS} -L/sw/lib"
109         #fi
110         ;;
111 esac
112
113 AC_SUBST(SHARED)
114
115 dnl Checks for programs.
116  AC_PROG_CC
117  AC_PROG_CXX
118
119
120 RFX_CHECK_OLDGCC
121
122 if test "x$GCC_IS_OK" '=' "x";then
123     echo "***************************************************"
124     echo "* Your gcc is too old to compile this!"
125     echo "* "
126     echo "* The last version compileable by this compiler is "
127     echo "* swftools 0.7.0, which you can download from "
128     echo "* http://www.swftools.org/swftools-0.7.0.tar.gz "
129     echo "* ."
130     echo "* Newer versions require at least gcc 3.0.0 "
131     echo "***************************************************"
132     exit 1
133 fi
134     
135 if test "x$CHECKMEM" '!=' "x";then
136     CC="ccmalloc $CC"
137     CXX="ccmalloc $CXX"
138     #echo running again
139     #unset ac_cv_prog_CC
140     #unset ac_cv_prog_CXX
141     #AC_PROG_CC
142     #AC_PROG_CXX
143 fi
144  AC_PROG_CPP
145
146  AC_PROG_RANLIB
147  AC_PROG_MAKE_SET
148  AC_PROG_INSTALL
149  AC_PROG_LN_S
150  AC_CHECK_PROGS(UNCOMPRESS, gzip uncompress compress, )
151
152 dnl PKG_PROG_PKG_CONFIG
153
154 dnl Checks for system services
155 OBJEXT="o"
156 AREXT=".a"
157 CXXLIBS="-lstdc++"
158
159 AC_EXEEXT
160
161 if test "x$EXEEXT" = "x.exe";then
162     OBJEXT="obj"
163     AREXT=".lib"
164     CXXLIBS=""
165 fi
166 AC_SUBST(OBJEXT)
167 AC_SUBST(AREXT)
168
169 RFX_CHECK_MING
170
171 SLEXT="so"
172 if test "x${MINGW}" != "xyes"; then
173     # no mingW
174     AC_DEFINE([O_BINARY], [0], [Not defined on mingw])
175 else
176     # mingW
177     SLEXT="dll"
178     CXXLIBS=""
179 fi
180 export SLEXT
181 AC_SUBST(SLEXT)
182 AC_SUBST(CXXLIBS)
183
184 # The following tries to make use of includes and libraries in
185 # /usr/local, too. Notice: A -I/usr/local/include might break
186 # things (MingW, cross-compiling etc.) in the same way as -I/usr/include, 
187 # especially on systems which link /usr/local to /usr, so it has yet
188 # to be seen how useful this is.
189 if test -d /usr/local/lib; then
190     LDFLAGS="$LDFLAGS -L/usr/local/lib"
191 fi
192 if test -d /usr/local/include; then
193 # Leave that alone. It's causing trouble e.g. with gcc 3.2 on gentoo.
194 #   CPPFLAGS="$CPPFLAGS -I/usr/local/include"
195     echo > /dev/null
196 fi
197 if test "$prefix" != "NONE" -a "$prefix" != "/usr/local" -a "$prefix" != "/usr/local/"; then
198     # if the user has a special prefix (like /opt), there might also be $prefix/lib
199     # and $prefix/include, which should be included in our search paths for libraries
200     # and includes.
201     LDFLAGS="$LDFLAGS -L${libdir}"
202     CPPFLAGS="$CPPFLAGS -I${includedir}"
203     # TODO- test whether gcc still works after this
204 fi
205
206 #Mac OS:
207 #LDFLAGS "-L/sw/lib" ; CPPFLAGS "-I/sw/include -I/sw/include/lame"
208
209
210 # this must be done after (I believe) AC_PROG_MAKE_SET
211 if test "x$DEBUG" '!=' "x" -o "x$STRIP" = "x";then
212     if test "$MACOSX";then
213         STRIP=dsymutil
214     else
215         STRIP="@echo debug enabled, not stripping "
216     fi
217     export STRIP
218     AC_SUBST(STRIP)
219 fi
220
221 dnl Checks for libraries.
222  AC_CHECK_LIB(m, sin,, 
223  echo "Error: Math library not found.";
224  exit;
225  )
226  AC_CHECK_LIB(z, deflate,, ZLIBMISSING=true)
227
228 if test "x$ZLIBMISSING" = "xtrue";then
229     echo 
230     echo "ERROR:"
231     echo "You need zlib to compile swftools"
232     echo
233     exit
234 fi
235
236 AC_CHECK_LIB(pdf, PDF_open_file,, PDFLIBMISSING=true)
237 AC_CHECK_LIB(jpeg, jpeg_write_raw_data,, JPEGLIBMISSING=true)
238 AC_CHECK_LIB(ungif, DGifOpen,, UNGIFMISSING=true)
239 if test "$UNGIFMISSING";then
240     UNGIFMISSING=
241     AC_CHECK_LIB(gif, DGifOpen,, UNGIFMISSING=true)
242 fi
243 AC_CHECK_LIB(zzip, zzip_file_open,, ZZIPMISSING=true)
244
245 RFX_CHECK_BYTEORDER
246 AC_SUBST(WORDS_BIGENDIAN)
247 RFX_CHECK_SYSTEM_BACKTICKS
248 AC_SUBST(SYSTEM_BACKTICKS)
249
250 AC_ARG_PROGRAM
251
252 dnl Checks for header files.
253  AC_CONFIG_HEADER(config.h)
254  AC_HEADER_DIRENT
255  AC_HEADER_STDC
256
257  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)
258
259 AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
260 AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])
261 AC_SUBST(PACKAGE)
262 AC_SUBST(VERSION)
263
264 AC_SUBST(HAVE_UNISTD_H)
265 AC_SUBST(EXEEXT)
266
267 dnl Checks for typedefs, structures, and compiler characteristics.
268  AC_C_CONST
269  AC_C_INLINE
270  AC_TYPE_OFF_T
271  AC_TYPE_SIZE_T
272  AC_STRUCT_TM
273  AC_CHECK_TYPE(boolean,int) #needed for jpeglib
274  AC_CHECK_FUNCS(popen wcschr wcsdup mkstemp stat mmap lrand48 rand srand48 srand bcopy bzero time getrusage mallinfo)
275
276 AC_CHECK_SIZEOF([signed char])
277 AC_CHECK_SIZEOF([signed short])
278 AC_CHECK_SIZEOF([signed])
279 AC_CHECK_SIZEOF([signed long long])
280 AC_CHECK_SIZEOF([void*])
281
282 RFX_CHECK_FREETYPE
283
284 RFX_CHECK_FONTCONFIG
285
286 RFX_CHECK_FFTW
287
288 # RFX_CHECK_OPENGL
289 # if test "$HAVE_OPENGL";then
290 #     DEVICE_OPENGL='devices/opengl.$(O)'
291 #     AC_SUBST(DEVICE_OPENGL)
292 # fi
293 AC_SUBST(DEVICE_OPENGL)
294
295 lame_in_source= 
296 lame_makefile=
297 if test "x${DISABLE_LAME}" = "xtrue"; then
298     echo "*" Disabling lame support...
299 else
300     # old lame code at lib/lame
301     if test -f lib/lame/Makefile.in; then
302         lame_in_source='$(lame_objects)'
303         lame_makefile="lib/lame/Makefile"
304         CPPFLAGS="$CPPFLAGS -Ilame -Ilib/lame"
305         AC_DEFINE([HAVE_LAME], [1], [have/use internal l.a.m.e. mp3 library])
306     else
307         if test -d /usr/include/lame; then
308             CPPFLAGS="$CPPFLAGS -I /usr/include/lame"
309         else
310             if test -d /usr/local/include/lame; then
311                 CPPFLAGS="$CPPFLAGS -I /usr/local/include/lame"
312             fi
313         fi
314         AC_CHECK_LIB(mp3lame, lame_init,, NO_LIBMP3LAME=1)
315         HASLAMEHEADER=
316         AC_CHECK_HEADERS(lame.h,HASLAMEHEADER=1)
317         if test "x$NO_LIBMP3LAME" "!=" "x1" -a "x$HASLAMEHEADER" '!=' "x";then
318             AC_DEFINE([HAVE_LAME], [1])
319         fi
320     fi
321 fi
322 AC_SUBST(lame_in_source)
323
324 splash_in_source='$(splash_objects)'
325 xpdf_in_source='$(xpdf_objects)'
326
327 dnl if test "x$USE_POPPLER" = "xtrue"; then
328 dnl     xpdf_in_source=
329 dnl     splash_in_source=
330 dnl     AC_DEFINE([HAVE_POPPLER],[1],[use poppler])
331 dnl     PKG_CHECK_MODULES([POPPLER],[poppler poppler-splash],,[poppler_pkgconfig=no])
332 dnl     if test "x$poppler_pkgconfig" = "xno"; then
333 dnl         AC_LANG_PUSH([C++])
334 dnl         AC_CHECK_HEADERS([OutputDev.h],[
335 dnl            AC_CHECK_LIB([poppler],[main],,[])
336 dnl         ],[AC_MSG_ERROR([No poppler library found. This library is required.])])
337 dnl         AC_LANG_POP
338 dnl     else
339 dnl     CPPFLAGS="$CPPFLAGS $POPPLER_CFLAGS"
340 dnl         AC_DEFINE([HAVE_POPPLER], [1])
341 dnl         LIBS="$LIBS $POPPLER_LIBS"
342 dnl     fi
343 dnl fi
344
345 AC_SUBST([xpdf_in_source])
346 AC_SUBST([splash_in_source])
347
348 # ------------------------------------------------------------------
349
350 RFX_CHECK_LOWERCASE_UPPERCASE
351 RFX_CHECK_AVI2SWF
352 if test "x${AVIFILE}" = "xtrue"; then
353     VIDEO_LIBS="$VIDEO_LIBS $AVIFILE_LIBS"
354     VIDEO_CFLAGS="$VIDEO_CFLAGS $AVIFILE_CFLAGS"
355     AC_DEFINE([HAVE_AVIFILE], [1], [Define if avifile is present])
356 fi
357
358 if test "x${WIN32}" != "x"; then
359     #AC_CHECK_LIB(avifil32, AVIFileInit,AVIFIL32=true)
360     #if test "x${AVIFIL32}" != "x"; then
361     #  VIDEO_LIBS="$VIDEO_LIBS -lavifil32"
362     #fi
363     VIDEO_LIBS="$VIDEO_LIBS -lavifil32"
364     AVIFIL32=true
365 fi
366
367 AC_SUBST(VIDEO_LIBS)
368 AC_SUBST(VIDEO_CFLAGS)
369 # ------------------------------------------------------------------
370
371 if test "x${UNCOMPRESS}" = "xgzip"; then
372     AC_DEFINE([USE_GZIP], [1], [Define if gzip is present])
373 fi
374 AC_SUBST(USE_GZIP)
375
376 # ------------------------------------------------------------------
377
378 RFX_CHECK_PYTHON
379
380 if test "x$PYTHON_OK" '!=' "xyes";then
381     echo all install uninstall clean: > lib/python/Makefile
382     # fail silently- the most users won't have any need for the
383     # python interface anyway
384 else
385     pythonrfxswf="lib/python/Makefile"
386 fi
387
388 # ------------------------------------------------------------------
389
390 AC_MSG_CHECKING([for missing libraries])
391
392 if test "x$ZLIBMISSING" = "xtrue";then
393     MISSINGLIBS="${MISSINGLIBS} zlib"
394     DISABLEPNG2SWF=true
395     PARTIAL=true
396 fi
397 if test "x$JPEGLIBMISSING" = "xtrue";then
398     MISSINGLIBS="${MISSINGLIBS} jpeglib"
399     DISABLEPDF2SWF=true
400     DISABLEJPEG2SWF=true
401     PARTIAL=true
402 fi
403 if test "x$PDFLIBMISSING" = "xtrue";then
404     DISABLEPDF2PDF=true;
405 fi
406 #if test "x$T1LIBMISSING" = "xtrue";then
407 #    MISSINGLIBS="${MISSINGLIBS} t1lib"
408 #fi
409 if test "x$UNGIFMISSING" = "xtrue";then
410     DISABLEGIF2SWF=true
411     MISSINGLIBS="${MISSINGLIBS} ungif"
412     PARTIAL=true
413 fi
414
415 if test "x${ac_cv_header_pdflib_h}" '!=' "xyes";then
416     DISABLEPDF2PDF=true;
417 fi
418 if test "x${ac_cv_header_jpeglib_h}" '!=' "xyes"; then
419     DISABLEPDF2SWF=true;
420     DISABLEJPEG2SWF=true;
421     MISSINGLIBS="${MISSINGLIBS} jpeglib.h"
422     PARTIAL=true
423 fi
424 if test "x$HAVE_FREETYPE" '!=' "x1"; then
425     DISABLEPDF2SWF=true;
426     MISSINGLIBS="${MISSINGLIBS} freetype"
427     PARTIAL=true
428 fi
429 #if test "x${ac_cv_header_t1lib_h}" '!=' "xyes"; then
430 #    MISSINGLIBS="${MISSINGLIBS} t1lib.h"
431 #fi
432 if test "x${ac_cv_header_gif_lib_h}" '!=' "xyes"; then
433     DISABLEGIF2SWF=true
434     MISSINGLIBS="${MISSINGLIBS} gif_lib.h"
435     PARTIAL=true
436 fi
437 if test "x${ac_cv_header_zlib_h}" '!=' "xyes"; then
438     DISABLEPNG2SWF=true;
439     MISSINGLIBS="${MISSINGLIBS} zlib.h"
440     PARTIAL=true
441 fi
442 #if test "x${AVIFILE}" '!=' "xtrue" -a "x${AVIFIL32}" '!=' "xtrue"; then
443 #    MISSINGLIBS="${MISSINGLIBS} avifile"
444 #fi
445
446 AC_MSG_RESULT(${MISSINGLIBS})
447
448 # ------------------------------------------------------------------
449
450 if test "x${MISSINGLIBS}" '!=' "x"; then
451   echo "***************************************************"
452   echo "* The following headers/libraries are missing: " ${MISSINGLIBS}
453 fi
454
455 avi2swf="avi2swf/Makefile"
456 if test "x${AVIFILE}" '!=' "xtrue" -a "x${AVIFIL32}" '!=' "xtrue"; then
457  #don't whine, avi2swf is outdated anyway
458  #echo "* Disabling avi2swf tool..."
459  echo all install uninstall clean: > avi2swf/Makefile
460  avi2swf=
461 fi
462
463 pdf2swf_makefile="lib/pdf/Makefile"
464 PDF2SWF='pdf2swf$(E)'
465 LIBPDF='libpdf$(A)'
466
467 if test "x${DISABLEPDF2SWF}" = "xtrue"; then
468   echo "* Disabling pdf2swf tool..."
469   rm -f lib/pdf/Makefile
470   echo all install uninstall clean libpdf libgfxpdf: > lib/pdf/Makefile
471   pdf2swf_makefile=""
472   PDF2SWF=
473   LIBPDF=
474 fi
475 AC_SUBST(PDF2SWF)
476 AC_SUBST(LIBPDF)
477
478 PDF2PDF='pdf2pdf$(E)'
479 DEVICE_PDF='devices/pdf.$(O)'
480 if test "x${DISABLEPDF2PDF}" = "xtrue"; then
481   #echo "* Disabling pdf2pdf tool..."
482   PDF2PDF=
483   DEVICE_PDF=
484 fi
485 AC_SUBST(DEVICE_PDF)
486 AC_SUBST(PDF2PDF)
487
488 if test "x${ZLIBMISSING}" = "xtrue"; then
489   echo
490   echo "* Warning! Without zlib, you will not be able to read"
491   echo "* or write compressed Flash MX files!"
492 fi
493
494 JPEG2SWF='jpeg2swf$(E)'
495 if test "x${DISABLEJPEG2SWF}" = "xtrue"; then
496   echo "* Disabling jpeg2swf tool..."
497   JPEG2SWF=
498 fi
499 export JPEG2SWF
500 AC_SUBST(JPEG2SWF)
501
502 GIF2SWF='gif2swf$(E)'
503 if test "x${DISABLEGIF2SWF}" = "xtrue"; then
504   echo "* Disabling gif2swf tool..."
505   GIF2SWF=
506 fi
507 export GIF2SWF
508 AC_SUBST(GIF2SWF)
509
510 PNG2SWF='png2swf$(E)'
511 if test "x${DISABLEPNG2SWF}" = "xtrue"; then
512   echo "* Disabling png2swf tool..."
513   PNG2SWF=
514 fi
515 export PNG2SWF
516 AC_SUBST(PNG2SWF)
517
518 if test "x${MISSINGLIBS}" '!=' "x"; then
519   if test "x${PARTIAL}" '=' "x"; then
520     echo "* (never mind)"
521   fi
522   echo "***************************************************"
523 fi
524
525 # ------------------------------------------------------------------
526
527 AH_TOP([
528 #ifndef __config_h__
529 #define __config_h__
530 ])
531
532 AH_BOTTOM([
533 #ifdef HAVE_ZLIB_H
534 #ifdef HAVE_LIBZ
535 #define HAVE_ZLIB
536 #endif
537 #endif
538
539 #ifdef HAVE_JPEGLIB_H
540 #ifdef HAVE_LIBJPEG
541 #define HAVE_JPEGLIB
542 #endif
543 #endif
544
545 #ifdef HAVE_FT2BUILD_H
546 #define HAVE_FREETYPE_H 1
547 #endif
548
549 #ifdef HAVE_GL_GL_H
550 #ifdef HAVE_GL_GLUT_H
551 #ifdef HAVE_OPENGL
552 #define USE_OPENGL
553 #endif
554 #endif
555 #endif
556
557 #ifdef HAVE_POPPLER
558 #define GString GooString
559 #define GHash GooHash
560 #endif
561
562 #ifdef HAVE_ZZIP_LIB_H
563 #ifdef HAVE_LIBZZIP
564 #define HAVE_ZZIP 1
565 #endif
566 #endif
567
568
569 #endif // __config_h__
570 ])
571
572 if test -f "release.in"; then release_in="./release"; fi
573 if test -f "Makefile.new.in"; then mk_in="./Makefile.new"; fi
574 FILES="$release_in $mk_in Makefile.common ${avi2swf} Makefile lib/Makefile lib/action/Makefile src/Makefile ${pdf2swf_makefile} swfs/Makefile ${pythonrfxswf} ${lame_makefile} lib/art/Makefile lib/readers/Makefile"
575 AC_OUTPUT(${FILES})
576
577 dnl new autoconf
578 dnl AC_CONFIG_FILES([${FILES}])
579 dnl AC_OUTPUT
580
581 #
582 # On development trees, create snapshots of config.status
583 #
584 if test -f snapshot -a "x$CHECKMEM" = "x" -a "x$PROFILING" = "x";then
585     if test "x${MINGW}" = "xyes"; then
586         echo cp config.status config.status.win32
587         cp config.status config.status.win32
588     else
589         if test "x$DEBUG" '=' "x" -a "x$OPTIMIZE"  '=' "x";then
590             echo cp config.status config.status.linux
591             cp config.status config.status.linux
592         fi
593         if test "x$DEBUG" '!=' "x" -a "x$OPTIMIZE"  '=' "x";then
594             echo cp config.status config.status.debug
595             cp config.status config.status.debug
596         fi
597         if test "x$DEBUG"    = "x" -a "x$OPTIMIZE" '!=' "x"; then
598             echo cp config.status config.status.optimize
599             cp config.status config.status.optimize
600         fi
601     fi
602 fi