added some comments.
[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-13-2026
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  AC_EXEEXT
111 if test "x$EXEEXT" = "x.exe";then
112     OBJEXT="obj"
113 fi
114 AC_SUBST(OBJEXT)
115
116 RFX_CHECK_MING
117
118 SLEXT="so"
119 if test "x${MINGW}" != "xyes"; then
120     # no mingW
121     AC_DEFINE_UNQUOTED(O_BINARY, 0)
122 else
123     # mingW
124     SLEXT="dll"
125 fi
126 export SLEXT
127 AC_SUBST(SLEXT)
128
129 # The following tries to make use of includes and libraries in
130 # /usr/local, too. Notice: A -I/usr/local/include might break
131 # things (MingW, cross-compiling etc.) in the same way as -I/usr/include, 
132 # especially on systems which link /usr/local to /usr, so it has yet
133 # to be seen how useful this is.
134 if test -d /usr/local/lib; then
135     LDFLAGS="$LDFLAGS -L/usr/local/lib"
136 fi
137 if test -d /usr/local/include; then
138 # Leave that alone. It's causing trouble e.g. with gcc 3.2 on gentoo.
139 #   CPPFLAGS="$CPPFLAGS -I/usr/local/include"
140     echo > /dev/null
141 fi
142 if test "$prefix" != "NONE" -a "$prefix" != "/usr/local" -a "$prefix" != "/usr/local/"; then
143     # if the user has a special prefix (like /opt), there might also be $prefix/lib
144     # and $prefix/include, which should be included in our search paths for libraries
145     # and includes.
146     LDFLAGS="$LDFLAGS -L${libdir}"
147     CPPFLAGS="$CPPFLAGS -I${includedir}"
148     # TODO- test whether gcc still works after this
149 fi
150
151 # this must be done after (I believe) AC_PROG_MAKE_SET
152 if test "x$DEBUG" '!=' "x";then
153     STRIP="@echo debug enabled, not stripping "
154     export STRIP
155     AC_SUBST(STRIP)
156 fi
157
158 dnl Checks for libraries.
159  AC_CHECK_LIB(m, sin,, 
160  echo "Error: Math library not found.";
161  exit;
162  )
163  AC_CHECK_LIB(z, deflate,, ZLIBMISSING=true)
164  AC_CHECK_LIB(jpeg, jpeg_write_raw_data,, JPEGLIBMISSING=true)
165  AC_CHECK_LIB(t1, T1_LoadFont,, T1LIBMISSING=true)
166
167 RFX_CHECK_BYTEORDER
168 AC_SUBST(WORDS_BIGENDIAN)
169 RFX_CHECK_SYSTEM_BACKTICKS
170 AC_SUBST(SYSTEM_BACKTICKS)
171
172 AC_ARG_PROGRAM
173
174 dnl Checks for header files.
175  AC_CONFIG_HEADER(config.h)
176  AC_HEADER_DIRENT
177  AC_HEADER_STDC
178  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)
179
180 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
181 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
182 AC_SUBST(PACKAGE)
183 AC_SUBST(VERSION)
184
185 AC_SUBST(HAVE_UNISTD_H)
186 AC_SUBST(EXEEXT)
187
188 dnl Checks for typedefs, structures, and compiler characteristics.
189  AC_C_CONST
190  AC_C_INLINE
191  AC_TYPE_OFF_T
192  AC_TYPE_SIZE_T
193  AC_STRUCT_TM
194  AC_CHECK_TYPE(boolean,int) #needed for jpeglib
195  dnl AC_CHECK_TYPE(bool,char)
196  dnl AC_CHECK_TYPE(uchar,unsigned char)
197  dnl AC_CHECK_TYPE(schar,signed char)
198  dnl AC_CHECK_TYPE(word,unsigned short int)
199  dnl AC_CHECK_TYPE(sword,unsigned short int)
200  dnl AC_CHECK_TYPE(uint,unsigned long int)
201
202 dnl Checks for library functions.
203  AC_CHECK_FUNCS(popen mkstemp stat lrand48 rand srand48 srand bcopy bzero time)
204
205 # ------------------------------------------------------------------
206
207 RFX_CHECK_FREETYPE
208
209 RFX_CHECK_FONTCONFIG
210
211 # ------------------------------------------------------------------
212  
213 lame_objects= 
214 lame_makefile=
215 if test "x${DISABLE_LAME}" = "xtrue"; then
216     echo "*" Disabling lame support...
217 else
218     # old lame code at lib/lame
219     if test -f lib/lame/Makefile.in; then
220         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)"
221         lame_makefile="lib/lame/Makefile"
222         CPPFLAGS="$CPPFLAGS -Ilame"
223         AC_DEFINE_UNQUOTED(HAVE_LAME, 1)
224     else
225         if test -d /usr/include/lame; then
226             CPPFLAGS="$CPPFLAGS -I /usr/include/lame"
227         else
228             if test -d /usr/local/include/lame; then
229                 CPPFLAGS="$CPPFLAGS -I /usr/local/include/lame"
230             fi
231         fi
232         AC_CHECK_LIB(mp3lame, lame_init,, NO_LIBMP3LAME=1)
233         AC_CHECK_HEADERS(lame.h)
234         if test "x$NO_LIBMP3LAME" "!=" "x1" -a "x$ac_cv_header_lame_h" "!=" "x";then
235             AC_DEFINE_UNQUOTED(HAVE_LAME, 1)
236         fi
237     fi
238 fi
239 AC_SUBST(lame_objects)
240
241 # ------------------------------------------------------------------
242  
243 RFX_CHECK_AVI2SWF
244 if test "x${AVIFILE}" = "xtrue"; then
245     VIDEO_LIBS="$VIDEO_LIBS $AVIFILE_LIBS"
246     VIDEO_CFLAGS="$VIDEO_CFLAGS $AVIFILE_CFLAGS"
247     AC_DEFINE_UNQUOTED(HAVE_AVIFILE, 1)
248 fi
249
250 if test "x${WIN32}" != "x"; then
251     #AC_CHECK_LIB(avifil32, AVIFileInit,AVIFIL32=true)
252     #if test "x${AVIFIL32}" != "x"; then
253     #  VIDEO_LIBS="$VIDEO_LIBS -lavifil32"
254     #fi
255     VIDEO_LIBS="$VIDEO_LIBS -lavifil32"
256     AVIFIL32=true
257 fi
258
259 AC_SUBST(VIDEO_LIBS)
260 AC_SUBST(VIDEO_CFLAGS)
261 # ------------------------------------------------------------------
262
263 if test "x${UNCOMPRESS}" = "xgzip"; then
264     AC_DEFINE_UNQUOTED(USE_GZIP, 1)
265 fi
266 AC_SUBST(USE_GZIP)
267
268 # ------------------------------------------------------------------
269
270 RFX_CHECK_PYTHON
271
272 if test "x$PYTHON_OK" '!=' "xyes";then
273     echo all install uninstall clean: > lib/python/Makefile
274     # fail silently- the most users won't have any need for the
275     # python interface anyway
276 else
277     pythonrfxswf="lib/python/Makefile"
278 fi
279
280 # ------------------------------------------------------------------
281
282 AC_MSG_CHECKING([for missing libraries])
283
284 if test "x$ZLIBMISSING" = "xtrue";then
285     MISSINGLIBS="${MISSINGLIBS} zlib"
286     DISABLEPNG2SWF=true
287     PARTIAL=true
288 fi
289 if test "x$JPEGLIBMISSING" = "xtrue";then
290     MISSINGLIBS="${MISSINGLIBS} jpeglib"
291     DISABLEPDF2SWF=true
292     DISABLEJPEG2SWF=true
293     PARTIAL=true
294 fi
295 if test "x$T1LIBMISSING" = "xtrue";then
296     MISSINGLIBS="${MISSINGLIBS} t1lib"
297 fi
298
299 if test "x${ac_cv_header_jpeglib_h}" '!=' "xyes"; then
300     DISABLEPDF2SWF=true;
301     DISABLEJPEG2SWF=true;
302     MISSINGLIBS="${MISSINGLIBS} jpeglib.h"
303     PARTIAL=true
304 fi
305 if test "x$HAVE_FREETYPE" '!=' "x1"; then
306     DISABLEPDF2SWF=true;
307     MISSINGLIBS="${MISSINGLIBS} freetype"
308     PARTIAL=true
309 fi
310 if test "x${ac_cv_header_t1lib_h}" '!=' "xyes"; then
311     MISSINGLIBS="${MISSINGLIBS} t1lib.h"
312 fi
313 if test "x${ac_cv_header_zlib_h}" '!=' "xyes"; then
314     DISABLEPNG2SWF=true;
315     MISSINGLIBS="${MISSINGLIBS} zlib.h"
316     PARTIAL=true
317 fi
318 if test "x${AVIFILE}" '!=' "xtrue" -a "x${AVIFIL32}" '!=' "xtrue"; then
319     MISSINGLIBS="${MISSINGLIBS} avifile"
320     PARTIAL=true
321 fi
322
323 AC_MSG_RESULT(${MISSINGLIBS})
324
325 # ------------------------------------------------------------------
326
327 if test "x${MISSINGLIBS}" '!=' "x"; then
328   echo "***************************************************"
329   echo "* The following headers/libraries are missing: " ${MISSINGLIBS}
330 fi
331
332 avi2swf="avi2swf/Makefile"
333 if test "x${AVIFILE}" '!=' "xtrue" -a "x${AVIFIL32}" '!=' "xtrue"; then
334  echo "* Disabling avi2swf tool..."
335  echo all install uninstall clean: > avi2swf/Makefile
336  avi2swf=
337 fi
338
339 pdf2swf_makefile="pdf2swf/Makefile pdf2swf/xpdf/Makefile"
340 if test "x${DISABLEPDF2SWF}" = "xtrue"; then
341   echo "* Disabling pdf2swf tool..."
342   rm -f pdf2swf/Makefile
343   echo all install uninstall clean: > pdf2swf/Makefile
344   pdf2swf_makefile=""
345 fi
346
347 if test "x${ZLIBMISSING}" = "xtrue"; then
348   echo
349   echo "* Warning! Without zlib, you will not be able to read"
350   echo "* or write compressed Flash MX files!"
351 fi
352
353 JPEG2SWF='jpeg2swf$(E)'
354 if test "x${DISABLEJPEG2SWF}" = "xtrue"; then
355   echo "* Disabling jpeg2swf tool..."
356   JPEG2SWF=
357 fi
358 export JPEG2SWF
359 AC_SUBST(JPEG2SWF)
360
361 PNG2SWF='png2swf$(E)'
362 if test "x${DISABLEPNG2SWF}" = "xtrue"; then
363   echo "* Disabling png2swf tool..."
364   PNG2SWF=
365 fi
366 export PNG2SWF
367 AC_SUBST(PNG2SWF)
368
369 if test "x${MISSINGLIBS}" '!=' "x"; then
370   if test "x${PARTIAL}" '=' "x"; then
371     echo "* (never mind)"
372   fi
373   echo "***************************************************"
374 fi
375
376 # ------------------------------------------------------------------
377
378 if test -f "release.in"; then release_in="./release"; fi
379 FILES="$release_in Makefile.common ${avi2swf} Makefile lib/Makefile lib/action/Makefile src/Makefile ${pdf2swf_makefile} swfs/Makefile ${pythonrfxswf} ${lame_makefile}"
380
381 dnl AC_OUTPUT(${FILES}) old autoconf
382 AC_CONFIG_FILES([${FILES}])
383 AC_OUTPUT
384