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 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
49 AM_GNU_GETTEXT([external])
50 AM_GNU_GETTEXT_VERSION([0.16.1])
52 # C/C++ compiler settings
56 if test -z "$CC"; then
57 AC_MSG_ERROR([C compiler was not found (required)])
70 CPPFLAGS="$CPPFLAGS -I\$(top_builddir)"
72 # For cpluff.h and cpluffdef.h
73 CPPFLAGS="$CPPFLAGS -I\$(top_builddir)/libcpluff -I\$(top_srcdir)/libcpluff"
75 # Substitute variables for libcpluff and non-libcpluff components
76 AC_SUBST([LIBS_LIBCPLUFF])
77 AC_SUBST([LIBS_OTHER])
79 # Define shared library extension
80 # -------------------------------
81 AC_DEFINE_UNQUOTED([CP_SHREXT], ["$shrext_cmds"], [Shared library extension])
83 # Thread support checks
84 # ---------------------
87 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)]))
88 case "$enable_threads" in
90 # Use the default auto detection
94 # Ok, legal value, no action needed
97 AC_MSG_ERROR([$enable_threads threads not supported])
101 # Only check for different thread types if threading not disabled
103 if test "$enable_threads" != no; then
105 # Check for Posix thread support
106 if test -z "$cp_threads" && \
107 ( test -z "$enable_threads" || test "$enable_threads" = Posix ); then
108 AC_MSG_CHECKING([for Posix threads])
110 [AC_LANG_SOURCE([#include <pthread.h>
112 int main(int argc, char **argv) {
113 pthread_mutex_t mutex;
115 pthread_mutex_init(&mutex, NULL);
118 ])], [AC_MSG_RESULT([yes])
119 cp_threads=Posix], AC_MSG_RESULT([no]))
122 # Check for Windows thread suppport
123 if test -z "$cp_threads" && \
124 ( test -z "$enable_threads" || test "$enable_threads" = Windows ); then
125 AC_MSG_CHECKING([for Windows threads])
127 [AC_LANG_SOURCE([#include <windows.h>
129 int main(int argc, char **argv) {
130 CreateMutex(NULL, FALSE, NULL);
133 ])], [AC_MSG_RESULT([yes])
134 cp_threads=Windows], AC_MSG_RESULT([no]))
137 # Check if we got the desired thread support
138 if test -n "$enable_threads" && test "$enable_threads" != "$cp_threads"; then
139 AC_MSG_ERROR([$enable_threads threads not detected])
144 if test -z "$cp_threads" && test "$enable_threads" != no; then
145 AC_MSG_WARN([multi-threading support not detected])
148 if test -n "$cp_threads"; then
149 AC_DEFINE_UNQUOTED([CP_THREADS], ["$cp_threads"], [Multi-threading support type])
151 AM_CONDITIONAL([POSIX_THREADS], test "$cp_threads" = Posix)
152 AM_CONDITIONAL([WINDOWS_THREADS], test "$cp_threads" = Windows)
154 # Check for the dlopen mechanism (Posix dlopen or GNU Libtool libltdl)
155 # --------------------------------------------------------------------
156 AC_ARG_WITH([dlopen],
157 AS_HELP_STRING([--with-dlopen],
158 [use the Posix dlopen facility]))
159 AC_ARG_WITH([libltdl],
160 AS_HELP_STRING([--with-libltdl],
161 [use the GNU Libtool libltdl]))
162 if test "$with_dlopen" = yes && test "$with_libltdl" = yes; then
163 AC_MSG_ERROR([Can not use both Posix dlopen and GNU Libtool libltdl])
166 if test "$with_dlopen" != no && test "$with_libltdl" != yes; then
167 AC_CHECK_HEADER([dlfcn.h],
168 AC_CHECK_LIB([dl], [dlopen],
169 [LIBS_LIBCPLUFF="-ldl $LIBS_LIBCPLUFF"; dlmechanism=dlopen],
170 AC_CHECK_LIB([c], [dlopen], [dlmechanism=dlopen])))
172 if test "$dlmechanism" = none && test "$with_libltdl" != no && test "$with_dlopen" != yes; then
173 AC_CHECK_HEADER([ltdl.h],
174 AC_CHECK_LIB([ltdl], [lt_dlopen],
175 [LIBS_LIBCPLUFF="-lltdl $LIBS_LIBCPLUFF"; dlmechanism=libltdl]))
177 case "$dlmechanism" in
179 AC_DEFINE([DLOPEN_POSIX], [], [Define to use Posix dlopen])
182 AC_DEFINE([DLOPEN_LIBTOOL], [], [Define to use GNU Libtool libltdl])
185 AC_MSG_ERROR([Either the Posix dlopen facility or GNU Libtool libltdl is required])
189 # Check for Expat XML parsing library
190 # -----------------------------------
191 AC_CHECK_HEADER([expat.h],, AC_MSG_ERROR([Expat header file is required]))
192 AC_CHECK_LIB([expat], [XML_ParseBuffer], [LIBS_LIBCPLUFF="-lexpat $LIBS_LIBCPLUFF"], AC_MSG_ERROR([Expat library is required]))
194 # Check for the GNU Readline Library
195 # ----------------------------------
196 AC_ARG_WITH([readline],
197 AS_HELP_STRING([--with-readline],
198 [use the GNU Readline Library]))
201 if test "$with_readline" != no; then
202 AC_CHECK_HEADER([readline/readline.h],
203 AC_CHECK_LIB([readline], [add_history], [LIB_READLINE="-lreadline"; have_readline=yes]))
204 if test "$with_readline" = yes && test "$have_readline" != yes; then
205 AC_MSG_ERROR([GNU readline requested but headers or library not found])
208 AC_SUBST([LIB_READLINE])
209 AM_CONDITIONAL([HAVE_READLINE], test "$have_readline" = yes)
211 # Link non-library parts with the C-Pluff library
212 # -----------------------------------------------
213 LIBS_OTHER="\$(top_builddir)/libcpluff/libcpluff.la $LIBS_OTHER"
215 # Check for stat/lstat functions
216 # ------------------------------
217 AC_CHECK_FUNCS([stat lstat])
221 AC_ARG_ENABLE([debug],
222 AS_HELP_STRING([--enable-assertions], [enable assertion checks for debugging]))
223 if ! test "$enable_assertions" = yes; then
224 CPPFLAGS="$CPPFLAGS -DNDEBUG"
226 AC_ARG_ENABLE([gcc-warnings],
227 AS_HELP_STRING([--enable-gcc-warnings],
228 [enable default set of GCC compiler warnings]))
229 if test "$enable_gcc_warnings" = yes; then
230 CFLAGS="$CFLAGS -Wall -pedantic -std=gnu99"
233 # File name separator character
234 # -----------------------------
235 AC_MSG_CHECKING([which file name separator to use])
237 *-*-mingw32* | *-*-windows*)
244 AC_MSG_RESULT(['$cp_fnamesep'])
245 AC_DEFINE_UNQUOTED([CP_FNAMESEP_CHAR], ['$cp_fnamesep'], [File name separator character])
246 AC_DEFINE_UNQUOTED([CP_FNAMESEP_STR], ["$cp_fnamesep"], [File name separator string])
248 # Substitute C-Pluff loader for examples
249 # --------------------------------------
250 CPLUFF_LOADER="$bindir/cpluff-loader"
251 AC_SUBST(CPLUFF_LOADER)
255 AC_CONFIG_FILES([Makefile
257 libcpluff/cpluffdef.h
258 libcpluff/docsrc/Makefile
259 libcpluff/docsrc/Doxyfile-ref
260 libcpluff/docsrc/Doxyfile-impl
268 test/plugins-source/Makefile
269 test/plugins-source/callbackcounter/Makefile
270 test/plugins-source/symuser/Makefile
271 test/plugins-source/symprovider/Makefile
273 examples/cpfile/Makefile
274 examples/cpfile/cpfile
275 examples/cpfile/plugins/Makefile
276 examples/cpfile/plugins/core/Makefile
277 examples/cpfile/plugins/special/Makefile
278 examples/cpfile/plugins/extension/Makefile
279 examples/cpfile/plugins/cext/Makefile])
283 # Print configuration information
284 # -------------------------------
285 AC_MSG_NOTICE([-----------------------------------------------------------])
286 AC_MSG_NOTICE([C-Pluff configuration])
287 AC_MSG_NOTICE([ release version: $PACKAGE_VERSION])
288 if test -n "$cp_threads"; then
289 val="yes ($cp_threads)"
293 AC_MSG_NOTICE([ multi-threading support: $val])
294 AC_MSG_NOTICE([ dlopening mechanism: $dlmechanism])
296 test "$USE_NLS" = no || val="yes (gettext)"
297 AC_MSG_NOTICE([ localization support: $val])
298 AC_MSG_NOTICE([ use GNU readline library: $have_readline])
299 if test "$enable_assertions" = yes; then
304 AC_MSG_NOTICE([ assertion checks for debugging: $val])
305 AC_MSG_NOTICE([ file name separator character: '$cp_fnamesep'])
306 AC_MSG_NOTICE([ compiler and linker settings:])
307 AC_MSG_NOTICE([ CC='$CC'])
308 AC_MSG_NOTICE([ CPPFLAGS='$CPPFLAGS'])
309 AC_MSG_NOTICE([ CFLAGS='$CFLAGS'])
310 AC_MSG_NOTICE([ LDFLAGS='$LDFLAGS'])
311 AC_MSG_NOTICE([ LIBS='$LIBS'])
312 AC_MSG_NOTICE([ LIBS_LIBCPLUFF='$LIBS_LIBCPLUFF'])
313 AC_MSG_NOTICE([ LIBS_OTHER='$LIBS_OTHER'])
314 AC_MSG_NOTICE([ LIB_READLINE='$LIB_READLINE'])
315 AC_MSG_NOTICE([ LTLIBINTL='$LTLIBINTL'])
316 AC_MSG_NOTICE([-----------------------------------------------------------])