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