aboutsummaryrefslogtreecommitdiff
path: root/lib/cpluff/configure.ac
blob: 854c0ca214e790b54b2d91d7216989e0ada391a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
dnl Process this file with autoconf to produce a configure script.

dnl Copyright 2007 Johannes Lehtinen
dnl This configure.ac script is free software; Johannes Lehtinen gives
dnl unlimited permission to copy, distribute and modify it.

dnl Version information
dnl -------------------

dnl Version information
define(CP_M4_VERSION_MAJOR, [0])
define(CP_M4_VERSION_MINOR, [1])
define(CP_M4_VERSION_REV, [3])
define(CP_M4_RELEASE_VERSION, CP_M4_VERSION_MAJOR.CP_M4_VERSION_MINOR.CP_M4_VERSION_REV)

dnl Backwards compatibility information
define(CP_M4_ABI_COMPATIBILITY, [0.1])

dnl Library version information
define(CP_M4_C_LIB_VERSION, [0:3:0])
define(CP_M4_CXX_LIB_VERSION, [0:0:0])

# Autoconf initialization
# -----------------------
AC_INIT([C-Pluff], CP_M4_RELEASE_VERSION, [johannes.lehtinen@iki.fi], [cpluff])
AC_COPYRIGHT([Copyright 2007 Johannes Lehtinen
This configure script is free software; Johannes Lehtinen gives unlimited
permission to copy, distribute and modify it.])
AC_CONFIG_SRCDIR([libcpluff/cpluff.h])
AC_CONFIG_AUX_DIR([auxliary])
AC_CONFIG_HEADERS([config.h])

# Version information
# -------------------
CP_VERSION_MAJOR=CP_M4_VERSION_MAJOR
CP_VERSION_MINOR=CP_M4_VERSION_MINOR
AC_DEFINE([CP_ABI_COMPATIBILITY], "CP_M4_ABI_COMPATIBILITY", [The earliest ABI compatible version or undefined])
CP_C_LIB_VERSION=CP_M4_C_LIB_VERSION
CP_CXX_LIB_VERSION=CP_M4_CXX_LIB_VERSION
AC_SUBST([CP_VERSION_MAJOR])
AC_SUBST([CP_VERSION_MINOR])
AC_SUBST([CP_C_LIB_VERSION])
AC_SUBST([CP_CXX_LIB_VERSION])

# Automake initialization
# -----------------------
AM_INIT_AUTOMAKE([foreign])
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION([0.16.1])

# C/C++ compiler settings
# -------------------
AC_LANG([C])
AC_PROG_CC
if test -z "$CC"; then
  AC_MSG_ERROR([C compiler was not found (required)])
fi
AC_PROG_CC_C_O
AC_C_CONST
AC_LIBTOOL_DLOPEN
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL

# Other programs
# --------------
AC_PROG_LN_S

# For config.h
CPPFLAGS="$CPPFLAGS -I\$(top_builddir)"

# For cpluff.h and cpluffdef.h
CPPFLAGS="$CPPFLAGS -I\$(top_builddir)/libcpluff -I\$(top_srcdir)/libcpluff"

# Substitute variables for libcpluff and non-libcpluff components
AC_SUBST([LIBS_LIBCPLUFF])
AC_SUBST([LIBS_OTHER])

# Define shared library extension
# -------------------------------
AC_DEFINE_UNQUOTED([CP_SHREXT], ["$shrext_cmds"], [Shared library extension])

# Thread support checks
# ---------------------

# Check the options
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)]))
case "$enable_threads" in
  yes)
  	# Use the default auto detection
  	enable_threads=''
  	;;
  ''|no|Posix|Windows)
  	# Ok, legal value, no action needed
  	;;
  *)
  	AC_MSG_ERROR([$enable_threads threads not supported])
  	;;
esac

