added checking for freetype.
[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-pre8
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  AC_CHECK_PROGS(FREETYPE_CONFIG, freetype-config, )
61
62 if test "x$FREETYPE_CONFIG" != "x";then
63     USE_FREETYPE=yes
64 fi
65
66 dnl Checks for system services
67  AC_EXEEXT
68
69 RFX_CHECK_MING
70
71 if test "x${MINGW}" != "xyes"; then
72     AC_DEFINE_UNQUOTED(O_BINARY, 0)
73 fi
74 # The following tries to make use of includes and libraries in
75 # /usr/local, too. Notice: A -I/usr/local/include might break
76 # things (MingW, cross-compiling etc.) in the same way as -I/usr/include, 
77 # especially on systems which link /usr/local to /usr, so it has yet
78 # to be seen how useful this is.
79 if test -d /usr/local/lib; then
80     LDFLAGS="$LDFLAGS -L/usr/local/lib"
81 fi
82 if test -d /usr/local/include; then
83 # Leave that alone. It's causing trouble e.g. with gcc 3.2 on gentoo.
84 #   CPPFLAGS="$CPPFLAGS -I/usr/local/include"
85     echo > /dev/null
86 fi
87 if test "$prefix" != "NONE" -a "$prefix" != "/usr/local" -a "$prefix" != "/usr/local/"; then
88     # if the user has a special prefix (like /opt), there might also be $prefix/lib
89     # and $prefix/include, which should be included in our search paths for libraries
90     # and includes.
91     LDFLAGS="$LDFLAGS -L${libdir}"
92     CPPFLAGS="$CPPFLAGS -I${includedir}"
93     # TODO- test whether gcc still works after this
94 fi
95
96 dnl Checks for libraries.
97  AC_CHECK_LIB(m, sin,, 
98  echo "Error: Math library not found.";
99  exit;
100  )
101  AC_CHECK_LIB(z, deflate,, 
102  DISABLEPNG2SWF=true;
103  MISSINGLIBS="${MISSINGLIBS} zlib"
104  ZLIBMISSING=true;
105  )
106  AC_CHECK_LIB(jpeg, jpeg_write_raw_data,, 
107  DISABLEPDF2SWF=true;
108  DISABLEJPEG2SWF=true;
109  MISSINGLIBS="${MISSINGLIBS} jpeglib"
110  )
111  AC_CHECK_LIB(t1, T1_LoadFont,,
112  DISABLEPDF2SWF=true;
113  MISSINGLIBS="${MISSINGLIBS} t1lib"
114  )
115  AC_CHECK_LIB(freetype, FT_Init_FreeType,
116  USE_FREETYPE=true,
117  )
118
119 RFX_CHECK_BYTEORDER
120 AC_SUBST(WORDS_BIGENDIAN)
121 RFX_CHECK_SYSTEM_BACKTICKS
122 AC_SUBST(SYSTEM_BACKTICKS)
123
124 AC_ARG_PROGRAM
125
126 dnl Checks for header files.
127  AC_CONFIG_HEADER(config.h)
128  AC_HEADER_DIRENT
129  AC_HEADER_STDC
130  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)
131
132 if test "x${ac_cv_header_jpeglib_h}" != "xyes"; then
133  DISABLEPDF2SWF=true;
134  DISABLEJPEG2SWF=true;
135  MISSINGLIBS="${MISSINGLIBS} jpeglib.h"
136 fi
137 if test "x${ac_cv_header_t1lib_h}" != "xyes"; then
138  DISABLEPDF2SWF=true;
139  MISSINGLIBS="${MISSINGLIBS} t1lib.h"
140 fi
141 if test "x${ac_cv_header_zlib_h}" != "xyes"; then
142  DISABLEPNG2SWF=true;
143  MISSINGLIBS="${MISSINGLIBS} zlib.h"
144  ZLIBMISSING=true;
145 fi
146
147 AC_DEFINE_UNQUOTED(USE_FREETYPE, "$USE_FREETYPE")
148 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
149 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
150 AC_SUBST(PACKAGE)
151 AC_SUBST(VERSION)
152
153 AC_SUBST(HAVE_UNISTD_H)
154 AC_SUBST(EXEEXT)
155
156 dnl Checks for typedefs, structures, and compiler characteristics.
157  AC_C_CONST
158  AC_C_INLINE
159  AC_TYPE_OFF_T
160  AC_TYPE_SIZE_T
161  AC_STRUCT_TM
162  AC_CHECK_TYPE(boolean,int)
163  AC_CHECK_TYPE(bool,char)
164  dnl AC_CHECK_TYPE(uchar,unsigned char)
165  dnl AC_CHECK_TYPE(schar,signed char)
166  dnl AC_CHECK_TYPE(word,unsigned short int)
167  dnl AC_CHECK_TYPE(sword,unsigned short int)
168  dnl AC_CHECK_TYPE(uint,unsigned long int)
169
170 dnl Checks for library functions.
171  AC_CHECK_FUNCS(popen mkstemp stat lrand48 rand srand48 srand)
172  RFX_CHECK_AVI2SWF
173
174 avi2swf="avi2swf/Makefile"
175 if test "x${AVIFILE}" != "xtrue"; then
176  echo "* Couldn't compile the avifile test program."
177  echo "* Disabling avi2swf tool..."
178  echo all install uninstall clean: > avi2swf/Makefile
179  avi2swf=
180 fi
181
182 if test "x${USE_FREETYPE}" == "xtrue"; then
183     if test "x{$FREETYPE_CONFIG}" != "x"; then
184         ftinclude=`freetype-config --cflags`
185         ftlibs=`freetype-config --libs`
186         CXXFLAGS="$CXXFLAGS $ftinclude"
187         CFLAGS="$CFLAGS $ftinclude"
188         LIBS="$LIBS $ftlibs"
189     else if test -d /usr/include/freetype2; then
190         CXXFLAGS="$CXXFLAGS -I/usr/include/freetype2"
191         CFLAGS="$CFLAGS -I/usr/include/freetype2"
192         LIBS="$LIBS -lfreetype"
193     else if test -d /usr/local/include/freetype2; then
194         CXXFLAGS="$CXXFLAGS -I/usr/local/include/freetype2"
195         CFLAGS="$CFLAGS -I/usr/local/include/freetype2"
196         LIBS="$LIBS -L /usr/local/lib -lfreetype"
197     fi
198     fi
199     fi
200 fi 
201
202 if test "x${UNCOMPRESS}" = "xgzip"; then
203     AC_DEFINE_UNQUOTED(USE_GZIP, 1)
204 fi
205 AC_SUBST(USE_GZIP)
206
207 JPEG2SWF='jpeg2swf' #$(EXEEXT)
208 export JPEG2SWF
209 PNG2SWF='png2swf' #$(EXEEXT)
210 export PNG2SWF
211 if test "x${DISABLEPDF2SWF}" = "xtrue"; then
212   echo "***************************************************"
213   echo "The following headers/libraries are missing: " ${MISSINGLIBS}
214   if test "x${DISABLEPDF2SWF}" = "xtrue"; then
215     echo "Disabling pdf2swf tool..."
216     rm -f pdf2swf/Makefile
217     echo all install uninstall clean: > pdf2swf/Makefile
218   fi
219   if test "x${DISABLEJPEG2SWF}" = "xtrue"; then
220     echo "Disabling jpeg2swf tool..."
221     JPEG2SWF=
222     export JPEG2SWF
223   fi
224   if test "x${DISABLEPNG2SWF}" = "xtrue"; then
225     echo "Disabling png2swf tool..."
226     PNG2SWF=
227     export PNG2SWF
228   fi
229   if test "x${ZLIBMISSING}" = "xtrue"; then
230     echo
231     echo "Warning! Without zlib, you will not be able to read"
232     echo "or write compressed Flash MX files!"
233   fi
234   echo "***************************************************"
235   FILES="./release Makefile.common ${avi2swf} Makefile lib/lame/Makefile lib/Makefile src/Makefile swfs/Makefile"
236 else
237   FILES="./release Makefile.common ${avi2swf} Makefile lib/lame/Makefile lib/Makefile src/Makefile pdf2swf/Makefile pdf2swf/xpdf/Makefile pdf2swf/ttf2pt1/Makefile swfs/Makefile"
238 fi
239 AC_SUBST(JPEG2SWF)
240 AC_SUBST(PNG2SWF)
241
242 AC_OUTPUT(${FILES})
243
244 if test "x${srcdir}" != "x."; then
245     echo "Warning: --srcdir is not supported"
246 fi