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