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