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