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