mac os x compile fixes
[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 AC_ARG_WITH([poppler],
23 [  --with-poppler          use poppler instead of internal xpdf (currently broken)], [USE_POPPLER=true])
24
25 PACKAGE=swftools
26 VERSION=0.9.0
27
28
29 # ------------------------------------------------------------------
30
31 if test "x${srcdir}" != "x."; then
32     echo "--srcdir is not supported"
33     exit 1
34 fi
35
36 WARNINGS="-Wparentheses -Wimplicit -Wreturn-type"
37 if test "x$ENABLE_WARNINGS" '!=' "x";then
38     WARNINGS="-Wall -Wno-unused -Wno-format -Wno-redundant-decls -D_FORTIFY_SOURCE=2 "
39 fi
40
41 if test "x$CHECKMEM" '!=' "x";then
42     DEBUG=yes
43 fi
44 if test "x$PROFILING" '!=' "x";then
45     DEBUG=yes
46 fi
47 if test "x$DEBUG" '!=' "x";then
48     if test "x$PROFILING" = "x";then
49         CFLAGS="$WARNINGS -O2 -g $CFLAGS"
50         CXXFLAGS="$WARNINGS -O2 -g $CXXFLAGS"
51         LDFLAGS="-g $LIBS"
52     else
53         CFLAGS="$WARNINGS -O2 -g -pg $CFLAGS"
54         CXXFLAGS="$WARNINGS -O2 -g -pg $CXXFLAGS"
55         LDFLAGS="-g -pg $LIBS"
56     fi
57 else if test "x$OPTIMIZE" '!=' "x"; then
58     CFLAGS="$WARNINGS -O3 -fomit-frame-pointer -Winline $CFLAGS"
59     CXXFLAGS="$WARNINGS -O3 -fomit-frame-pointer -Winline $CXXFLAGS"
60 else
61     CFLAGS="$WARNINGS -O -fomit-frame-pointer $CFLAGS"
62     CXXFLAGS="$WARNINGS -O -fomit-frame-pointer $CXXFLAGS"
63 fi
64 fi
65
66 CFLAGS="-fPIC $CFLAGS"
67 CXXFLAGS="-fPIC $CFLAGS"
68
69 #OLDGCC=1
70 #if test "x$OLDGCC" '!=' "x";then
71 #     #CFLAGS="$CFLAGS --std=c89 -ansi -pendantic"
72 #     #CXXFLAGS="$CXXFLAGS --std=c89 -ansi -pendantic"
73 #     CFLAGS="$CFLAGS -ansi -pendantic"
74 #     CXXFLAGS="$CXXFLAGS -ansi -pendantic"
75 #fi
76
77 export PACKAGE VERSION CFLAGS CXXFLAGS
78
79 dnl Checks for programs.
80
81 AC_CANONICAL_HOST
82
83 SHARED="-shared"
84 MACOSX=
85 case $host_os in
86     *darwin* ) 
87         MACOSX=yes
88         CFLAGS="$CFLAGS"
89         CXXFLAGS="$CXXFLAGS -fno-rtti"
90         SHARED="-bundle"
91         if test -d /opt/local/include && test -d /opt/local/lib; then
92             CPPFLAGS="${CPPFLAGS} -I/opt/local/include"
93             LDFLAGS="${LDFLAGS} -L/opt/local/lib"
94         fi
95         # Use fink packages if available.
96         #if test -d /sw/include && test -d /sw/lib; then
97         #    CPPFLAGS="${CPPFLAGS} -I/sw/include"
98         #    LDFLAGS="${LDFLAGS} -L/sw/lib"
99         #fi
100         ;;
101 esac
102
103 AC_SUBST(SHARED)
104
105 dnl Checks for programs.
106  AC_PROG_CC
107  AC_PROG_CXX
108
109
110 RFX_CHECK_OLDGCC
111
112 if test "x$GCC_IS_OK" '=' "x";then
113     echo "***************************************************"
114     echo "* Your gcc is too old to compile this!"
115     echo "* "
116     echo "* The last version compileable by this compiler is "
117     echo "* swftools 0.7.0, which you can download from "
118     echo "* http://www.swftools.org/swftools-0.7.0.tar.gz "
119     echo "* ."
120     echo "* Newer versions require at least gcc 3.0.0 "
121     echo "***************************************************"
122     exit 1
123 fi
124     
125 if test "x$CHECKMEM" '!=' "x";then
126     CC="ccmalloc $CC"
127     CXX="ccmalloc $CXX"
128     #echo running again
129     #unset ac_cv_prog_CC
130     #unset ac_cv_prog_CXX
131     #AC_PROG_CC
132     #AC_PROG_CXX
133 fi
134  AC_PROG_CPP
135
136  AC_PROG_RANLIB
137  AC_PROG_MAKE_SET
138  AC_PROG_INSTALL
139  AC_PROG_LN_S
140  AC_CHECK_PROGS(UNCOMPRESS, gzip uncompress compress, )
141
142 dnl PKG_PROG_PKG_CONFIG
143
144 dnl Checks for system services
145 OBJEXT="o"
146 AREXT=".a"
147 CXXLIBS="-lstdc++"
148
149 AC_EXEEXT
150
151 if test "x$EXEEXT" = "x.exe";then
152     OBJEXT="obj"
153     AREXT=".lib"
154     CXXLIBS=""
155 fi
156 AC_SUBST(OBJEXT)
157 AC_SUBST(AREXT)
158
159 RFX_CHECK_MING
160
161 SLEXT="so"
162 if test "x${MINGW}" != "xyes"; then
163     # no mingW
164     AC_DEFINE([O_BINARY], [0], [Not defined on mingw])
165 else
166     # mingW
167     SLEXT="dll"
168     CXXLIBS=""
169 fi
170 export SLEXT
171 AC_SUBST(SLEXT)
172 AC_SUBST(CXXLIBS)
173
174 # The following tries to make use of includes and libraries in
175 # /usr/local, too. Notice: A -I/usr/local/include might break
176 # things (MingW, cross-compiling etc.) in the same way as -I/usr/include, 
177 # especially on systems which link /usr/local to /usr, so it has yet
178 # to be seen how useful this is.
179 if test -d /usr/local/lib; then
180     LDFLAGS="$LDFLAGS -L/usr/local/lib"
181 fi
182 if test -d /usr/local/include; then
183 # Leave that alone. It's causing trouble e.g. with gcc 3.2 on gentoo.
184 #   CPPFLAGS="$CPPFLAGS -I/usr/local/include"
185     echo > /dev/null
186 fi
187 if test "$prefix" != "NONE" -a "$prefix" != "/usr/local" -a "$prefix" != "/usr/local/"; then
188     # if the user has a special prefix (like /opt), there might also be $prefix/lib
189     # and $prefix/include, which should be included in our search paths for libraries
190     # and includes.
191     LDFLAGS="$LDFLAGS -L${libdir}"
192     CPPFLAGS="$CPPFLAGS -I${includedir}"
193     # TODO- test whether gcc still works after this
194 fi
195
196 #Mac OS:
197 #LDFLAGS "-L/sw/lib" ; CPPFLAGS "-I/sw/include -I/sw/include/lame"
198
199
200 # this must be done after (I believe) AC_PROG_MAKE_SET
201 if test "x$DEBUG" '!=' "x" -o "x$STRIP" = "x";then
202     STRIP="@echo debug enabled, not stripping "
203     export STRIP
204     AC_SUBST(STRIP)
205 fi
206
207 dnl Checks for libraries.
208  AC_CHECK_LIB(m, sin,, 
209  echo "Error: Math library not found.";
210  exit;
211  )
212  AC_CHECK_LIB(z, deflate,, ZLIBMISSING=true)
213
214 if test "x$ZLIBMISSING" = "xtrue";then
215     echo 
216     echo "ERROR:"
217     echo "You need zlib to compile swftools"
218     echo
219     exit
220 fi
221  
222 AC_CHECK_LIB(jpeg, jpeg_write_raw_data,, JPEGLIBMISSING=true)
223 AC_CHECK_LIB(ungif, DGifOpen,, UNGIFMISSING=true)
224 if test "$UNGIFMISSING";then
225     UNGIFMISSING=
226     AC_CHECK_LIB(gif, DGifOpen,, UNGIFMISSING=true)
227 fi
228
229 RFX_CHECK_BYTEORDER
230 AC_SUBST(WORDS_BIGENDIAN)
231 RFX_CHECK_SYSTEM_BACKTICKS
232 AC_SUBST(SYSTEM_BACKTICKS)
233
234 AC_ARG_PROGRAM
235
236 dnl Checks for header files.
237  AC_CONFIG_HEADER(config.h)
238  AC_HEADER_DIRENT
239  AC_HEADER_STDC
240
241  AC_CHECK_HEADERS(zlib.h gif_lib.h io.h wchar.h jpeglib.h assert.h signal.h pthread.h sys/stat.h sys/mman.h sys/types.h dirent.h sys/bsdtypes.h sys/ndir.h sys/dir.h ndir.h time.h sys/time.h sys/resource.h)
242
243 AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
244 AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])
245 AC_SUBST(PACKAGE)
246 AC_SUBST(VERSION)
247
248 AC_SUBST(HAVE_UNISTD_H)
249 AC_SUBST(EXEEXT)
250
251 dnl Checks for typedefs, structures, and compiler characteristics.
252  AC_C_CONST
253  AC_C_INLINE
254  AC_TYPE_OFF_T
255  AC_TYPE_SIZE_T
256  AC_STRUCT_TM
257  AC_CHECK_TYPE(boolean,int) #needed for jpeglib
258  AC_CHECK_FUNCS(popen wcschr wcsdup mkstemp stat mmap lrand48 rand srand48 srand bcopy bzero time getrusage mallinfo)
259
260 AC_CHECK_SIZEOF([signed char])
261 AC_CHECK_SIZEOF([signed short])
262 AC_CHECK_SIZEOF([signed])
263 AC_CHECK_SIZEOF([signed long long])
264 AC_CHECK_SIZEOF([void*])
265
266 RFX_CHECK_FREETYPE
267
268 RFX_CHECK_FONTCONFIG
269
270 RFX_CHECK_OPENGL
271 if test "$HAVE_OPENGL";then
272     DEVICE_OPENGL='devices/opengl.$(O)'
273     AC_SUBST(DEVICE_OPENGL)
274 fi
275
276 lame_in_source= 
277 lame_makefile=
278 if test "x${DISABLE_LAME}" = "xtrue"; then
279     echo "*" Disabling lame support...
280 else
281     # old lame code at lib/lame
282     if test -f lib/lame/Makefile.in; then
283         lame_in_source='$(lame_objects)'
284         lame_makefile="lib/lame/Makefile"
285         CPPFLAGS="$CPPFLAGS -Ilame -Ilib/lame"
286         AC_DEFINE([HAVE_LAME], [1], [have/use internal l.a.m.e. mp3 library])
287     else
288         if test -d /usr/include/lame; then
289             CPPFLAGS="$CPPFLAGS -I /usr/include/lame"
290         else
291             if test -d /usr/local/include/lame; then
292                 CPPFLAGS="$CPPFLAGS -I /usr/local/include/lame"
293             fi
294         fi
295         AC_CHECK_LIB(mp3lame, lame_init,, NO_LIBMP3LAME=1)
296         HASLAMEHEADER=
297         AC_CHECK_HEADERS(lame.h,HASLAMEHEADER=1)
298         if test "x$NO_LIBMP3LAME" "!=" "x1" -a "x$HASLAMEHEADER" '!=' "x";then
299             AC_DEFINE([HAVE_LAME], [1])
300         fi
301     fi
302 fi
303 AC_SUBST(lame_in_source)
304
305 AC_DEFINE([INTERNAL_LIBART], [1], [use internal libart library])
306 art_in_source='$(art_objects)'
307 splash_in_source='$(splash_objects)'
308 xpdf_in_source='$(xpdf_objects)'
309
310 dnl if test "x$USE_POPPLER" = "xtrue"; then
311 dnl     xpdf_in_source=
312 dnl     splash_in_source=
313 dnl     AC_DEFINE([HAVE_POPPLER],[1],[use poppler])
314 dnl     PKG_CHECK_MODULES([POPPLER],[poppler poppler-splash],,[poppler_pkgconfig=no])
315 dnl     if test "x$poppler_pkgconfig" = "xno"; then
316 dnl         AC_LANG_PUSH([C++])
317 dnl         AC_CHECK_HEADERS([OutputDev.h],[
318 dnl            AC_CHECK_LIB([poppler],[main],,[])
319 dnl         ],[AC_MSG_ERROR([No poppler library found. This library is required.])])
320 dnl         AC_LANG_POP
321 dnl     else
322 dnl     CPPFLAGS="$CPPFLAGS $POPPLER_CFLAGS"
323 dnl         AC_DEFINE([HAVE_POPPLER], [1])
324 dnl         LIBS="$LIBS $POPPLER_LIBS"
325 dnl     fi
326 dnl fi
327
328 AC_SUBST([art_in_source])
329 AC_SUBST([xpdf_in_source])
330 AC_SUBST([splash_in_source])
331
332 # ------------------------------------------------------------------
333  
334 RFX_CHECK_AVI2SWF
335 if test "x${AVIFILE}" = "xtrue"; then
336     VIDEO_LIBS="$VIDEO_LIBS $AVIFILE_LIBS"
337     VIDEO_CFLAGS="$VIDEO_CFLAGS $AVIFILE_CFLAGS"
338     AC_DEFINE([HAVE_AVIFILE], [1], [Define if avifile is present])
339 fi
340
341 if test "x${WIN32}" != "x"; then
342     #AC_CHECK_LIB(avifil32, AVIFileInit,AVIFIL32=true)
343     #if test "x${AVIFIL32}" != "x"; then
344     #  VIDEO_LIBS="$VIDEO_LIBS -lavifil32"
345     #fi
346     VIDEO_LIBS="$VIDEO_LIBS -lavifil32"
347     AVIFIL32=true
348 fi
349
350 AC_SUBST(VIDEO_LIBS)
351 AC_SUBST(VIDEO_CFLAGS)
352 # ------------------------------------------------------------------
353
354 if test "x${UNCOMPRESS}" = "xgzip"; then
355     AC_DEFINE([USE_GZIP], [1], [Define if gzip is present])
356 fi
357 AC_SUBST(USE_GZIP)
358
359 # ------------------------------------------------------------------
360
361 RFX_CHECK_PYTHON
362
363 if test "x$PYTHON_OK" '!=' "xyes";then
364     echo all install uninstall clean: > lib/python/Makefile
365     # fail silently- the most users won't have any need for the
366     # python interface anyway
367 else
368     pythonrfxswf="lib/python/Makefile"
369 fi
370
371 # ------------------------------------------------------------------
372
373 AC_MSG_CHECKING([for missing libraries])
374
375 if test "x$ZLIBMISSING" = "xtrue";then
376     MISSINGLIBS="${MISSINGLIBS} zlib"
377     DISABLEPNG2SWF=true
378     PARTIAL=true
379 fi
380 if test "x$JPEGLIBMISSING" = "xtrue";then
381     MISSINGLIBS="${MISSINGLIBS} jpeglib"
382     DISABLEPDF2SWF=true
383     DISABLEJPEG2SWF=true
384     PARTIAL=true
385 fi
386 #if test "x$T1LIBMISSING" = "xtrue";then
387 #    MISSINGLIBS="${MISSINGLIBS} t1lib"
388 #fi
389 if test "x$UNGIFMISSING" = "xtrue";then
390     DISABLEGIF2SWF=true
391     MISSINGLIBS="${MISSINGLIBS} ungif"
392     PARTIAL=true
393 fi
394
395 if test "x${ac_cv_header_jpeglib_h}" '!=' "xyes"; then
396     DISABLEPDF2SWF=true;
397     DISABLEJPEG2SWF=true;
398     MISSINGLIBS="${MISSINGLIBS} jpeglib.h"
399     PARTIAL=true
400 fi
401 if test "x$HAVE_FREETYPE" '!=' "x1"; then
402     DISABLEPDF2SWF=true;
403     MISSINGLIBS="${MISSINGLIBS} freetype"
404     PARTIAL=true
405 fi
406 #if test "x${ac_cv_header_t1lib_h}" '!=' "xyes"; then
407 #    MISSINGLIBS="${MISSINGLIBS} t1lib.h"
408 #fi
409 if test "x${ac_cv_header_gif_lib_h}" '!=' "xyes"; then
410     DISABLEGIF2SWF=true
411     MISSINGLIBS="${MISSINGLIBS} gif_lib.h"
412     PARTIAL=true
413 fi
414 if test "x${ac_cv_header_zlib_h}" '!=' "xyes"; then
415     DISABLEPNG2SWF=true;
416     MISSINGLIBS="${MISSINGLIBS} zlib.h"
417     PARTIAL=true
418 fi
419 #if test "x${AVIFILE}" '!=' "xtrue" -a "x${AVIFIL32}" '!=' "xtrue"; then
420 #    MISSINGLIBS="${MISSINGLIBS} avifile"
421 #fi
422
423 AC_MSG_RESULT(${MISSINGLIBS})
424
425 # ------------------------------------------------------------------
426
427 if test "x${MISSINGLIBS}" '!=' "x"; then
428   echo "***************************************************"
429   echo "* The following headers/libraries are missing: " ${MISSINGLIBS}
430 fi
431
432 avi2swf="avi2swf/Makefile"
433 if test "x${AVIFILE}" '!=' "xtrue" -a "x${AVIFIL32}" '!=' "xtrue"; then
434  #don't whine, avi2swf is outdated anyway
435  #echo "* Disabling avi2swf tool..."
436  echo all install uninstall clean: > avi2swf/Makefile
437  avi2swf=
438 fi
439
440 pdf2swf_makefile="lib/pdf/Makefile"
441 PDF2SWF='pdf2swf$(E)'
442 LIBPDF='libpdf$(A)'
443
444 if test "x${DISABLEPDF2SWF}" = "xtrue"; then
445   echo "* Disabling pdf2swf tool..."
446   rm -f lib/pdf/Makefile
447   echo all install uninstall clean libpdf: > lib/pdf/Makefile
448   pdf2swf_makefile=""
449   PDF2SWF=
450   LIBPDF=
451 fi
452 AC_SUBST(PDF2SWF)
453 AC_SUBST(LIBPDF)
454
455 if test "x${ZLIBMISSING}" = "xtrue"; then
456   echo
457   echo "* Warning! Without zlib, you will not be able to read"
458   echo "* or write compressed Flash MX files!"
459 fi
460
461 JPEG2SWF='jpeg2swf$(E)'
462 if test "x${DISABLEJPEG2SWF}" = "xtrue"; then
463   echo "* Disabling jpeg2swf tool..."
464   JPEG2SWF=
465 fi
466 export JPEG2SWF
467 AC_SUBST(JPEG2SWF)
468
469 GIF2SWF='gif2swf$(E)'
470 if test "x${DISABLEGIF2SWF}" = "xtrue"; then
471   echo "* Disabling gif2swf tool..."
472   GIF2SWF=
473 fi
474 export GIF2SWF
475 AC_SUBST(GIF2SWF)
476
477 PNG2SWF='png2swf$(E)'
478 if test "x${DISABLEPNG2SWF}" = "xtrue"; then
479   echo "* Disabling png2swf tool..."
480   PNG2SWF=
481 fi
482 export PNG2SWF
483 AC_SUBST(PNG2SWF)
484
485 if test "x${MISSINGLIBS}" '!=' "x"; then
486   if test "x${PARTIAL}" '=' "x"; then
487     echo "* (never mind)"
488   fi
489   echo "***************************************************"
490 fi
491
492 # ------------------------------------------------------------------
493
494 AH_TOP([
495 #ifndef __config_h__
496 #define __config_h__
497 ])
498
499 AH_BOTTOM([
500 #ifdef HAVE_ZLIB_H
501 #ifdef HAVE_LIBZ
502 #define HAVE_ZLIB
503 #endif
504 #endif
505
506 #ifdef HAVE_JPEGLIB_H
507 #ifdef HAVE_LIBJPEG
508 #define HAVE_JPEGLIB
509 #endif
510 #endif
511
512 #ifdef HAVE_FT2BUILD_H
513 #define HAVE_FREETYPE_H 1
514 #endif
515
516 #ifdef HAVE_GL_GL_H
517 #ifdef HAVE_GL_GLUT_H
518 #ifdef HAVE_OPENGL
519 #define USE_OPENGL
520 #endif
521 #endif
522 #endif
523
524 #ifdef HAVE_POPPLER
525 #define GString GooString
526 #define GHash GooHash
527 #endif
528
529 #endif // __config_h__
530 ])
531
532 if test -f "release.in"; then release_in="./release"; fi
533 if test -f "Makefile.new.in"; then mk_in="./Makefile.new"; fi
534 FILES="$release_in $mk_in Makefile.common ${avi2swf} Makefile lib/Makefile lib/action/Makefile src/Makefile ${pdf2swf_makefile} swfs/Makefile ${pythonrfxswf} ${lame_makefile} lib/art/Makefile lib/readers/Makefile"
535 AC_OUTPUT(${FILES})
536
537 dnl new autoconf
538 dnl AC_CONFIG_FILES([${FILES}])
539 dnl AC_OUTPUT
540
541 #
542 # On development trees, create snapshots of config.status
543 #
544 if test -f snapshot -a "x$CHECKMEM" = "x" -a "x$PROFILING" = "x";then
545     if test "x${MINGW}" = "xyes"; then
546         echo cp config.status config.status.win32
547         cp config.status config.status.win32
548     else
549         if test "x$DEBUG" '=' "x" -a "x$OPTIMIZE"  '=' "x";then
550             echo cp config.status config.status.linux
551             cp config.status config.status.linux
552         fi
553         if test "x$DEBUG" '!=' "x" -a "x$OPTIMIZE"  '=' "x";then
554             echo cp config.status config.status.debug
555             cp config.status config.status.debug
556         fi
557         if test "x$DEBUG"    = "x" -a "x$OPTIMIZE" '!=' "x"; then
558             echo cp config.status config.status.optimize
559             cp config.status config.status.optimize
560         fi
561     fi
562 fi