1dnl Process this file with autoconf to create configure.
2
3AC_INIT
4AC_CONFIG_SRCDIR([src/ferite.c])
5AM_INIT_AUTOMAKE(ferite, 1.0.2)
6AM_CONFIG_HEADER(config.h)
7
8AC_PROG_CC
9AM_PROG_CC_STDC
10AC_C_CONST
11
12AC_PATH_PROG(unamepath, uname)
13if test "_$unamepath" = _; then
14   system="unknown"
15else
16   AC_MSG_CHECKING(system type)
17   system=`$unamepath -s`
18   AC_MSG_RESULT($system)
19   if test "$system" = "Linux"; then
20	  AC_DEFINE([USING_LINUX], 1, [We Are Using Linux])
21   fi
22   if test "$system" = "FreeBSD"; then
23	  AC_DEFINE([USING_FREEBSD], 1, [We Are Using FreeBSD])
24   fi
25   if test "$system" = "SunOS"; then
26      AC_DEFINE([USING_SOLARIS], 1, [We Are Using Solaris])
27   fi
28   if test "$system" = "Darwin"; then
29      AC_DEFINE([USING_DARWIN], 1, [We Are Using darwin - the unix part of MacOSX])
30   fi
31   if test "$system" = "OpenBSD"; then
32      AC_DEFINE([USING_OPENBSD], 1, [We Are Using OpenBSD])
33   fi
34   if test "$system" = "NetBSD"; then
35      AC_DEFINE([USING_NETBSD], 1, [We Are Using NetBSD])
36   fi
37
38   cygwin=`$unamepath -s | cut -c 1-6`
39   if test "$cygwin" = "CYGWIN"; then
40      AC_DEFINE([USING_CYGWIN], 1, [We Are Using CygWin])
41	  system="CYGWIN"
42   fi
43   mingw=`$unamepath -s | cut -c 1-5`
44   if test "$mingw" = "MINGW"; then
45	  AC_DEFINE([USING_MINGW], 1, [We Are Using MinGW])
46	  system="MINGW"
47   fi
48
49   machinetype=`$unamepath -m`
50   AC_MSG_CHECKING(machine type)
51   AC_MSG_RESULT($machinetype)
52   AC_DEFINE_UNQUOTED([MACH_TYPE], "$machinetype", [The machine type we are building on])
53
54   machineos=`$unamepath -s`
55   AC_MSG_CHECKING(operating system)
56   AC_MSG_RESULT($machineos)
57   AC_DEFINE_UNQUOTED([OS_NAME], "$machineos", [The os we are running on])
58
59   machinever=`$unamepath -r`
60   AC_MSG_CHECKING(opertating system version)
61   AC_MSG_RESULT($machinever)
62   AC_DEFINE_UNQUOTED([OS_RELEASE], "$machinever", [The release verison of the os])
63fi
64
65if test "x$prefix" = "xNONE"; then
66  prefix="/usr/local"
67else
68  prefix=$prefix
69fi
70
71AC_CANONICAL_HOST
72#dnl platform=`$unamepath -s -m | sed -e "s/ /-/g;"`
73platform="$host_os-$host_cpu"
74AC_MSG_CHECKING(platform)
75AC_MSG_RESULT($platform)
76AC_DEFINE_UNQUOTED([PLATFORM], "$platform", [The Platform on which we exist])
77
78AM_CONDITIONAL(NEED_FERITE_LIB, test "$system" = "Darwin" -o "$system" = "CYGWIN" -o "$system" = "SunOS" -o "$system" = "MINGW" )
79
80CFLAGS="-DHAVE_CONFIG_HEADER $CFLAGS"
81CCFLAGS="-DHAVE_CONFIG_HEADER $CCFLAGS"
82
83AC_PROG_INSTALL
84AC_PROG_MAKE_SET
85
86AM_ENABLE_SHARED
87AM_PROG_LIBTOOL
88
89AC_MSG_CHECKING( for debug support )
90AC_ARG_ENABLE( debug,
91  [  --enable-debug          enable debuging within ferite [default=no]],
92  echo "yes"; debugdefs="-DDEBUG";
93  echo "**************************************************";
94  echo "* DEBUG SUPPORT IS DESIGNED TO HELP TRACK ERRORS *";
95  echo "* WITHIN THE FERITE ENGINE. IT SLOWS DOWN FERITE *";
96  echo "* CONSIDERABLY. CONSIDER ONLY FOR DEVELOPERS OF  *";
97  echo "* THE FERITE ENGINE                              *";
98  echo "**************************************************";
99  AC_DEFINE([DEBUG], 1, [Whether we are compiling ferite in debug mode])
100  ,
101  echo "no";  debugdefs="")
102
103AC_MSG_CHECKING( for x86 profiler support )
104AC_ARG_ENABLE( x86-profile,
105  [  --enable-x86-profile    enable x86 profiling within ferite [default=no]],
106  echo "yes"; debugdefs="$debugdefs -DUSE_X86_PROFILER",
107  echo "no";)
108
109AC_MSG_CHECKING( whether to autoload core modules )
110AC_ARG_ENABLE( autoload-core,
111  [  --enable-autoload-core  enable the loading of core modules automatically],
112  echo "no",
113  echo "yes"; debugdefs="$debugdefs -DAUTOLOAD_CORE")
114
115AC_SUBST(debugdefs)
116
117AC_CHECK_LIB(xml2, xmlParseDocument,
118  [gotxml=yes],
119  [gotxml=no;
120   echo "Cannot find libXML2: xml support is required, please install libxml2 from http://xmlsoft.org";
121   exit],)
122
123AC_ARG_WITH(pcre,
124        [  --with-pcre=DIR         use pcre in <DIR>],
125           PATH=$PATH:$withval/bin)
126
127AC_CHECK_PROG(LIBPCRE_CONFIG, pcre-config, pcre-config, false)
128
129if test "$LIBPCRE_CONFIG" = "false"; then
130   echo "ERROR: Could not find pcre-config in your path.";
131   echo "       You need PCRE to compile Ferite.";
132   echo "       Debian: apt-get install libpcre3 libpcre3-dev";
133   echo "       Source: http://www.pcre.org";
134   exit;
135   :
136fi
137
138AC_MSG_CHECKING([for pcre libs])
139pcre_libs=`pcre-config --libs`
140AC_MSG_RESULT($pcre_libs)
141AC_MSG_CHECKING([for pcre cflags])
142pcre_cflags=`pcre-config --cflags`
143AC_MSG_RESULT($pcre_cflags)
144AC_SUBST(pcre_libs)
145AC_SUBST(pcre_cflags)
146
147thread_libs=""
148thread_defs=""
149for thread_lib in pthread pthread32 pthreads c_r thread dce pthreadGC2; do
150    AC_CHECK_LIB($thread_lib, pthread_mutex_lock, FOUND_PTHREAD=1,FOUND_PTHREAD=0,)
151    if test "$FOUND_PTHREAD" -eq 1; then
152        thread_libs="-l$thread_lib"
153        thread_defs="-D_REENTRANT -DUSE_PTHREAD"
154        break;
155    fi
156done
157
158if test "$FOUND_PTHREAD" -ne 1; then
159   echo "";
160   echo "ERROR: ferite neeeds the pthread library"
161   echo "";
162   AC_MSG_ERROR(ERROR: pthread library not found)
163fi
164
165AC_MSG_CHECKING( for thread safety )
166AC_ARG_ENABLE( thread-safe,
167  [  --enable-thread-safe    enable thread safety within ferite [default=yes]],
168  [
169    if test "$enableval" != "no"; then
170	  thread_defs="$thread_defs -DTHREAD_SAFE"
171	  AC_MSG_RESULT(yes)
172	else
173	  AC_MSG_RESULT(no)
174	fi
175  ],
176  [
177    AC_MSG_RESULT(yes)
178	thread_defs="$thread_defs -DTHREAD_SAFE"
179  ]
180)
181
182AC_SUBST(thread_libs)
183AC_SUBST(thread_defs)
184
185sinclude(modules-config.m4)
186sinclude(libs/triton/config.m4)
187sinclude(libs/aphex/config.m4)
188
189FE_LIBRARY_PATH="$prefix/lib/ferite"
190AC_DEFINE_UNQUOTED([LIBRARY_DIR], "$FE_LIBRARY_PATH", [Ferites library path])
191AC_SUBST(FE_LIBRARY_PATH)
192
193FE_XPLAT_LIBRARY_PATH="$FE_LIBRARY_PATH/module-source"
194AC_DEFINE_UNQUOTED(XPLAT_LIBRARY_DIR, "$FE_XPLAT_LIBRARY_PATH", [Ferites cross platform library path])
195AC_SUBST(FE_XPLAT_LIBRARY_PATH)
196
197FE_NATIVE_LIBRARY_PATH="$FE_LIBRARY_PATH/module-native/$platform"
198AC_DEFINE_UNQUOTED(NATIVE_LIBRARY_DIR, "$FE_NATIVE_LIBRARY_PATH", [Ferites native library path])
199AC_SUBST(FE_NATIVE_LIBRARY_PATH)
200
201#dnl This is for builder's generated Makefile.am's
202BUILDER="\$(top_builddir)/builder/builder"
203AC_SUBST(BUILDER)
204MODULE_SRC_PREFIX="\$(top_srcdir)/modules"
205AC_SUBST(MODULE_SRC_PREFIX)
206
207AC_CONFIG_FILES([ferite-config \
208 ferite.spec \
209 Makefile \
210 libs/Makefile \
211 libs/aphex/Makefile \
212 libs/aphex/include/Makefile \
213 libs/aphex/src/Makefile \
214 libs/triton/Makefile \
215 libs/triton/include/Makefile \
216 libs/triton/src/Makefile \
217 test/Makefile \
218 docs/Makefile \
219 docs/images/Makefile \
220 src/Makefile \
221 builder/Makefile \
222 include/Makefile \
223 include/ferite/Makefile \
224 scripts/Makefile \
225 scripts/cgi/Makefile \
226 scripts/test/Makefile \
227 scripts/test/rmi/Makefile \
228 scripts/test-suite/Makefile \
229 tools/Makefile \
230 tools/generate-module/Makefile \
231 tools/generate-module/generate-module \
232 tools/doc/Makefile \
233 tools/doc/feritedoc \
234 tools/doc/template/Makefile \
235 tools/doc/template/html/Makefile \
236 tools/farm/Makefile \
237 tools/farm/rulesets/Makefile \
238 tools/farm/farm \
239 tools/manual-builder/Makefile \
240 tools/manual-builder/ManualBuilder/Makefile \
241 tools/manual-builder/ManualBuilder/Filters/Makefile \
242 tools/manual-builder/ManualBuilder/Support/Makefile \
243 tools/manual-builder/ManualBuilder/Support/Images/Makefile \
244 tools/manual-builder/ManualBuilder/Support/CSS/Makefile \
245 tools/manual-builder/manual-builder-html \
246 tools/manual-builder/manual-builder-pdf \
247 modules/Makefile \
248 modules/array/Makefile \
249modules/console/Makefile \
250modules/date/Makefile \
251modules/filesystem/Makefile \
252modules/ipc/Makefile \
253modules/math/Makefile \
254modules/network/Makefile \
255modules/posix/Makefile \
256modules/reflection/Makefile \
257modules/regexp/Makefile \
258modules/rmi/Makefile \
259modules/rmi/rmi/Makefile \
260modules/rmi/rmi/protocol/Makefile \
261modules/rmi/rmi/translation/Makefile \
262modules/rmi/rmi/transport/Makefile \
263modules/serialize/Makefile \
264modules/stream/Makefile \
265modules/string/Makefile \
266modules/sys/Makefile \
267modules/test/Makefile \
268modules/thread/Makefile \
269modules/unix/Makefile \
270modules/xml/Makefile \
271])
272
273AC_CONFIG_COMMANDS([default],[[
274 chmod +x ferite-config
275 chmod +x tools/doc/feritedoc
276 chmod +x tools/farm/farm
277 chmod +x tools/generate-module/generate-module
278 chmod +x tools/manual-builder/manual-builder-html
279 chmod +x tools/manual-builder/manual-builder-pdf
280]],[[]])
281AC_OUTPUT
282