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