added void,typeof,undefined keywords
[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         AC_CHECK_HEADERS(lame.h)
295         if test "x$NO_LIBMP3LAME" "!=" "x1" -a "x$ac_cv_header_lame_h" "!=" "x";then
296             AC_DEFINE([HAVE_LAME], [1])
297         fi
298     fi
299 fi
300 AC_SUBST(lame_in_source)
301
302 art_in_source='$(art_objects)'
303 AC_DEFINE([INTERNAL_LIBART], [1], [use internal libart library])
304
305 if test "x$EXTERNAL_LIBART" = "xtrue"; then
306     art_in_source=
307     PKG_CHECK_MODULES([LIBART],[libart-2.0],,[libart_pkgconfig_libart=no])
308     if test "x$libart_pkgconfig_libart" = "xno"; then
309         AC_CHECK_HEADERS([libart_lgpl/libart.h],[
310            AC_CHECK_LIB([art_lgpl_2],[art_new],,[])
311         ],[AC_MSG_ERROR([No libart library found. This library is required.])])
312     else
313         CPPFLAGS="$CPPFLAGS $LIBART_CFLAGS"
314         AC_DEFINE([INTERNAL_LIBART], [0])
315         LIBS="$LIBS $LIBART_LIBS"
316     fi
317 fi
318 AC_SUBST([art_in_source])
319
320 xpdf_in_source='$(xpdf_objects)'
321 splash_in_source='$(splash_objects)'
322
323 if test "x$USE_POPPLER" = "xtrue"; then
324     xpdf_in_source=
325     splash_in_source=
326     AC_DEFINE([HAVE_POPPLER],[1],[use poppler])
327     PKG_CHECK_MODULES([POPPLER],[poppler poppler-splash],,[poppler_pkgconfig=no])
328     if test "x$poppler_pkgconfig" = "xno"; then
329         AC_LANG_PUSH([C++])
330         AC_CHECK_HEADERS([OutputDev.h],[
331            AC_CHECK_LIB([poppler],[main],,[])
332         ],[AC_MSG_ERROR([No poppler library found. This library is required.])])
333         AC_LANG_POP
334     else
335         CPPFLAGS="$CPPFLAGS $POPPLER_CFLAGS"
336         AC_DEFINE([HAVE_POPPLER], [1])
337         LIBS="$LIBS $POPPLER_LIBS"
338     fi
339 fi
340 AC_SUBST([xpdf_in_source])
341 AC_SUBST([splash_in_source])
342
343 # ------------------------------------------------------------------
344  
345 RFX_CHECK_AVI2SWF
346 if test "x${AVIFILE}" = "xtrue"; then
347     VIDEO_LIBS="$VIDEO_LIBS $AVIFILE_LIBS"
348     VIDEO_CFLAGS="$VIDEO_CFLAGS $AVIFILE_CFLAGS"
349     AC_DEFINE([HAVE_AVIFILE], [1], [Define if avifile is present])
350 fi
351
352 if test "x${WIN32}" != "x"; then
353     #AC_CHECK_LIB(avifil32, AVIFileInit,AVIFIL32=true)
354     #if test "x${AVIFIL32}" != "x"; then
355     #  VIDEO_LIBS="$VIDEO_LIBS -lavifil32"
356     #fi
357     VIDEO_LIBS="$VIDEO_LIBS -lavifil32"
358     AVIFIL32=true
359 fi
360
361 AC_SUBST(VIDEO_LIBS)
362 AC_SUBST(VIDEO_CFLAGS)
363 # ------------------------------------------------------------------
364
365 if test "x${UNCOMPRESS}" = "xgzip"; then
366     AC_DEFINE([USE_GZIP], [1], [Define if gzip is present])
367 fi
368 AC_SUBST(USE_GZIP)
369
370 # ------------------------------------------------------------------
371
372 RFX_CHECK_PYTHON
373
374 if test "x$PYTHON_OK" '!=' "xyes";then
375     echo all install uninstall clean: > lib/python/Makefile
376     # fail silently- the most users won't have any need for the
377     # python interface anyway
378 else
379     pythonrfxswf="lib/python/Makefile"
380 fi
381
382 # ------------------------------------------------------------------
383
384 AC_MSG_CHECKING([for missing libraries])
385
386 if test "x$ZLIBMISSING" = "xtrue";then
387     MISSINGLIBS="${MISSINGLIBS} zlib"
388     DISABLEPNG2SWF=true
389     PARTIAL=true
390 fi
391 if test "x$JPEGLIBMISSING" = "xtrue";then
392     MISSINGLIBS="${MISSINGLIBS} jpeglib"
393     DISABLEPDF2SWF=true
394     DISABLEJPEG2SWF=true
395     PARTIAL=true
396 fi
397 #if test "x$T1LIBMISSING" = "xtrue";then
398 #    MISSINGLIBS="${MISSINGLIBS} t1lib"
399 #fi
400 if test "x$UNGIFMISSING" = "xtrue";then
401     DISABLEGIF2SWF=true
402     MISSINGLIBS="${MISSINGLIBS} ungif"
403     PARTIAL=true
404 fi
405
406 if test "x${ac_cv_header_jpeglib_h}" '!=' "xyes"; then
407     DISABLEPDF2SWF=true;
408     DISABLEJPEG2SWF=true;
409     MISSINGLIBS="${MISSINGLIBS} jpeglib.h"
410     PARTIAL=true
411 fi
412 if test "x$HAVE_FREETYPE" '!=' "x1"; then
413     DISABLEPDF2SWF=true;
414     MISSINGLIBS="${MISSINGLIBS} freetype"
415     PARTIAL=true
416 fi
417 #if test "x${ac_cv_header_t1lib_h}" '!=' "xyes"; then
418 #    MISSINGLIBS="${MISSINGLIBS} t1lib.h"
419 #fi
420 if test "x${ac_cv_header_gif_lib_h}" '!=' "xyes"; then
421     DISABLEGIF2SWF=true
422     MISSINGLIBS="${MISSINGLIBS} gif_lib.h"
423     PARTIAL=true
424 fi
425 if test "x${ac_cv_header_zlib_h}" '!=' "xyes"; then
426     DISABLEPNG2SWF=true;
427     MISSINGLIBS="${MISSINGLIBS} zlib.h"
428     PARTIAL=true
429 fi
430 #if test "x${AVIFILE}" '!=' "xtrue" -a "x${AVIFIL32}" '!=' "xtrue"; then
431 #    MISSINGLIBS="${MISSINGLIBS} avifile"
432 #fi
433
434 AC_MSG_RESULT(${MISSINGLIBS})
435
436 # ------------------------------------------------------------------
437
438 if test "x${MISSINGLIBS}" '!=' "x"; then
439   echo "***************************************************"
440   echo "* The following headers/libraries are missing: " ${MISSINGLIBS}
441 fi
442
443 avi2swf="avi2swf/Makefile"
444 if test "x${AVIFILE}" '!=' "xtrue" -a "x${AVIFIL32}" '!=' "xtrue"; then
445  #don't whine, avi2swf is outdated anyway
446  #echo "* Disabling avi2swf tool..."
447  echo all install uninstall clean: > avi2swf/Makefile
448  avi2swf=
449 fi
450
451 pdf2swf_makefile="lib/pdf/Makefile"
452 PDF2SWF='pdf2swf$(E)'
453 LIBPDF='libpdf$(A)'
454
455 if test "x${DISABLEPDF2SWF}" = "xtrue"; then
456   echo "* Disabling pdf2swf tool..."
457   rm -f lib/pdf/Makefile
458   echo all install uninstall clean libpdf: > lib/pdf/Makefile
459   pdf2swf_makefile=""
460   PDF2SWF=
461   LIBPDF=
462 fi
463 AC_SUBST(PDF2SWF)
464 AC_SUBST(LIBPDF)
465
466 if test "x${ZLIBMISSING}" = "xtrue"; then
467   echo
468   echo "* Warning! Without zlib, you will not be able to read"
469   echo "* or write compressed Flash MX files!"
470 fi
471
472 JPEG2SWF='jpeg2swf$(E)'
473 if test "x${DISABLEJPEG2SWF}" = "xtrue"; then
474   echo "* Disabling jpeg2swf tool..."
475   JPEG2SWF=
476 fi
477 export JPEG2SWF
478 AC_SUBST(JPEG2SWF)
479
480 GIF2SWF='gif2swf$(E)'
481 if test "x${DISABLEGIF2SWF}" = "xtrue"; then
482   echo "* Disabling gif2swf tool..."
483   GIF2SWF=
484 fi
485 export GIF2SWF
486 AC_SUBST(GIF2SWF)
487
488 PNG2SWF='png2swf$(E)'
489 if test "x${DISABLEPNG2SWF}" = "xtrue"; then
490   echo "* Disabling png2swf tool..."
491   PNG2SWF=
492 fi
493 export PNG2SWF
494 AC_SUBST(PNG2SWF)
495
496 if test "x${MISSINGLIBS}" '!=' "x"; then
497   if test "x${PARTIAL}" '=' "x"; then
498     echo "* (never mind)"
499   fi
500   echo "***************************************************"
501 fi
502
503 # ------------------------------------------------------------------
504
505 AH_TOP([
506 #ifndef __config_h__
507 #define __config_h__
508 ])
509
510 AH_BOTTOM([
511 #ifdef HAVE_ZLIB_H
512 #ifdef HAVE_LIBZ
513 #define HAVE_ZLIB
514 #endif
515 #endif
516
517 #ifdef HAVE_JPEGLIB_H
518 #ifdef HAVE_LIBJPEG
519 #define HAVE_JPEGLIB
520 #endif
521 #endif
522
523 #ifdef HAVE_FT2BUILD_H
524 #define HAVE_FREETYPE_H 1
525 #endif
526
527 #ifdef HAVE_GL_GL_H
528 #ifdef HAVE_GL_GLUT_H
529 #ifdef HAVE_OPENGL
530 #define USE_OPENGL
531 #endif
532 #endif
533 #endif
534
535 #ifdef HAVE_POPPLER
536 #define GString GooString
537 #define GHash GooHash
538 #endif
539
540 #endif // __config_h__
541 ])
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 pdf2swf/fonts/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