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