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