releasing package mimetic version 0.9.8-10 into distribution unstable
[debian/mimetic.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_REVISION($Revision: 1.38 $)
3 AC_INIT(mimetic/mimetic.h)
4 AC_CANONICAL_SYSTEM
5 AC_CONFIG_MACRO_DIR([m4])
6
7 AM_INIT_AUTOMAKE(mimetic,0.9.8)
8 AM_CONFIG_HEADER(mimetic/config.h)
9
10 dnl Checks for programs.
11 AC_PROG_CC
12 AC_PROG_MAKE_SET
13 AC_PROG_LIBTOOL
14
15 dnl defines HAVE_MMAP if mmapping works
16 AC_FUNC_MMAP
17 AC_CHECK_FUNCS(madvise)
18
19 AC_PROG_CXX
20 AC_PROG_CXXCPP
21
22 AC_PROG_INSTALL
23
24 AC_LANG_CPLUSPLUS
25
26 INCLUDEDIR=$includedir/mimetic
27
28 debug_enabled=false
29
30 dnl CFLAGS and CXXFLAGS default to -O2 -g
31
32 dnl CXXFLAGS="$CXXFLAGS -DNDEBUG -fno-exceptions"
33 CXXFLAGS="$CXXFLAGS -DNDEBUG"
34
35 AC_ARG_ENABLE(debug,
36   [  --enable-debug[=LEVEL]  enables debug symbols [default=2]],
37   if test "$enableval" = "yes"; then
38     debug_enabled=true
39     CXXFLAGS="-g -Wall"
40   else
41     if test "$enableval" != "no"; then
42       debug_enabled=true
43       CXXFLAGS="-g$enableval -Wall"
44     fi
45   fi
46   )
47
48 AC_ARG_ENABLE(profile,
49   [  --enable-profile        enables profiling],
50   if test "$enableval" = "yes"; then
51     CXXFLAGS="$CXXFLAGS -pg -a"
52   fi
53   )
54
55 dnl *** Checks for libraries.
56
57 AC_ARG_WITH(stlport,
58   [  --with-stlport[=BASEDIR]       use STLport],
59   enable_stlport="yes"
60   dnl STLport base dir
61   if test "$withval" != "no"; then
62       if test $withval != "yes"; then
63
64           with_stlport_basedir=$withval
65       with_stlport_includes=${withval}/include/stlport
66           with_stlport_libraries=${withval}/lib
67       fi
68   fi
69   , enable_stlport=no)
70
71 AC_ARG_WITH(stlport-includes, 
72   [  --with-stlport-includes=DIR    where the STLport includes are ],
73   [with_stlport_includes=$withval])
74
75 AC_ARG_WITH(stlport-libraries, 
76   [  --with-stlport-libraries=DIR   where STLport library is installed],
77   [with_stlport_libraries=$withval])
78
79 AC_ARG_WITH(stlport-libname, 
80   [  --with-stlport-libname=NAME    STLport lib base name],
81   [with_stlport_libname=$withval])
82
83 dnl AC_ARG_WITH(stlport-debug, 
84 dnl  [  --with-stlport-debug    STLport debug mode on/off.[default: on with --enable-debug off otherwise],
85 dnl  [  with_stlport_libname=${with_stlport_libname}_stldebug  ])
86
87 if test "$enable_stlport" = "yes"; then
88   dnl ** debug enabled ?
89   if test "$debug_enabled" = "true"; then
90     CXXFLAGS="$CXXFLAGS -D_STLP_DEBUG"
91   fi
92   dnl *** STLport include dir
93   if test "$with_stlport_includes"; then
94     AC_CHECK_HEADER(${with_stlport_includes}/stl_user_config.h,
95                      stlp_headers_found=true)
96   else
97     stlp_include_dirs="/usr/local/include/stlport /usr/include/stlport"
98     for stlp_inc in $stlp_include_dirs; do
99       AC_CHECK_HEADER(${stlp_inc}/stl_user_config.h,
100                       with_stlport_includes=$stlp_inc
101               export stlp_headers_found=true
102               break) 
103     done
104   fi
105
106   if test "$stlp_headers_found" != "true"; then
107     AC_MSG_ERROR([I'm unable to find STLport include directory])
108   fi
109   
110   if test "$with_stlport_libraries"; then
111     stlp_ldflags="$stlp_ldflags -L${with_stlport_libraries}"
112   fi
113   
114   dnl *** STLport library(it must be linked with libm & libpthread on linux...
115   AC_CHECK_LIB(m, main,stlp_ldflags="$stlp_ldflags -lm")
116   case "$host_os" in
117     freebsd*) 
118         stlp_ldflags="$stlp_ldflags -pthread";;
119     *netbsd*) 
120     stlp_ldflags="$stlp_ldflags -L/usr/libexec -lm"
121     ;;
122     *) stlp_ldflags="$stlp_ldflags -lpthread"
123        AC_CHECK_LIB(pthread, main,stlp_ldflags="$stlp_ldflags -lpthread")
124     ;;
125   esac
126   
127   if test "$with_stlport_libname"; then
128     AC_CHECK_LIB($with_stlport_libname,main,stlp_lib_found=true,,
129                  [$stlp_ldflags])
130   else
131     dnl *** try to get stlport library name 
132     stlp_libs="stlport_gcc stlport_icl stlport_cygwin stlport_dec \
133        stlport_djgpp stlport_mingw32 stlport_aCC stlport_kcc stlport_misppro \
134        stlport_sunpro stlport_vc5 stlport_vc6 stlport_vc7 stlport_watcom"
135     for stlp_libname in $stlp_libs; do 
136       test "$debug_enabled" = "true" && stlp_libname=${stlp_libname}_debug
137       AC_CHECK_LIB($stlp_libname, main,
138         with_stlport_libname=$stlp_libname
139     stlp_lib_found=true
140     break,
141       ,[$stlp_ldflags])
142     done
143   fi
144
145   if test "$stlp_lib_found" != "true"; then
146       AC_MSG_ERROR([I'm unable to find STLport library. You must call configure
147                     with the --with-stlport-libname option])
148   fi
149   stlp_ldflags="$stlp_ldflags -l$with_stlport_libname"
150   CXXFLAGS="$CXXFLAGS -I$with_stlport_includes"
151   LDFLAGS="$LDFLAGS ${stlp_ldflags}"
152 fi
153
154 CXXFLAGS="$CXXFLAGS -DHAVE_MIMETIC_CONFIG"
155 CFLAGS="$CXXFLAGS"
156
157 dnl ** check for STL required features
158  AC_MSG_CHECKING([STL required features])
159  AC_TRY_COMPILE([#include <string>],
160       [using namespace std; char_traits<char>::eq('a','a');],
161       ,
162       AC_MSG_ERROR([std::char_traits unsupported])
163       )
164 AC_TRY_COMPILE([#include <streambuf>],
165       [using namespace std; struct sbd:public streambuf {} msb;],
166       ,
167       AC_MSG_ERROR([std::streambuf unsupported])
168       )
169 AC_MSG_RESULT([yes])
170
171
172 dnl Checks for typedefs, structures, and compiler characteristics.
173 AC_TYPE_SIZE_T
174 AC_TYPE_OFF_T
175 AC_TYPE_UID_T
176
177 AC_HEADER_DIRENT
178 AC_CHECK_HEADERS(sys/stat.h)
179 AC_CHECK_HEADERS(sys/types.h)
180 AC_CHECK_HEADERS(sys/time.h)
181 AC_CHECK_HEADERS(stdint.h)
182
183 AC_SUBST(PACKAGE)
184 AC_SUBST(VERSION)
185 AC_SUBST(INCLUDEDIR)
186
187 AC_OUTPUT(Makefile          \
188     mimetic/Makefile        \
189     mimetic/codec/Makefile  \
190     mimetic/rfc822/Makefile \
191     mimetic/os/Makefile     \
192     mimetic/parser/Makefile \
193     test/Makefile           \
194     examples/Makefile       \
195     doc/Makefile            \
196     doc/doxygen.config      \
197     win32/Makefile)