# Only check for different thread types if threading not disabled
cp_threads=''
if test "$enable_threads" != no; then

  # Check for Posix thread support
  if test -z "$cp_threads" && \
    ( test -z "$enable_threads" || test "$enable_threads" = Posix ); then
    AC_MSG_CHECKING([for Posix threads])
    AC_LINK_IFELSE(
[AC_LANG_SOURCE([#include <pthread.h>

int main(int argc, char *argv[]) {
	pthread_mutex_t mutex;
	
	pthread_mutex_init(&mutex, NULL);
	return 0;
}
])], [AC_MSG_RESULT([yes])
cp_threads=Posix], AC_MSG_RESULT([no]))
  fi
  
  # Check for Windows thread suppport
  if test -z "$cp_threads" && \
    ( test -z "$enable_threads" || test "$enable_threads" = Windows ); then
    AC_MSG_CHECKING([for Windows threads])
    AC_LINK_IFELSE(
[AC_LANG_SOURCE([#include <windows.h>

int main(int argc, char *argv[]) {
  CreateMutex(NULL, FALSE, NULL);
  return 0;
}
])], [AC_MSG_RESULT([yes])
cp_threads=Windows], AC_MSG_RESULT([no]))
  fi
  
  # Check if we got the desired thread support
  if test -n "$enable_threads" && test "$enable_threads" != "$cp_threads"; then
    AC_MSG_ERROR([$enable_threads threads not detected])
  fi
  
fi

if test -z "$cp_threads" && test "$enable_threads" != no; then
  AC_MSG_WARN([multi-threading support not detected])
fi

if test -n "$cp_threads"; then
  	AC_DEFINE_UNQUOTED([CP_THREADS], ["$cp_threads"], [Multi-threading support type])
fi
AM_CONDITIONAL([POSIX_THREADS], test "$cp_threads" = Posix)
AM_CONDITIONAL([WINDOWS_THREADS], test "$cp_threads" = Windows)

# Check for the dlopen mechanism (Posix dlopen or GNU Libtool libltdl)
# --------------------------------------------------------------------
AC_ARG_WITH([dlopen],
  AS_HELP_STRING([--with-dlopen],
    [use the Posix dlopen facility]))
AC_ARG_WITH([libltdl],
  AS_HELP_STRING([--with-libltdl],
    [use the GNU Libtool libltdl]))
if test "$with_dlopen" = yes && test "$with_libltdl" = yes; then
  AC_MSG_ERROR([Can not use both Posix dlopen and GNU Libtool libltdl])
fi
dlmechanism=none
if test "$with_dlopen" != no && test "$with_libltdl" != yes; then
  AC_CHECK_HEADER([dlfcn.h],
    AC_CHECK_LIB([dl], [dlopen],
      [LIBS_LIBCPLUFF="-ldl $LIBS_LIBCPLUFF"; dlmechanism=dlopen]))
fi
if test "$dlmechanism" = none && test "$with_libltdl" != no && test "$with_dlopen" != yes; then  
  AC_CHECK_HEADER([ltdl.h],
    AC_CHECK_LIB([ltdl], [lt_dlopen],
      [LIBS_LIBCPLUFF="-lltdl $LIBS_LIBCPLUFF"; dlmechanism=libltdl]))
fi
case "$dlmechanism" in
  dlopen)
    AC_DEFINE([DLOPEN_POSIX], [], [Define to use Posix dlopen])
      ;;
  libltdl)
    AC_DEFINE([DLOPEN_LIBTOOL], [], [Define to use GNU Libtool libltdl])
    ;;
  *)
    AC_MSG_ERROR([Either the Posix dlopen facility or GNU Libtool libltdl is required])
    ;;
esac

# Check for Expat XML parsing library
# -----------------------------------
AC_CHECK_HEADER([expat.h],, AC_MSG_ERROR([Expat header file is required]))
AC_CHECK_LIB([expat], [XML_ParseBuffer], [LIBS_LIBCPLUFF="-lexpat $LIBS_LIBCPLUFF"], AC_MSG_ERROR([Expat library is required]))

# Check for the GNU Readline Library
# ----------------------------------
AC_ARG_WITH([readline],
  AS_HELP_STRING([--with-readline],
    [use the GNU Readline Library]))
have_readline=no
LIB_READLINE=
if test "$with_readline" != no; then
  AC_CHECK_HEADER([readline/readline.h],
    AC_CHECK_LIB([readline], [add_history], [LIB_READLINE="-lreadline"; have_readline=yes]))
  if test "$with_readline" = yes && test "$have_readline" != yes; then
    AC_MSG_ERROR([GNU readline requested but headers or library not found])
  fi
fi
AC_SUBST([LIB_READLINE])
AM_CONDITIONAL([HAVE_READLINE], test "$have_readline" = yes)

# Link non-library parts with the C-Pluff library
# -----------------------------------------------
LIBS_OTHER="\$(top_builddir)/libcpluff/libcpluff.la $LIBS_OTHER"

