moved extern declaration up to prevent compile-time errors.
[swftools.git] / configure.in
index b384539..393126b 100644 (file)
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT(pdf2swf/swfoutput.h)
-AM_INIT_AUTOMAKE(swftools, 0.0.2)
-AC_ARG_PROGRAM
+AC_INIT(src/)
+
+AC_ARG_ENABLE(checkmem,
+[  --enable-checkmem       turn on ccmalloc debugging], CHECKMEM=true)
+AC_ARG_ENABLE(debug,
+[  --enable-debug          turn on debugging], DEBUG=true)
+AC_ARG_ENABLE(optimizations,
+[  --enable-optimizations  turn on compiler optimizations (recommended for avi2swf)], OPTIMIZE=true)
+AC_ARG_ENABLE(mp3,
+[  --disable-mp3           don't compile any mp3 code in], NO_MP3=true)
+
+PACKAGE=swftools
+VERSION=2003-08-02-1416
+
+
+
+# -Winline?
 
-export CFLAGS
-CFLAGS="-O2 -fomit-frame-pointer"
-export CXXFLAGS
-CXXFLAGS="-O2 -fomit-frame-pointer"
+if test "x$CHECKMEM" '!=' "x";then
+    DEBUG=yes
+fi
+if test "x$DEBUG" '!=' "x";then
+    CFLAGS="-Wparentheses -Wimplicit -Wreturn-type -g $CFLAGS"
+    CXXFLAGS="-Wparentheses -Wimplicit -Wreturn-type -g $CXXFLAGS"
+    STRIP="@echo debug enabled, not stripping "
+    export STRIP
+    AC_SUBST(STRIP)
+else if test "x$OPTIMIZE" '!=' "x"; then
+       CFLAGS="-Wparentheses -Wimplicit -Wreturn-type -Winline -O3 -fomit-frame-pointer $CFLAGS"
+       CXXFLAGS="-Wparentheses -Wimplicit -Wreturn-type -Winline -O3 -fomit-frame-pointer $CXXFLAGS"
+     else
+       CFLAGS="-Wparentheses -Wimplicit -Wreturn-type -O -fomit-frame-pointer $CFLAGS"
+       CXXFLAGS="-Wparentheses -Wimplicit -Wreturn-type -O -fomit-frame-pointer $CXXFLAGS"
+     fi
+fi
+
+export PACKAGE VERSION CFLAGS CXXFLAGS
+
+dnl Checks for programs.
+ AC_CANONICAL_HOST
+MACOSX=
+case $host_os in
+    *darwin* ) 
+       MACOSX=yes
+       CFLAGS="$CFLAGS -fno-rtti"
+       CXXFLAGS="$CXXFLAGS -fno-rtti"
+       ;;
+esac
 dnl Checks for programs.
- AC_PROG_AWK
  AC_PROG_CC
- AC_PROG_CPP
  AC_PROG_CXX
+
+if test "x$CHECKMEM" '!=' "x";then
+    CC="ccmalloc $CC"
+    CXX="ccmalloc $CXX"
+    #echo running again
+    #unset ac_cv_prog_CC
+    #unset ac_cv_prog_CXX
+    #AC_PROG_CC
+    #AC_PROG_CXX
+fi
+ AC_PROG_CPP
+
  AC_PROG_RANLIB
  AC_PROG_MAKE_SET
  AC_PROG_INSTALL
  AC_PROG_LN_S
+ AC_PROG_LIBTOOL
+ AC_CHECK_PROGS(UNCOMPRESS, gzip uncompress compress, )
+ AC_CHECK_PROGS(FREETYPE_CONFIG, freetype-config, )
 
 dnl Checks for system services
  AC_EXEEXT
 
+RFX_CHECK_MING
+
+if test "x${MINGW}" != "xyes"; then
+    AC_DEFINE_UNQUOTED(O_BINARY, 0)
+fi
+# The following tries to make use of includes and libraries in
+# /usr/local, too. Notice: A -I/usr/local/include might break
+# things (MingW, cross-compiling etc.) in the same way as -I/usr/include, 
+# especially on systems which link /usr/local to /usr, so it has yet
+# to be seen how useful this is.
+if test -d /usr/local/lib; then
+    LDFLAGS="$LDFLAGS -L/usr/local/lib"
+fi
+if test -d /usr/local/include; then
+# Leave that alone. It's causing trouble e.g. with gcc 3.2 on gentoo.
+#   CPPFLAGS="$CPPFLAGS -I/usr/local/include"
+    echo > /dev/null
+fi
+if test "$prefix" != "NONE" -a "$prefix" != "/usr/local" -a "$prefix" != "/usr/local/"; then
+    # if the user has a special prefix (like /opt), there might also be $prefix/lib
+    # and $prefix/include, which should be included in our search paths for libraries
+    # and includes.
+    LDFLAGS="$LDFLAGS -L${libdir}"
+    CPPFLAGS="$CPPFLAGS -I${includedir}"
+    # TODO- test whether gcc still works after this
+fi
+
 dnl Checks for libraries.
  AC_CHECK_LIB(m, sin,, 
  echo "Error: Math library not found.";
  exit;
  )
- AC_CHECK_LIB(z, crc32,, 
- echo "Error: The zlib compression library is required."
- DISABLEPDF2SWF=true; 
+ AC_CHECK_LIB(z, deflate,, 
+ DISABLEPNG2SWF=true;
  MISSINGLIBS="${MISSINGLIBS} zlib"
- exit;
+ ZLIBMISSING=true;
  )
  AC_CHECK_LIB(jpeg, jpeg_write_raw_data,, 
  DISABLEPDF2SWF=true;
@@ -38,20 +117,47 @@ dnl Checks for libraries.
  )
  AC_CHECK_LIB(t1, T1_LoadFont,,
  DISABLEPDF2SWF=true;
- MISSINGLIBS="${MISSINGLIBS} T1lib"
+ MISSINGLIBS="${MISSINGLIBS} t1lib"
  )
+ AC_CHECK_LIB(freetype, FT_Init_FreeType,
+ USE_FREETYPE=true,
+ )
+
+RFX_CHECK_BYTEORDER
+AC_SUBST(WORDS_BIGENDIAN)
+RFX_CHECK_SYSTEM_BACKTICKS
+AC_SUBST(SYSTEM_BACKTICKS)
 
-dnl do we need those?
- AC_CHECK_LIB(pthread, pthread_create)
- AC_CHECK_LIB(X11, XFlush)
+AC_ARG_PROGRAM
 
 dnl Checks for header files.
-AM_CONFIG_HEADER(config.h)
- AC_PATH_X
-dnl AC_PATH_XTRA
+ AC_CONFIG_HEADER(config.h)
  AC_HEADER_DIRENT
  AC_HEADER_STDC
- AC_CHECK_HEADERS(math.h fcntl.h limits.h malloc.h unistd.h memory.h zlib.h jpeglib.h t1lib.h)
+ AC_CHECK_HEADERS(zlib.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)
+
+if test "x${ac_cv_header_jpeglib_h}" != "xyes"; then
+ DISABLEPDF2SWF=true;
+ DISABLEJPEG2SWF=true;
+ MISSINGLIBS="${MISSINGLIBS} jpeglib.h"
+fi
+if test "x${ac_cv_header_t1lib_h}" != "xyes"; then
+ DISABLEPDF2SWF=true;
+ MISSINGLIBS="${MISSINGLIBS} t1lib.h"
+fi
+if test "x${ac_cv_header_zlib_h}" != "xyes"; then
+ DISABLEPNG2SWF=true;
+ MISSINGLIBS="${MISSINGLIBS} zlib.h"
+ ZLIBMISSING=true;
+fi
+
+if test "x$USE_FREETYPE" != "x"; then
+    AC_DEFINE_UNQUOTED(USE_FREETYPE, "$USE_FREETYPE")
+fi
+AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
+AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
+AC_SUBST(PACKAGE)
+AC_SUBST(VERSION)
 
 AC_SUBST(HAVE_UNISTD_H)
 AC_SUBST(EXEEXT)
@@ -62,32 +168,92 @@ dnl Checks for typedefs, structures, and compiler characteristics.
  AC_TYPE_OFF_T
  AC_TYPE_SIZE_T
  AC_STRUCT_TM
-dnl AC_CHECK_TYPE(uchar,unsigned char)
-dnl AC_CHECK_TYPE(schar,signed char)
-dnl AC_CHECK_TYPE(word,unsigned short int)
-dnl AC_CHECK_TYPE(sword,unsigned short int)
-dnl AC_CHECK_TYPE(uint,unsigned long int)
+ AC_CHECK_TYPE(boolean,int)
+ AC_CHECK_TYPE(bool,char)
+ dnl AC_CHECK_TYPE(uchar,unsigned char)
+ dnl AC_CHECK_TYPE(schar,signed char)
+ dnl AC_CHECK_TYPE(word,unsigned short int)
+ dnl AC_CHECK_TYPE(sword,unsigned short int)
+ dnl AC_CHECK_TYPE(uint,unsigned long int)
 
 dnl Checks for library functions.
- AC_FUNC_MEMCMP
- AC_FUNC_MMAP
- AC_FUNC_VPRINTF
- AC_CHECK_FUNCS(getcwd putenv socket strcspn strdup strerror strstr)
+ AC_CHECK_FUNCS(popen mkstemp stat lrand48 rand srand48 srand)
+ RFX_CHECK_AVI2SWF
 
+avi2swf="avi2swf/Makefile"
+if test "x${AVIFILE}" != "xtrue"; then
+ echo "* Couldn't compile the avifile test program."
+ echo "* Disabling avi2swf tool..."
+ echo all install uninstall clean: > avi2swf/Makefile
+ avi2swf=
+fi
+
+if test "x${NO_MP3}" == "x"; then
+    AC_DEFINE_UNQUOTED(USE_MP3, 1)
+fi
+
+if test "x${USE_FREETYPE}" == "xtrue"; then
+    if test "x{$FREETYPE_CONFIG}" != "x"; then
+       ftinclude=`freetype-config --cflags`
+       ftlibs=`freetype-config --libs`
+       CXXFLAGS="$CXXFLAGS $ftinclude"
+       CFLAGS="$CFLAGS $ftinclude"
+       LIBS="$LIBS $ftlibs"
+    else if test -d /usr/include/freetype2; then
+       CXXFLAGS="$CXXFLAGS -I/usr/include/freetype2"
+       CFLAGS="$CFLAGS -I/usr/include/freetype2"
+       LIBS="$LIBS -lfreetype"
+    else if test -d /usr/local/include/freetype2; then
+       CXXFLAGS="$CXXFLAGS -I/usr/local/include/freetype2"
+       CFLAGS="$CFLAGS -I/usr/local/include/freetype2"
+       LIBS="$LIBS -L /usr/local/lib -lfreetype"
+    fi
+    fi
+    fi
+fi 
+
+if test "x${UNCOMPRESS}" = "xgzip"; then
+    AC_DEFINE_UNQUOTED(USE_GZIP, 1)
+fi
+AC_SUBST(USE_GZIP)
 
+JPEG2SWF='jpeg2swf$(E)'
+export JPEG2SWF
+PNG2SWF='png2swf$(E)'
+export PNG2SWF
 if test "x${DISABLEPDF2SWF}" = "xtrue"; then
   echo "***************************************************"
-  echo "The following libraries are missing: " ${MISSINGLIBS}
-  echo "Disabling pdf2swf tool..."
-  rm pdf2swf/Makefile
-  echo all: > pdf2swf/Makefile
+  echo "The following headers/libraries are missing: " ${MISSINGLIBS}
+  if test "x${DISABLEPDF2SWF}" = "xtrue"; then
+    echo "Disabling pdf2swf tool..."
+    rm -f pdf2swf/Makefile
+    echo all install uninstall clean: > pdf2swf/Makefile
+  fi
   if test "x${DISABLEJPEG2SWF}" = "xtrue"; then
     echo "Disabling jpeg2swf tool..."
-    dnl FIXME: Do something here
+    JPEG2SWF=
+    export JPEG2SWF
+  fi
+  if test "x${DISABLEPNG2SWF}" = "xtrue"; then
+    echo "Disabling png2swf tool..."
+    PNG2SWF=
+    export PNG2SWF
+  fi
+  if test "x${ZLIBMISSING}" = "xtrue"; then
+    echo
+    echo "Warning! Without zlib, you will not be able to read"
+    echo "or write compressed Flash MX files!"
   fi
   echo "***************************************************"
-  AC_OUTPUT(./release Makefile lib/Makefile src/Makefile)
+  FILES="./release Makefile.common ${avi2swf} Makefile lib/lame/Makefile lib/Makefile src/Makefile swfs/Makefile"
 else
-  AC_OUTPUT(./release Makefile lib/Makefile src/Makefile pdf2swf/Makefile pdf2swf/xpdf/Makefile pdf2swf/fonts/Makefile)
+  FILES="./release Makefile.common ${avi2swf} Makefile lib/lame/Makefile lib/Makefile src/Makefile pdf2swf/Makefile pdf2swf/xpdf/Makefile pdf2swf/ttf2pt1/Makefile swfs/Makefile"
 fi
+AC_SUBST(JPEG2SWF)
+AC_SUBST(PNG2SWF)
 
+AC_OUTPUT(${FILES})
+
+if test "x${srcdir}" != "x."; then
+    echo "Warning: --srcdir is not supported"
+fi