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