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