99ab70e3edd3fd6f8b216e260afa11bd4669d2c0
[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(optimizations,
9 [  --enable-optimizations  turn on compiler optimizations (recommended for avi2swf)], OPTIMIZE=true)
10 AC_ARG_ENABLE(mp3,
11 [  --disable-mp3           don't compile any mp3 code in], NO_MP3=true)
12
13 PACKAGE=swftools
14 VERSION=2004-02-01-1614
15
16
17
18
19 # -Winline?
20
21 if test "x$CHECKMEM" '!=' "x";then
22     DEBUG=yes
23 fi
24 if test "x$DEBUG" '!=' "x";then
25     CFLAGS="-Wparentheses -Wimplicit -Wreturn-type -g $CFLAGS"
26     CXXFLAGS="-Wparentheses -Wimplicit -Wreturn-type -g $CXXFLAGS"
27     STRIP="@echo debug enabled, not stripping "
28     export STRIP
29     AC_SUBST(STRIP)
30 else if test "x$OPTIMIZE" '!=' "x"; then
31         CFLAGS="-Wparentheses -Wimplicit -Wreturn-type -Winline -O3 -fomit-frame-pointer $CFLAGS"
32         CXXFLAGS="-Wparentheses -Wimplicit -Wreturn-type -Winline -O3 -fomit-frame-pointer $CXXFLAGS"
33      else
34         CFLAGS="-Wparentheses -Wimplicit -Wreturn-type -O -fomit-frame-pointer $CFLAGS"
35         CXXFLAGS="-Wparentheses -Wimplicit -Wreturn-type -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  AC_CHECK_PROGS(FREETYPE_CONFIG, freetype-config, ) # TODO: use this
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 dnl Checks for libraries.
112  AC_CHECK_LIB(m, sin,, 
113  echo "Error: Math library not found.";
114  exit;
115  )
116  AC_CHECK_LIB(z, deflate,, 
117  DISABLEPNG2SWF=true;
118  MISSINGLIBS="${MISSINGLIBS} zlib"
119  ZLIBMISSING=true;
120  )
121  AC_CHECK_LIB(jpeg, jpeg_write_raw_data,, 
122  DISABLEPDF2SWF=true;
123  DISABLEJPEG2SWF=true;
124  MISSINGLIBS="${MISSINGLIBS} jpeglib"
125  )
126  AC_CHECK_LIB(t1, T1_LoadFont,,
127  DISABLEPDF2SWF=true;
128  MISSINGLIBS="${MISSINGLIBS} t1lib"
129  )
130  AC_CHECK_LIB(freetype, FT_Init_FreeType,
131  USE_FREETYPE=true,
132  )
133
134 RFX_CHECK_BYTEORDER
135 AC_SUBST(WORDS_BIGENDIAN)
136 RFX_CHECK_SYSTEM_BACKTICKS
137 AC_SUBST(SYSTEM_BACKTICKS)
138
139 AC_ARG_PROGRAM
140
141 dnl Checks for header files.
142  AC_CONFIG_HEADER(config.h)
143  AC_HEADER_DIRENT
144  AC_HEADER_STDC
145  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)
146
147 if test "x${ac_cv_header_jpeglib_h}" != "xyes"; then
148  DISABLEPDF2SWF=true;
149  DISABLEJPEG2SWF=true;
150  MISSINGLIBS="${MISSINGLIBS} jpeglib.h"
151 fi
152 if test "x${ac_cv_header_t1lib_h}" != "xyes"; then
153  DISABLEPDF2SWF=true;
154  MISSINGLIBS="${MISSINGLIBS} t1lib.h"
155 fi
156 if test "x${ac_cv_header_zlib_h}" != "xyes"; then
157  DISABLEPNG2SWF=true;
158  MISSINGLIBS="${MISSINGLIBS} zlib.h"
159  ZLIBMISSING=true;
160 fi
161
162 if test "x$USE_FREETYPE" != "x"; then
163     AC_DEFINE_UNQUOTED(USE_FREETYPE, "$USE_FREETYPE")
164 fi
165 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
166 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
167 AC_SUBST(PACKAGE)
168 AC_SUBST(VERSION)
169
170 AC_SUBST(HAVE_UNISTD_H)
171 AC_SUBST(EXEEXT)
172
173 dnl Checks for typedefs, structures, and compiler characteristics.
174  AC_C_CONST
175  AC_C_INLINE
176  AC_TYPE_OFF_T
177  AC_TYPE_SIZE_T
178  AC_STRUCT_TM
179  AC_CHECK_TYPE(boolean,int)
180  AC_CHECK_TYPE(bool,char)
181  dnl AC_CHECK_TYPE(uchar,unsigned char)
182  dnl AC_CHECK_TYPE(schar,signed char)
183  dnl AC_CHECK_TYPE(word,unsigned short int)
184  dnl AC_CHECK_TYPE(sword,unsigned short int)
185  dnl AC_CHECK_TYPE(uint,unsigned long int)
186
187 dnl Checks for library functions.
188  AC_CHECK_FUNCS(popen mkstemp stat lrand48 rand srand48 srand bcopy bzero)
189  RFX_CHECK_AVI2SWF
190
191 avi2swf="avi2swf/Makefile"
192 if test "x${AVIFILE}" != "xtrue"; then
193  echo "* Couldn't compile the avifile test program."
194  echo "* Disabling avi2swf tool..."
195  echo all install uninstall clean: > avi2swf/Makefile
196  avi2swf=
197 fi
198
199 if test "x${NO_MP3}" == "x"; then
200     AC_DEFINE_UNQUOTED(USE_MP3, 1)
201 fi
202
203 if test "x${USE_FREETYPE}" == "xtrue"; then
204     if test "x{$FREETYPE_CONFIG}" != "x"; then
205         ftinclude=`freetype-config --cflags`
206         ftlibs=`freetype-config --libs`
207         CXXFLAGS="$CXXFLAGS $ftinclude"
208         CFLAGS="$CFLAGS $ftinclude"
209         LIBS="$LIBS $ftlibs"
210     else if test -d /usr/include/freetype2; then
211         CXXFLAGS="$CXXFLAGS -I/usr/include/freetype2"
212         CFLAGS="$CFLAGS -I/usr/include/freetype2"
213         LIBS="$LIBS -lfreetype"
214     else if test -d /usr/local/include/freetype2; then
215         CXXFLAGS="$CXXFLAGS -I/usr/local/include/freetype2"
216         CFLAGS="$CFLAGS -I/usr/local/include/freetype2"
217         LIBS="$LIBS -L /usr/local/lib -lfreetype"
218     fi
219     fi
220     fi
221 fi 
222
223 if test "x${UNCOMPRESS}" = "xgzip"; then
224     AC_DEFINE_UNQUOTED(USE_GZIP, 1)
225 fi
226 AC_SUBST(USE_GZIP)
227
228 JPEG2SWF='jpeg2swf$(E)'
229 export JPEG2SWF
230 PNG2SWF='png2swf$(E)'
231 export PNG2SWF
232 if test "x${DISABLEPDF2SWF}" = "xtrue"; then
233   echo "***************************************************"
234   echo "The following headers/libraries are missing: " ${MISSINGLIBS}
235   if test "x${DISABLEPDF2SWF}" = "xtrue"; then
236     echo "Disabling pdf2swf tool..."
237     rm -f pdf2swf/Makefile
238     echo all install uninstall clean: > pdf2swf/Makefile
239   fi
240   if test "x${DISABLEJPEG2SWF}" = "xtrue"; then
241     echo "Disabling jpeg2swf tool..."
242     JPEG2SWF=
243     export JPEG2SWF
244   fi
245   if test "x${DISABLEPNG2SWF}" = "xtrue"; then
246     echo "Disabling png2swf tool..."
247     PNG2SWF=
248     export PNG2SWF
249   fi
250   if test "x${ZLIBMISSING}" = "xtrue"; then
251     echo
252     echo "Warning! Without zlib, you will not be able to read"
253     echo "or write compressed Flash MX files!"
254   fi
255   echo "***************************************************"
256   FILES="./release Makefile.common ${avi2swf} Makefile lib/lame/Makefile lib/Makefile src/Makefile swfs/Makefile"
257 else
258   FILES="./release Makefile.common ${avi2swf} Makefile lib/lame/Makefile lib/Makefile src/Makefile pdf2swf/Makefile pdf2swf/xpdf/Makefile pdf2swf/ttf2pt1/Makefile swfs/Makefile"
259 fi
260 AC_SUBST(JPEG2SWF)
261 AC_SUBST(PNG2SWF)
262
263 AC_OUTPUT(${FILES})
264
265 if test "x${srcdir}" != "x."; then
266     echo "Warning: --srcdir is not supported"
267 fi