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