iotivity 0.9.0
[platform/upstream/iotivity.git] / service / protocol-plugin / lib / cpluff / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2
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.
6
7 dnl Version information
8 dnl -------------------
9
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)
15
16 dnl Backwards compatibility information
17 define(CP_M4_ABI_COMPATIBILITY, [0.1])
18
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])
22
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])
32
33 # Version information
34 # -------------------
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])
44
45 # Automake initialization
46 # -----------------------
47 AM_INIT_AUTOMAKE([foreign])
48 AM_GNU_GETTEXT([external])
49 AM_GNU_GETTEXT_VERSION([0.16.1])
50
51 # C/C++ compiler settings
52 # -------------------
53 AC_LANG([C])
54 AC_PROG_CC
55 if test -z "$CC"; then
56   AC_MSG_ERROR([C compiler was not found (required)])
57 fi
58 AC_PROG_CC_C_O
59 AC_C_CONST
60 AC_LIBTOOL_DLOPEN
61 AC_LIBTOOL_WIN32_DLL
62 AC_PROG_LIBTOOL
63
64 # Other programs
65 # --------------
66 AC_PROG_LN_S
67
68 # For config.h
69 CPPFLAGS="$CPPFLAGS -I\$(top_builddir)"
70
71 # For cpluff.h and cpluffdef.h
72 CPPFLAGS="$CPPFLAGS -I\$(top_builddir)/libcpluff -I\$(top_srcdir)/libcpluff"
73
74 # Substitute variables for libcpluff and non-libcpluff components
75 AC_SUBST([LIBS_LIBCPLUFF])
76 AC_SUBST([LIBS_OTHER])
77
78 # Define shared library extension
79 # -------------------------------
80 AC_DEFINE_UNQUOTED([CP_SHREXT], ["$shrext_cmds"], [Shared library extension])
81
82 # Thread support checks
83 # ---------------------
84
85 # Check the options
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
88   yes)
89         # Use the default auto detection
90         enable_threads=''
91         ;;
92   ''|no|Posix|Windows)
93         # Ok, legal value, no action needed
94         ;;
95   *)
96         AC_MSG_ERROR([$enable_threads threads not supported])
97         ;;
98 esac
99
100 # Only check for different thread types if threading not disabled
101 cp_threads=''
102 if test "$enable_threads" != no; then
103
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])
108     AC_LINK_IFELSE(
109 [#include <pthread.h>
110
111 int main(int argc, char *argv[]) {
112         pthread_mutex_t mutex;
113         
114         pthread_mutex_init(&mutex, NULL);
115         return 0;
116 }
117 ], [AC_MSG_RESULT([yes])
118 cp_threads=Posix], AC_MSG_RESULT([no]))
119   fi
120   
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])
125     AC_LINK_IFELSE(
126 [#include <windows.h>
127
128 int main(int argc, char *argv[]) {
129   CreateMutex(NULL, FALSE, NULL);
130   return 0;
131 }
132 ], [AC_MSG_RESULT([yes])
133 cp_threads=Windows], AC_MSG_RESULT([no]))
134   fi
135   
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])
139   fi
140   
141 fi
142
143 if test -z "$cp_threads" && test "$enable_threads" != no; then
144   AC_MSG_WARN([multi-threading support not detected])
145 fi
146
147 if test -n "$cp_threads"; then
148         AC_DEFINE_UNQUOTED([CP_THREADS], ["$cp_threads"], [Multi-threading support type])
149 fi
150 AM_CONDITIONAL([POSIX_THREADS], test "$cp_threads" = Posix)
151 AM_CONDITIONAL([WINDOWS_THREADS], test "$cp_threads" = Windows)
152
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])
163 fi
164 dlmechanism=none
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]))
169 fi
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]))
174 fi
175 case "$dlmechanism" in
176   dlopen)
177     AC_DEFINE([DLOPEN_POSIX], [], [Define to use Posix dlopen])
178       ;;
179   libltdl)
180     AC_DEFINE([DLOPEN_LIBTOOL], [], [Define to use GNU Libtool libltdl])
181     ;;
182   *)
183     AC_MSG_ERROR([Either the Posix dlopen facility or GNU Libtool libltdl is required])
184     ;;
185 esac
186
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]))
191
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]))
197 have_readline=no
198 LIB_READLINE=
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])
204   fi
205 fi
206 AC_SUBST([LIB_READLINE])
207 AM_CONDITIONAL([HAVE_READLINE], test "$have_readline" = yes)
208
209 # Link non-library parts with the C-Pluff library
210 # -----------------------------------------------
211 LIBS_OTHER="\$(top_builddir)/libcpluff/libcpluff.la $LIBS_OTHER"
212
213 # Check for stat/lstat functions
214 # ------------------------------
215 AC_CHECK_FUNCS([stat lstat])
216
217 # Debugging support
218 # -----------------
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"
223 fi
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"
229 fi
230
231 # File name separator character
232 # -----------------------------
233 AC_MSG_CHECKING([which file name separator to use])
234 case "$host" in
235   *-*-mingw32* | *-*-windows*)
236         cp_fnamesep='\\'
237         ;;
238   *)
239         cp_fnamesep='/'
240         ;;
241 esac
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])
245
246 # Substitute C-Pluff loader for examples
247 # --------------------------------------
248 CPLUFF_LOADER="$bindir/cpluff-loader"
249 AC_SUBST(CPLUFF_LOADER)
250
251 # Output Makefiles
252 # ----------------
253 AC_CONFIG_FILES([Makefile
254 libcpluff/Makefile
255 libcpluff/cpluffdef.h
256 libcpluff/docsrc/Makefile
257 libcpluff/docsrc/Doxyfile-ref
258 libcpluff/docsrc/Doxyfile-impl
259 loader/Makefile
260 po/Makefile.in
261 doc/Makefile
262 doc/img/Makefile
263 docsrc/Makefile
264 test/Makefile
265 test/plugins-source/Makefile
266 test/plugins-source/callbackcounter/Makefile
267 test/plugins-source/symuser/Makefile
268 test/plugins-source/symprovider/Makefile
269 examples/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])
277 AC_OUTPUT
278
279
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)"
287 else
288   val=no
289 fi
290 AC_MSG_NOTICE([  multi-threading support:        $val])
291 AC_MSG_NOTICE([  dlopening mechanism:            $dlmechanism])
292 val=no
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
297   val=yes
298 else
299   val=no;
300 fi
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([-----------------------------------------------------------])