# Check for stat/lstat functions
# ------------------------------
AC_CHECK_FUNCS([stat lstat])

# Debugging support
# -----------------
AC_ARG_ENABLE([debug],
  AS_HELP_STRING([--enable-assertions], [enable assertion checks for debugging]))
if ! test "$enable_assertions" = yes; then
  CPPFLAGS="$CPPFLAGS -DNDEBUG"
fi
AC_ARG_ENABLE([gcc-warnings],
  AS_HELP_STRING([--enable-gcc-warnings],
    [enable default set of GCC compiler warnings]))
if test "$enable_gcc_warnings" = yes; then
  CFLAGS="$CFLAGS -Wall -pedantic -std=gnu99"
fi

# File name separator character
# -----------------------------
AC_MSG_CHECKING([which file name separator to use])
case "$host" in
  *-*-mingw32* | *-*-windows*)
  	cp_fnamesep='\\'
  	;;
  *)
  	cp_fnamesep='/'
  	;;
esac
AC_MSG_RESULT(['$cp_fnamesep'])
AC_DEFINE_UNQUOTED([CP_FNAMESEP_CHAR], ['$cp_fnamesep'], [File name separator character])
AC_DEFINE_UNQUOTED([CP_FNAMESEP_STR], ["$cp_fnamesep"], [File name separator string])

# Substitute C-Pluff loader for examples
# --------------------------------------
CPLUFF_LOADER="$bindir/cpluff-loader"
AC_SUBST(CPLUFF_LOADER)

# Output Makefiles
# ----------------
AC_CONFIG_FILES([Makefile
libcpluff/Makefile
libcpluff/cpluffdef.h
libcpluff/docsrc/Makefile
libcpluff/docsrc/Doxyfile-ref
libcpluff/docsrc/Doxyfile-impl
loader/Makefile
console/Makefile
po/Makefile.in
doc/Makefile
doc/img/Makefile
docsrc/Makefile
test/Makefile
test/plugins-source/Makefile
test/plugins-source/callbackcounter/Makefile
test/plugins-source/symuser/Makefile
test/plugins-source/symprovider/Makefile
examples/Makefile
examples/cpfile/Makefile
examples/cpfile/cpfile
examples/cpfile/plugins/Makefile
examples/cpfile/plugins/core/Makefile
examples/cpfile/plugins/special/Makefile
examples/cpfile/plugins/extension/Makefile
examples/cpfile/plugins/cext/Makefile])
AC_OUTPUT


# Print configuration information
# -------------------------------
AC_MSG_NOTICE([-----------------------------------------------------------])
AC_MSG_NOTICE([C-Pluff configuration])
AC_MSG_NOTICE([  release version:                $PACKAGE_VERSION])
if test -n "$cp_threads"; then
  val="yes ($cp_threads)"
else
  val=no
fi
AC_MSG_NOTICE([  multi-threading support:        $val])
AC_MSG_NOTICE([  dlopening mechanism:            $dlmechanism])
val=no
test "$USE_NLS" = no || val="yes (gettext)"
AC_MSG_NOTICE([  localization support:           $val])
AC_MSG_NOTICE([  use GNU readline library:       $have_readline])
if test "$enable_assertions" = yes; then
  val=yes
else
  val=no;
fi
AC_MSG_NOTICE([  assertion checks for debugging: $val])
AC_MSG_NOTICE([  file name separator character:  '$cp_fnamesep'])
AC_MSG_NOTICE([  compiler and linker settings:])
AC_MSG_NOTICE([    CC='$CC'])
AC_MSG_NOTICE([    CPPFLAGS='$CPPFLAGS'])
AC_MSG_NOTICE([    CFLAGS='$CFLAGS'])
AC_MSG_NOTICE([    LDFLAGS='$LDFLAGS'])
AC_MSG_NOTICE([    LIBS='$LIBS'])
AC_MSG_NOTICE([    LIBS_LIBCPLUFF='$LIBS_LIBCPLUFF'])
AC_MSG_NOTICE([    LIBS_OTHER='$LIBS_OTHER'])
AC_MSG_NOTICE([    LIB_READLINE='$LIB_READLINE'])
AC_MSG_NOTICE([    LTLIBINTL='$LTLIBINTL'])
AC_MSG_NOTICE([-----------------------------------------------------------])