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