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