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