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