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