1 dnl Process this file with autoconf to produce a configure script.
3 dnl Copyright 2007 Johannes Lehtinen
4 dnl This configure.ac script is free software; Johannes Lehtinen gives
5 dnl unlimited permission to copy, distribute and modify it.
7 dnl Version information
8 dnl -------------------
10 dnl Version information
11 define(CP_M4_VERSION_MAJOR, [0])
12 define(CP_M4_VERSION_MINOR, [1])
13 define(CP_M4_VERSION_REV, [3])
14 define(CP_M4_RELEASE_VERSION, CP_M4_VERSION_MAJOR.CP_M4_VERSION_MINOR.CP_M4_VERSION_REV)
16 dnl Backwards compatibility information
17 define(CP_M4_ABI_COMPATIBILITY, [0.1])
19 dnl Library version information
20 define(CP_M4_C_LIB_VERSION, [0:3:0])
21 define(CP_M4_CXX_LIB_VERSION, [0:0:0])
23 # Autoconf initialization
24 # -----------------------
25 AC_INIT([C-Pluff], CP_M4_RELEASE_VERSION, [johannes.lehtinen@iki.fi], [cpluff])
26 AC_COPYRIGHT([Copyright 2007 Johannes Lehtinen
27 This configure script is free software; Johannes Lehtinen gives unlimited
28 permission to copy, distribute and modify it.])
29 AC_CONFIG_SRCDIR([libcpluff/cpluff.h])
30 AC_CONFIG_AUX_DIR([auxliary])
31 AC_CONFIG_HEADERS([config.h])
35 CP_VERSION_MAJOR=CP_M4_VERSION_MAJOR
36 CP_VERSION_MINOR=CP_M4_VERSION_MINOR
37 AC_DEFINE([CP_ABI_COMPATIBILITY], "CP_M4_ABI_COMPATIBILITY", [The earliest ABI compatible version or undefined])
38 CP_C_LIB_VERSION=CP_M4_C_LIB_VERSION
39 CP_CXX_LIB_VERSION=CP_M4_CXX_LIB_VERSION
40 AC_SUBST([CP_VERSION_MAJOR])
41 AC_SUBST([CP_VERSION_MINOR])
42 AC_SUBST([CP_C_LIB_VERSION])
43 AC_SUBST([CP_CXX_LIB_VERSION])
45 # Automake initialization
46 # -----------------------
47 AM_INIT_AUTOMAKE([foreign])
48 AM_GNU_GETTEXT([external])
49 AM_GNU_GETTEXT_VERSION([0.16.1])
51 # C/C++ compiler settings
55 if test -z "$CC"; then
56 AC_MSG_ERROR([C compiler was not found (required)])
69 CPPFLAGS="$CPPFLAGS -I\$(top_builddir)"
71 # For cpluff.h and cpluffdef.h
72 CPPFLAGS="$CPPFLAGS -I\$(top_builddir)/libcpluff -I\$(top_srcdir)/libcpluff"
74 # Substitute variables for libcpluff and non-libcpluff components
75 AC_SUBST([LIBS_LIBCPLUFF])
76 AC_SUBST([LIBS_OTHER])
78 # Define shared library extension
79 # -------------------------------
80 AC_DEFINE_UNQUOTED([CP_SHREXT], ["$shrext_cmds"], [Shared library extension])
82 # Thread support checks
83 # ---------------------
86 AC_ARG_ENABLE([threads], AS_HELP_STRING([--enable-threads@<:@=TYPE@:>@], [enable multi-threading support (supported TYPEs are "Posix" and "Windows", default is to check support in this order)]))
87 case "$enable_threads" in
89 # Use the default auto detection
93 # Ok, legal value, no action needed
96 AC_MSG_ERROR([$enable_threads threads not supported])
100 # Only check for different thread types if threading not disabled
102 if test "$enable_threads" != no; then
104 # Check for Posix thread support
105 if test -z "$cp_threads" && \
106 ( test -z "$enable_threads" || test "$enable_threads" = Posix ); then
107 AC_MSG_CHECKING([for Posix threads])
109 [#include <pthread.h>
111 int main(int argc, char *argv[]) {
112 pthread_mutex_t mutex;
114 pthread_mutex_init(&mutex, NULL);
117 ], [AC_MSG_RESULT([yes])
118 cp_threads=Posix], AC_MSG_RESULT([no]))
121 # Check for Windows thread suppport
122 if test -z "$cp_threads" && \
123 ( test -z "$enable_threads" || test "$enable_threads" = Windows ); then
124 AC_MSG_CHECKING([for Windows threads])
126 [#include <windows.h>
128 int main(int argc, char *argv[]) {
129 CreateMutex(NULL, FALSE, NULL);
132 ], [AC_MSG_RESULT([yes])
133 cp_threads=Windows], AC_MSG_RESULT([no]))
136 # Check if we got the desired thread support
137 if test -n "$enable_threads" && test "$enable_threads" != "$cp_threads"; then
138 AC_MSG_ERROR([$enable_threads threads not detected])
143 if test -z "$cp_threads" && test "$enable_threads" != no; then
144 AC_MSG_WARN([multi-threading support not detected])
147 if test -n "$cp_threads"; then
148 AC_DEFINE_UNQUOTED([CP_THREADS], ["$cp_threads"], [Multi-threading support type])
150 AM_CONDITIONAL([POSIX_THREADS], test "$cp_threads" = Posix)
151 AM_CONDITIONAL([WINDOWS_THREADS], test "$cp_threads" = Windows)
153 # Check for the dlopen mechanism (Posix dlopen or GNU Libtool libltdl)
154 # --------------------------------------------------------------------
155 AC_ARG_WITH([dlopen],
156 AS_HELP_STRING([--with-dlopen],
157 [use the Posix dlopen facility]))
158 AC_ARG_WITH([libltdl],
159 AS_HELP_STRING([--with-libltdl],
160 [use the GNU Libtool libltdl]))
161 if test "$with_dlopen" = yes && test "$with_libltdl" = yes; then
162 AC_MSG_ERROR([Can not use both Posix dlopen and GNU Libtool libltdl])
165 if test "$with_dlopen" != no && test "$with_libltdl" != yes; then
166 AC_CHECK_HEADER([dlfcn.h],
167 AC_CHECK_LIB([dl], [dlopen],
168 [LIBS_LIBCPLUFF="-ldl $LIBS_LIBCPLUFF"; dlmechanism=dlopen]))
170 if test "$dlmechanism" = none && test "$with_libltdl" != no && test "$with_dlopen" != yes; then
171 AC_CHECK_HEADER([ltdl.h],
172 AC_CHECK_LIB([ltdl], [lt_dlopen],
173 [LIBS_LIBCPLUFF="-lltdl $LIBS_LIBCPLUFF"; dlmechanism=libltdl]))
175 case "$dlmechanism" in
177 AC_DEFINE([DLOPEN_POSIX], [], [Define to use Posix dlopen])
180 AC_DEFINE([DLOPEN_LIBTOOL], [], [Define to use GNU Libtool libltdl])
183 AC_MSG_ERROR([Either the Posix dlopen facility or GNU Libtool libltdl is required])
187 # Check for Expat XML parsing library
188 # -----------------------------------
189 AC_CHECK_HEADER([expat.h],, AC_MSG_ERROR([Expat header file is required]))
190 AC_CHECK_LIB([expat], [XML_ParseBuffer], [LIBS_LIBCPLUFF="-lexpat $LIBS_LIBCPLUFF"], AC_MSG_ERROR([Expat library is required]))
192 # Check for the GNU Readline Library
193 # ----------------------------------
194 AC_ARG_WITH([readline],
195 AS_HELP_STRING([--with-readline],
196 [use the GNU Readline Library]))
199 if test "$with_readline" != no; then
200 AC_CHECK_HEADER([readline/readline.h],
201 AC_CHECK_LIB([readline], [add_history], [LIB_READLINE="-lreadline"; have_readline=yes]))
202 if test "$with_readline" = yes && test "$have_readline" != yes; then
203 AC_MSG_ERROR([GNU readline requested but headers or library not found])
206 AC_SUBST([LIB_READLINE])
207 AM_CONDITIONAL([HAVE_READLINE], test "$have_readline" = yes)
209 # Link non-library parts with the C-Pluff library
210 # -----------------------------------------------
211 LIBS_OTHER="\$(top_builddir)/libcpluff/libcpluff.la $LIBS_OTHER"
213 # Check for stat/lstat functions
214 # ------------------------------
215 AC_CHECK_FUNCS([stat lstat])
219 AC_ARG_ENABLE([debug],
220 AS_HELP_STRING([--enable-assertions], [enable assertion checks for debugging]))
221 if ! test "$enable_assertions" = yes; then
222 CPPFLAGS="$CPPFLAGS -DNDEBUG"
224 AC_ARG_ENABLE([gcc-warnings],
225 AS_HELP_STRING([--enable-gcc-warnings],
226 [enable default set of GCC compiler warnings]))
227 if test "$enable_gcc_warnings" = yes; then
228 CFLAGS="$CFLAGS -Wall -pedantic -std=gnu99"
231 # File name separator character
232 # -----------------------------
233 AC_MSG_CHECKING([which file name separator to use])
235 *-*-mingw32* | *-*-windows*)
242 AC_MSG_RESULT(['$cp_fnamesep'])
243 AC_DEFINE_UNQUOTED([CP_FNAMESEP_CHAR], ['$cp_fnamesep'], [File name separator character])
244 AC_DEFINE_UNQUOTED([CP_FNAMESEP_STR], ["$cp_fnamesep"], [File name separator string])
246 # Substitute C-Pluff loader for examples
247 # --------------------------------------
248 CPLUFF_LOADER="$bindir/cpluff-loader"
249 AC_SUBST(CPLUFF_LOADER)
253 AC_CONFIG_FILES([Makefile
255 libcpluff/cpluffdef.h
256 libcpluff/docsrc/Makefile
257 libcpluff/docsrc/Doxyfile-ref
258 libcpluff/docsrc/Doxyfile-impl
265 test/plugins-source/Makefile
266 test/plugins-source/callbackcounter/Makefile
267 test/plugins-source/symuser/Makefile
268 test/plugins-source/symprovider/Makefile
270 examples/cpfile/Makefile
271 examples/cpfile/cpfile
272 examples/cpfile/plugins/Makefile
273 examples/cpfile/plugins/core/Makefile
274 examples/cpfile/plugins/special/Makefile
275 examples/cpfile/plugins/extension/Makefile
276 examples/cpfile/plugins/cext/Makefile])
280 # Print configuration information
281 # -------------------------------
282 AC_MSG_NOTICE([-----------------------------------------------------------])
283 AC_MSG_NOTICE([C-Pluff configuration])
284 AC_MSG_NOTICE([ release version: $PACKAGE_VERSION])
285 if test -n "$cp_threads"; then
286 val="yes ($cp_threads)"
290 AC_MSG_NOTICE([ multi-threading support: $val])
291 AC_MSG_NOTICE([ dlopening mechanism: $dlmechanism])
293 test "$USE_NLS" = no || val="yes (gettext)"
294 AC_MSG_NOTICE([ localization support: $val])
295 AC_MSG_NOTICE([ use GNU readline library: $have_readline])
296 if test "$enable_assertions" = yes; then
301 AC_MSG_NOTICE([ assertion checks for debugging: $val])
302 AC_MSG_NOTICE([ file name separator character: '$cp_fnamesep'])
303 AC_MSG_NOTICE([ compiler and linker settings:])
304 AC_MSG_NOTICE([ CC='$CC'])
305 AC_MSG_NOTICE([ CPPFLAGS='$CPPFLAGS'])
306 AC_MSG_NOTICE([ CFLAGS='$CFLAGS'])
307 AC_MSG_NOTICE([ LDFLAGS='$LDFLAGS'])
308 AC_MSG_NOTICE([ LIBS='$LIBS'])
309 AC_MSG_NOTICE([ LIBS_LIBCPLUFF='$LIBS_LIBCPLUFF'])
310 AC_MSG_NOTICE([ LIBS_OTHER='$LIBS_OTHER'])
311 AC_MSG_NOTICE([ LIB_READLINE='$LIB_READLINE'])
312 AC_MSG_NOTICE([ LTLIBINTL='$LTLIBINTL'])
313 AC_MSG_NOTICE([-----------------------------------------------------------])