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