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