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