in_source patch from Patrice Dumas
[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=2008-06-23-2005
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([O_BINARY], [0], [Not defined on mingw])
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(ungif, DGifOpen,, UNGIFMISSING=true)
216 if test "$UNGIFMISSING";then
217     UNGIFMISSING=
218     AC_CHECK_LIB(gif, DGifOpen,, UNGIFMISSING=true)
219 fi
220
221 RFX_CHECK_BYTEORDER
222 AC_SUBST(WORDS_BIGENDIAN)
223 RFX_CHECK_SYSTEM_BACKTICKS
224 AC_SUBST(SYSTEM_BACKTICKS)
225
226 AC_ARG_PROGRAM
227
228 dnl Checks for header files.
229  AC_CONFIG_HEADER(config.h)
230  AC_HEADER_DIRENT
231  AC_HEADER_STDC
232
233  AC_CHECK_HEADERS(zlib.h gif_lib.h io.h wchar.h jpeglib.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 sys/time.h sys/resource.h)
234
235 AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
236 AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])
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 wcschr wcsdup mkstemp stat lrand48 rand srand48 srand bcopy bzero time getrusage mallinfo)
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 RFX_CHECK_OPENGL
264 if test "$HAVE_OPENGL";then
265     DEVICE_OPENGL='devices/opengl.$(O)'
266     AC_SUBST(DEVICE_OPENGL)
267 fi
268
269 lame_in_source= 
270 lame_makefile=
271 if test "x${DISABLE_LAME}" = "xtrue"; then
272     echo "*" Disabling lame support...
273 else
274     # old lame code at lib/lame
275     if test -f lib/lame/Makefile.in; then
276         lame_in_source='$(lame_objects)'
277         lame_makefile="lib/lame/Makefile"
278         CPPFLAGS="$CPPFLAGS -Ilame"
279         AC_DEFINE([HAVE_LAME], [1], [have/use internal l.a.m.e. mp3 library])
280     else
281         if test -d /usr/include/lame; then
282             CPPFLAGS="$CPPFLAGS -I /usr/include/lame"
283         else
284             if test -d /usr/local/include/lame; then
285                 CPPFLAGS="$CPPFLAGS -I /usr/local/include/lame"
286             fi
287         fi
288         AC_CHECK_LIB(mp3lame, lame_init,, NO_LIBMP3LAME=1)
289         AC_CHECK_HEADERS(lame.h)
290         if test "x$NO_LIBMP3LAME" "!=" "x1" -a "x$ac_cv_header_lame_h" "!=" "x";then
291             AC_DEFINE([HAVE_LAME], [1])
292         fi
293     fi
294 fi
295 AC_SUBST(lame_in_source)
296
297 # ------------------------------------------------------------------
298  
299 RFX_CHECK_AVI2SWF
300 if test "x${AVIFILE}" = "xtrue"; then
301     VIDEO_LIBS="$VIDEO_LIBS $AVIFILE_LIBS"
302     VIDEO_CFLAGS="$VIDEO_CFLAGS $AVIFILE_CFLAGS"
303     AC_DEFINE([HAVE_AVIFILE], [1], [Define if avifile is present])
304 fi
305
306 if test "x${WIN32}" != "x"; then
307     #AC_CHECK_LIB(avifil32, AVIFileInit,AVIFIL32=true)
308     #if test "x${AVIFIL32}" != "x"; then
309     #  VIDEO_LIBS="$VIDEO_LIBS -lavifil32"
310     #fi
311     VIDEO_LIBS="$VIDEO_LIBS -lavifil32"
312     AVIFIL32=true
313 fi
314
315 AC_SUBST(VIDEO_LIBS)
316 AC_SUBST(VIDEO_CFLAGS)
317 # ------------------------------------------------------------------
318
319 if test "x${UNCOMPRESS}" = "xgzip"; then
320     AC_DEFINE([USE_GZIP], [1], [Define if gzip is present])
321 fi
322 AC_SUBST(USE_GZIP)
323
324 # ------------------------------------------------------------------
325
326 RFX_CHECK_PYTHON
327
328 if test "x$PYTHON_OK" '!=' "xyes";then
329     echo all install uninstall clean: > lib/python/Makefile
330     # fail silently- the most users won't have any need for the
331     # python interface anyway
332 else
333     pythonrfxswf="lib/python/Makefile"
334 fi
335
336 # ------------------------------------------------------------------
337
338 AC_MSG_CHECKING([for missing libraries])
339
340 if test "x$ZLIBMISSING" = "xtrue";then
341     MISSINGLIBS="${MISSINGLIBS} zlib"
342     DISABLEPNG2SWF=true
343     PARTIAL=true
344 fi
345 if test "x$JPEGLIBMISSING" = "xtrue";then
346     MISSINGLIBS="${MISSINGLIBS} jpeglib"
347     DISABLEPDF2SWF=true
348     DISABLEJPEG2SWF=true
349     PARTIAL=true
350 fi
351 #if test "x$T1LIBMISSING" = "xtrue";then
352 #    MISSINGLIBS="${MISSINGLIBS} t1lib"
353 #fi
354 if test "x$UNGIFMISSING" = "xtrue";then
355     DISABLEGIF2SWF=true
356     MISSINGLIBS="${MISSINGLIBS} ungif"
357     PARTIAL=true
358 fi
359
360 if test "x${ac_cv_header_jpeglib_h}" '!=' "xyes"; then
361     DISABLEPDF2SWF=true;
362     DISABLEJPEG2SWF=true;
363     MISSINGLIBS="${MISSINGLIBS} jpeglib.h"
364     PARTIAL=true
365 fi
366 if test "x$HAVE_FREETYPE" '!=' "x1"; then
367     DISABLEPDF2SWF=true;
368     MISSINGLIBS="${MISSINGLIBS} freetype"
369     PARTIAL=true
370 fi
371 #if test "x${ac_cv_header_t1lib_h}" '!=' "xyes"; then
372 #    MISSINGLIBS="${MISSINGLIBS} t1lib.h"
373 #fi
374 if test "x${ac_cv_header_gif_lib_h}" '!=' "xyes"; then
375     DISABLEGIF2SWF=true
376     MISSINGLIBS="${MISSINGLIBS} gif_lib.h"
377     PARTIAL=true
378 fi
379 if test "x${ac_cv_header_zlib_h}" '!=' "xyes"; then
380     DISABLEPNG2SWF=true;
381     MISSINGLIBS="${MISSINGLIBS} zlib.h"
382     PARTIAL=true
383 fi
384 #if test "x${AVIFILE}" '!=' "xtrue" -a "x${AVIFIL32}" '!=' "xtrue"; then
385 #    MISSINGLIBS="${MISSINGLIBS} avifile"
386 #fi
387
388 AC_MSG_RESULT(${MISSINGLIBS})
389
390 # ------------------------------------------------------------------
391
392 if test "x${MISSINGLIBS}" '!=' "x"; then
393   echo "***************************************************"
394   echo "* The following headers/libraries are missing: " ${MISSINGLIBS}
395 fi
396
397 avi2swf="avi2swf/Makefile"
398 if test "x${AVIFILE}" '!=' "xtrue" -a "x${AVIFIL32}" '!=' "xtrue"; then
399  #don't whine, avi2swf is outdated anyway
400  #echo "* Disabling avi2swf tool..."
401  echo all install uninstall clean: > avi2swf/Makefile
402  avi2swf=
403 fi
404
405 pdf2swf_makefile="lib/pdf/Makefile"
406 PDF2SWF='pdf2swf$(E)'
407 LIBPDF='libpdf$(A)'
408
409 if test "x${DISABLEPDF2SWF}" = "xtrue"; then
410   echo "* Disabling pdf2swf tool..."
411   rm -f lib/pdf/Makefile
412   echo all install uninstall clean: > lib/pdf/Makefile
413   pdf2swf_makefile=""
414   PDF2SWF=
415   LIBPDF=
416 fi
417 AC_SUBST(PDF2SWF)
418 AC_SUBST(LIBPDF)
419
420 if test "x${ZLIBMISSING}" = "xtrue"; then
421   echo
422   echo "* Warning! Without zlib, you will not be able to read"
423   echo "* or write compressed Flash MX files!"
424 fi
425
426 JPEG2SWF='jpeg2swf$(E)'
427 if test "x${DISABLEJPEG2SWF}" = "xtrue"; then
428   echo "* Disabling jpeg2swf tool..."
429   JPEG2SWF=
430 fi
431 export JPEG2SWF
432 AC_SUBST(JPEG2SWF)
433
434 GIF2SWF='gif2swf$(E)'
435 if test "x${DISABLEGIF2SWF}" = "xtrue"; then
436   echo "* Disabling gif2swf tool..."
437   GIF2SWF=
438 fi
439 export GIF2SWF
440 AC_SUBST(GIF2SWF)
441
442 PNG2SWF='png2swf$(E)'
443 if test "x${DISABLEPNG2SWF}" = "xtrue"; then
444   echo "* Disabling png2swf tool..."
445   PNG2SWF=
446 fi
447 export PNG2SWF
448 AC_SUBST(PNG2SWF)
449
450 if test "x${MISSINGLIBS}" '!=' "x"; then
451   if test "x${PARTIAL}" '=' "x"; then
452     echo "* (never mind)"
453   fi
454   echo "***************************************************"
455 fi
456
457 # ------------------------------------------------------------------
458
459 AH_TOP([
460 #ifndef __config_h__
461 #define __config_h__
462 ])
463
464 AH_BOTTOM([
465 #ifdef HAVE_ZLIB_H
466 #ifdef HAVE_LIBZ
467 #define HAVE_ZLIB
468 #endif
469 #endif
470
471 #ifdef HAVE_JPEGLIB_H
472 #ifdef HAVE_LIBJPEG
473 #define HAVE_JPEGLIB
474 #endif
475 #endif
476
477 #ifdef HAVE_FT2BUILD_H
478 #define HAVE_FREETYPE_H 1
479 #endif
480
481 #ifdef HAVE_GL_GL_H
482 #ifdef HAVE_GL_GLUT_H
483 #ifdef HAVE_OPENGL
484 #define USE_OPENGL
485 #endif
486 #endif
487 #endif
488
489 #endif // __config_h__
490 ])
491
492
493
494 if test -f "release.in"; then release_in="./release"; fi
495 FILES="$release_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/readers/Makefile"
496 AC_OUTPUT(${FILES})
497
498 dnl new autoconf
499 dnl AC_CONFIG_FILES([${FILES}])
500 dnl AC_OUTPUT
501
502 #
503 # On development trees, create snapshots of config.status
504 #
505 if test -f snapshot -a "x$CHECKMEM" = "x" -a "x$PROFILING" = "x";then
506     if test "x${MINGW}" = "xyes"; then
507         echo cp config.status config.status.win32
508         cp config.status config.status.win32
509     else
510         if test "x$DEBUG" '=' "x" -a "x$OPTIMIZE"  '=' "x";then
511             echo cp config.status config.status.linux
512             cp config.status config.status.linux
513         fi
514         if test "x$DEBUG" '!=' "x" -a "x$OPTIMIZE"  '=' "x";then
515             echo cp config.status config.status.debug
516             cp config.status config.status.debug
517         fi
518         if test "x$DEBUG"    = "x" -a "x$OPTIMIZE" '!=' "x"; then
519             echo cp config.status config.status.optimize
520             cp config.status config.status.optimize
521         fi
522     fi
523 fi