a60f54e7e31910fee480bb83df2960c363b8133b
[swftools.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(src/)
3
4 AC_ARG_ENABLE(checkmem,
5 [  --enable-checkmem       turn on ccmalloc debugging], CHECKMEM=true)
6 AC_ARG_ENABLE(debug,
7 [  --enable-debug          turn on debugging], DEBUG=true)
8
9 PACKAGE=swftools
10 VERSION=0.5.0-pre4
11 # -Winline?
12
13 if test "x$CHECKMEM" '!=' "x";then
14     DEBUG=yes
15 fi
16 if test "x$DEBUG" '!=' "x";then
17     CFLAGS="-Wparentheses -Wimplicit -Wreturn-type -g $CFLAGS"
18     CXXFLAGS="-Wparentheses -Wimplicit -Wreturn-type -g $CXXFLAGS"
19     STRIP="@echo debug enabled, not stripping "
20     export STRIP
21     AC_SUBST(STRIP)
22 else
23     CFLAGS="-Wparentheses -Wimplicit -Wreturn-type -O -fomit-frame-pointer $CFLAGS"
24     CXXFLAGS="-Wparentheses -Wimplicit -Wreturn-type -O -fomit-frame-pointer $CXXFLAGS"
25 fi
26
27 export PACKAGE VERSION CFLAGS CXXFLAGS
28
29 dnl Checks for programs.
30  AC_CANONICAL_HOST
31 MACOSX=
32 case $host_os in
33     *darwin* ) 
34         MACOSX=yes
35         CFLAGS="$CFLAGS -fno-rtti"
36         CXXFLAGS="$CXXFLAGS -fno-rtti"
37         ;;
38 esac
39 dnl Checks for programs.
40  AC_PROG_CC
41  AC_PROG_CXX
42
43 if test "x$CHECKMEM" '!=' "x";then
44     CC="ccmalloc $CC"
45     CXX="ccmalloc $CXX"
46     #echo running again
47     #unset ac_cv_prog_CC
48     #unset ac_cv_prog_CXX
49     #AC_PROG_CC
50     #AC_PROG_CXX
51 fi
52  AC_PROG_CPP
53
54  AC_PROG_RANLIB
55  AC_PROG_MAKE_SET
56  AC_PROG_INSTALL
57  AC_PROG_LN_S
58  AC_PROG_LIBTOOL
59  AC_CHECK_PROGS(UNCOMPRESS, gzip uncompress compress, )
60
61 dnl Checks for system services
62  AC_EXEEXT
63
64 RFX_CHECK_MING
65
66 if test "x${MINGW}" != "xyes"; then
67     AC_DEFINE_UNQUOTED(O_BINARY, 0)
68 fi
69 # The following tries to make use of includes and libraries in
70 # /usr/local, too. Notice: A -I/usr/local/include might break
71 # things (MingW, cross-compiling etc.) in the same way as -I/usr/include, 
72 # especially on systems which link /usr/local to /usr, so it has yet
73 # to be seen how useful this is.
74 if test -d /usr/local/lib; then
75     LDFLAGS="$LDFLAGS -L/usr/local/lib"
76 fi
77 if test -d /usr/local/include; then
78 # Leave that alone. It's causing trouble e.g. with gcc 3.2 on gentoo.
79 #   CPPFLAGS="$CPPFLAGS -I/usr/local/include"
80     echo > /dev/null
81 fi
82 if test "$prefix" != "NONE" -a "$prefix" != "/usr/local" -a "$prefix" != "/usr/local/"; then
83     # if the user has a special prefix (like /opt), there might also be $prefix/lib
84     # and $prefix/include, which should be included in our search paths for libraries
85     # and includes.
86     LDFLAGS="$LDFLAGS -L${libdir}"
87     CPPFLAGS="$CPPFLAGS -I${includedir}"
88     # TODO- test whether gcc still works after this
89 fi
90
91 dnl Checks for libraries.
92  AC_CHECK_LIB(m, sin,, 
93  echo "Error: Math library not found.";
94  exit;
95  )
96  AC_CHECK_LIB(z, deflate,, 
97  DISABLEPNG2SWF=true;
98  MISSINGLIBS="${MISSINGLIBS} zlib"
99  ZLIBMISSING=true;
100  )
101  AC_CHECK_LIB(jpeg, jpeg_write_raw_data,, 
102  DISABLEPDF2SWF=true;
103  DISABLEJPEG2SWF=true;
104  MISSINGLIBS="${MISSINGLIBS} jpeglib"
105  )
106  AC_CHECK_LIB(t1, T1_LoadFont,,
107  DISABLEPDF2SWF=true;
108  MISSINGLIBS="${MISSINGLIBS} t1lib"
109  )
110
111 RFX_CHECK_BYTEORDER
112 AC_SUBST(WORDS_BIGENDIAN)
113 RFX_CHECK_SYSTEM_BACKTICKS
114 AC_SUBST(SYSTEM_BACKTICKS)
115
116 AC_ARG_PROGRAM
117
118 dnl Checks for header files.
119  AC_CONFIG_HEADER(config.h)
120  AC_HEADER_DIRENT
121  AC_HEADER_STDC
122  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)
123
124 if test "x${ac_cv_header_jpeglib_h}" != "xyes"; then
125  DISABLEPDF2SWF=true;
126  DISABLEJPEG2SWF=true;
127  MISSINGLIBS="${MISSINGLIBS} jpeglib.h"
128 fi
129 if test "x${ac_cv_header_t1lib_h}" != "xyes"; then
130  DISABLEPDF2SWF=true;
131  MISSINGLIBS="${MISSINGLIBS} t1lib.h"
132 fi
133 if test "x${ac_cv_header_zlib_h}" != "xyes"; then
134  DISABLEPNG2SWF=true;
135  MISSINGLIBS="${MISSINGLIBS} zlib.h"
136  ZLIBMISSING=true;
137 fi
138
139 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
140 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
141 AC_SUBST(PACKAGE)
142 AC_SUBST(VERSION)
143
144 AC_SUBST(HAVE_UNISTD_H)
145 AC_SUBST(EXEEXT)
146
147 dnl Checks for typedefs, structures, and compiler characteristics.
148  AC_C_CONST
149  AC_C_INLINE
150  AC_TYPE_OFF_T
151  AC_TYPE_SIZE_T
152  AC_STRUCT_TM
153  AC_CHECK_TYPE(boolean,int)
154  AC_CHECK_TYPE(bool,char)
155  dnl AC_CHECK_TYPE(uchar,unsigned char)
156  dnl AC_CHECK_TYPE(schar,signed char)
157  dnl AC_CHECK_TYPE(word,unsigned short int)
158  dnl AC_CHECK_TYPE(sword,unsigned short int)
159  dnl AC_CHECK_TYPE(uint,unsigned long int)
160
161 dnl Checks for library functions.
162  AC_CHECK_FUNCS(popen mkstemp stat lrand48 rand srand48 srand)
163  RFX_CHECK_AVI2SWF
164
165 avi2swf="avi2swf/Makefile"
166 if test "x${AVIFILE}" != "xtrue"; then
167  echo "* Couldn't compile the avifile test program."
168  echo "* Disabling avi2swf tool..."
169  echo all install uninstall clean: > avi2swf/Makefile
170  avi2swf=
171 fi
172
173 if test "x${UNCOMPRESS}" = "xgzip"; then
174     AC_DEFINE_UNQUOTED(USE_GZIP, 1)
175 fi
176 AC_SUBST(USE_GZIP)
177
178 JPEG2SWF='jpeg2swf' #$(EXEEXT)
179 export JPEG2SWF
180 PNG2SWF='png2swf' #$(EXEEXT)
181 export PNG2SWF
182 if test "x${DISABLEPDF2SWF}" = "xtrue"; then
183   echo "***************************************************"
184   echo "The following headers/libraries are missing: " ${MISSINGLIBS}
185   if test "x${DISABLEPDF2SWF}" = "xtrue"; then
186     echo "Disabling pdf2swf tool..."
187     rm -f pdf2swf/Makefile
188     echo all install uninstall clean: > pdf2swf/Makefile
189   fi
190   if test "x${DISABLEJPEG2SWF}" = "xtrue"; then
191     echo "Disabling jpeg2swf tool..."
192     JPEG2SWF=
193     export JPEG2SWF
194   fi
195   if test "x${DISABLEPNG2SWF}" = "xtrue"; then
196     echo "Disabling png2swf tool..."
197     PNG2SWF=
198     export PNG2SWF
199   fi
200   if test "x${ZLIBMISSING}" = "xtrue"; then
201     echo
202     echo "Warning! Without zlib, you will not be able to read"
203     echo "or write compressed Flash MX files!"
204   fi
205   echo "***************************************************"
206   FILES="./release Makefile.common ${avi2swf} Makefile lib/lame/Makefile lib/Makefile src/Makefile swfs/Makefile"
207 else
208   FILES="./release Makefile.common ${avi2swf} Makefile lib/lame/Makefile lib/Makefile src/Makefile pdf2swf/Makefile pdf2swf/xpdf/Makefile pdf2swf/ttf2pt1/Makefile swfs/Makefile"
209 fi
210 AC_SUBST(JPEG2SWF)
211 AC_SUBST(PNG2SWF)
212
213 AC_OUTPUT(${FILES})
214
215 if test "x${srcdir}" != "x."; then
216     echo "Warning: --srcdir is not supported"
217 fi