-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
350 lines (300 loc) · 8.65 KB
/
configure.ac
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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
dnl autoconf script for portLib/comLib (aka pocolibs)
dnl
dnl Copyright (c) 2004
dnl Autonomous Systems Lab, Swiss Federal Institute of Technology.
dnl Copyright (c) 2003-2004,2010,2011 CNRS/LAAS
dnl
dnl GPL, since some parts were copied from other configure.in
dnl
dnl
AC_INIT([pocolibs],[3.1.99],[https://git.openrobots.org/projecrs/pocolibs])
AC_PREREQ(2.62)
AM_INIT_AUTOMAKE([foreign subdir-objects])
AM_MAINTAINER_MODE([enable])
AC_CONFIG_MACRO_DIR([m4])
AC_CANONICAL_HOST
AC_PROG_CC
if test "x${GCC}" = "xyes"; then
CFLAGS="${CFLAGS} -Wall"
fi
dnl --- OS flavour checks -----------------------------------------------
OSAPI=posix
AC_SUBST(OSAPI)
AC_ARG_WITH(xenomai,
AC_HELP_STRING([--with-xenomai=yes|no], [configure to use Xenomai]),
[opt_xenomai=$withval],[opt_xenomai=no])
AC_ARG_VAR([XENO_CONFIG], [Path to the xeno-config command for xenomai])
if test "x$opt_xenomai" = "xyes"; then
AC_PATH_PROG([XENO_CONFIG], [xeno-config], [no],
[/usr/xenomai/bin:${PATH}])
if test "x$XENO_CONFIG" = "xno" ; then
AC_MSG_FAILURE([--with-xenomai=yes specified, but xeno-config not found])
opt_xenomai=no
else
AC_MSG_RESULT([Configuring to use Xenomai])
XENO_CFLAGS=`${XENO_CONFIG} --skin posix --cflags`
XENO_LDFLAGS=`${XENO_CONFIG} --skin posix --ldflags`
fi
fi
CFLAGS="${CFLAGS} ${XENO_CFLAGS}"
LDFLAGS="${LDFLAGS} ${XENO_LDFLAGS}"
# there's no simple way to check this
case $host_os in
darwin*) CFLAGS="${CFLAGS} -DUSE_SEM_OPEN" ;;
esac
dnl --- end of OS flavour checks ----------------------------------------
AC_LIBTOOL_DLOPEN
AC_PROG_LIBTOOL
dnl add -ldl if needed
if test -n "$lt_cv_dlopen_libs" ; then
LIBS=$lt_cv_dlopen_libs
fi
AC_PROG_INSTALL
dnl check for rpcgen
AC_ARG_VAR(RPCGEN, [Remote Procedure Call (RPC) protocol compiler])
AC_PATH_PROG(RPCGEN, rpcgen, no, [$PATH])
AC_RPCGEN_C
AC_RPCGEN_M
dnl check for purify
opt_purify=no
AC_ARG_WITH(purify, [ --with-purify configure to postprocess with purify], opt_purify=$withval)
if test "x$opt_purify" = xyes; then
AC_MSG_RESULT([enabling purify])
PURIFY="purify"
else
PURIFY=
fi
AC_SUBST(PURIFY)
dnl processor tests
AC_C_BIGENDIAN
dnl
AC_TYPE_SIGNAL
AC_CHECK_HEADERS([getopt.h])
dnl --- check for pthread -----------------------------------------------
if test "x$opt_xenomai" != "xyes" ; then
# AC_CHECK_PTHREADS(action if ok, action if not ok, action if cross-compiling)
AC_DEFUN([AC_CHECK_PTHREADS],
AC_LANG_SAVE
AC_LANG_C
AC_TRY_RUN([
#include <pthread.h>
#include <stdlib.h>
void *pipo(void *a) { exit(0); }
int main() {
pthread_t t;
pthread_create(&t, NULL, pipo, NULL);
pthread_join(t, NULL);
exit(2);
}
],[$1],[$2],:)
AC_LANG_RESTORE
)
AC_CACHE_CHECK(
[if compiler recognizes -pthread],
poco_cv_gcc_pthread,
ac_save_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -pthread"
AC_CHECK_PTHREADS(
poco_cv_gcc_pthread=yes,
poco_cv_gcc_pthread=no
)
CFLAGS=$ac_save_CFLAGS
)
if test "$poco_cv_gcc_pthread" = "yes"; then
poco_threads=""
CFLAGS="$CFLAGS -pthread"
LDFLAGS="$LDFLAGS -pthread";
else
AC_CACHE_CHECK(
[if compiler recognizes -mt],
poco_cv_cc_mt,
ac_save_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -mt"
AC_CHECK_PTHREADS(
poco_cv_cc_mt=yes,
poco_cv_cc_mt=no
)
CFLAGS=$ac_save_CFLAGS
)
if test "$poco_cv_cc_mt" = "yes"; then
CFLAGS="$CFLAGS -mt";
LDFLAGS="$LDFLAGS -mt";
else
AC_CHECK_LIB(pthread,pthread_create,poco_threads=-lpthread,
[AC_CHECK_LIB(c_r,pthread_create,poco_threads=-lc_r)])
ac_save_LIBS="$LIBS"
if test -n "$poco_threads" ; then
LIBS="$poco_threads $LIBS"
fi
AC_CHECK_PTHREADS([
:
],[
AC_MSG_ERROR([No working thread support found (fatal)])
exit 2
])
fi
fi
# Linux requires -D_XOPEN_SOURCE=500 to build with libpthread and -Wall
AC_MSG_CHECKING([whether you need -D_XOPEN_SOURCE to use libpthread])
xopen=no
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#include <sys/types.h>
#include <pthread.h>
],[
pthread_rwlock_t lock;
pthread_rwlock_init(&lock, NULL);
])], [xopen=no], [CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"; xopen=yes])
AC_MSG_RESULT([$xopen])
fi
dnl --- end of checks for pthread ---------------------------------------
dnl recent glibc have moved rpc out to libtirpc
AC_CHECK_HEADERS([rpc/rpc.h],[],
[PKG_CHECK_MODULES([LIBTIRPC], libtirpc >= 1.0)])
if test "x$LIBTIRPC_LIBS" != "x" ; then
LIBS="${LIBS} ${LIBTIRPC_LIBS}"
fi
AC_SEARCH_LIBS([fabs], [m])
AC_SEARCH_LIBS([atan], [m])
AC_SEARCH_LIBS([timer_create], [rt])
if test "x$opt_xenomai" != "xyes" ; then
case `uname -r` in
*-adeos)
enable_posix_timers=yes
AC_MSG_WARN([Running adeos, enabling posix timers])
;;
esac
fi
AC_ARG_ENABLE([posix-timers],
AC_HELP_STRING([--disable-posix-timers Force use of setitimer(2)],
[instead of timer_create(3p)]),
[ if test "$enable_posix_timers" = "yes"; then
AC_MSG_NOTICE([forcing use of POSIX timers])
AC_DEFINE([HAVE_POSIX_TIMERS], 1, [timer_*() functions])
else
AC_MSG_NOTICE([disabling use of POSIX timers])
fi ],
AC_POSIX_TIMERS_WORKS
)
AC_SEARCH_LIBS(clock_gettime, [rt posix4])
AC_CHECK_FUNCS(clock_gettime, [],
AC_MSG_WARN([clock_gettime() support is required]))
AC_SEARCH_LIBS(sched_get_priority_min, [rt])
AC_MSG_CHECKING([for pthread_attr_setschedpolicy])
AC_TRY_LINK([#include <pthread.h>],
[pthread_attr_setschedpolicy(NULL, SCHED_RR);],
[AC_MSG_RESULT([yes])]
[AC_DEFINE(HAVE_PTHREAD_ATTR_SETSCHEDPOLICY, 1,
[posix threads scheduling policies])],
[AC_MSG_RESULT([no])]
)
AC_CHECK_FUNCS(gethostbyname, [], [
AC_CHECK_LIB(nsl, gethostbyname)
])
AC_CHECK_LIB(socket, socket)
AC_MSG_CHECKING([for vfscanf])
AC_TRY_LINK([#include <stdio.h>],
[vfscanf(NULL, NULL, NULL);],
[AC_MSG_RESULT([yes])]
[AC_DEFINE([HAVE_VFSCANF], 1, [vfscanf()])],
[AC_MSG_RESULT([no])]
)
AC_CONFIG_LIBOBJ_DIR([compat])
AC_REPLACE_FUNCS([fnmatch])
AC_CHECK_HEADERS([sys/tree.h])
dnl --- Debugging options -----------------------------------------------
AC_ARG_ENABLE(valgrind,
AC_HELP_STRING([--enable-valgrind], [compile with valgrind support]),
[valgrind=$enableval], [valgrind=no])
if test "x$valgrind" = "xyes"; then
PKG_CHECK_MODULES(VALGRIND, valgrind >= 1.1,
[ AC_DEFINE([VALGRIND_SUPPORT], 1,
[Support for running under valgrind])],
[ AC_MSG_ERROR(Valgrind not present and Valgrind support requested) ])
fi
AC_ARG_ENABLE(debug,
[AC_HELP_STRING([--enable-debug], [compile with DEBUG defined])],
[debug=$enableval],[debug=no])
if test "x$debug" = "xyes"; then
CFLAGS="${CFLAGS} -DDEBUG"
AC_MSG_RESULT([enabling -DDEBUG])
elif test "x$opt_debug" = "xno"; then
CFLAGS="${CFLAGS} -DNDEBUG"
fi
AC_ARG_WITH(debug-output,
AC_HELP_STRING([--with-debug-output=all task sys h2dev smmem h2evn mbox gcom h2timer],
[print debugging information at run-time (comma separated list)]),
[opt_debug_output=$withval],[opt_debug_output=])
if test "x$opt_debug_output" = "xall"; then
opt_debug_output="task,sys,h2dev,smmem,h2evn,mbox,gcom,h2timer"
fi
ac_save_ifs=$IFS; IFS=","
for dopt in $opt_debug_output; do
IFS=$ac_save_ifs
test -z "$dopt" && break
case "$dopt" in
task)
AC_DEFINE([PORTLIB_DEBUG_TASKLIB], 1,
[Enable debug in taskLib])
;;
sys)
AC_DEFINE([PORTLIB_DEBUG_SYSLIB], 1,
[Enable debug in sysLib])
;;
h2dev)
AC_DEFINE([COMLIB_DEBUG_H2DEVLIB], 1,
[Enable debug in h2devLib])
;;
smmem)
AC_DEFINE([COMLIB_DEBUG_SMMEMLIB], 1,
[Enable debug in smMemLib])
;;
h2evn)
AC_DEFINE([COMLIB_DEBUG_H2EVNLIB], 1,
[Enable debug in h2evnLib])
;;
mbox)
AC_DEFINE([COMLIB_DEBUG_MBOXLIB], 1,
[Enable debug in mboxLib])
;;
gcom)
AC_DEFINE([COMLIB_DEBUG_GCOMLIB], 1,
[Enable debug in gcomLib])
;;
h2timer)
AC_DEFINE([COMLIB_DEBUG_H2TIMERLIB], 1,
[Enable debug in h2timerLib])
;;
*)
IFS=$ac_save_ifs
AC_MSG_ERROR([Invalid debug output mode "$dopt"]) ;;
esac
AC_MSG_RESULT([debugging output in $dopt])
done
IFS=$ac_save_ifs
dnl --- Check perl path -------------------------------------------------
dnl Check for perl
AC_ARG_VAR(PERL, full path of Perl interpreter)
AC_PATH_PROG(PERL, perl, no)
if test "x$PERL" = "xno"; then
AC_MSG_ERROR(Cannot find the perl executable)
fi
dnl --- GNU tar (for make dist only) ------------------------------------
AC_ARG_VAR(TAR, [GNU tar command])
AC_CHECK_PROGS(TAR, [gtar gnutar gnu-tar tar], [no])
if test "x$TAR" = "xno"; then
AC_MSG_ERROR([Cannot find a tar program])
fi
dnl --- Make makefiles --------------------------------------------------
AC_CONFIG_HEADER(src/pocolibs-config.h)
AC_OUTPUT(
Makefile
pocolibs.pc
include/Makefile
src/portLib/Makefile
src/comLib/Makefile
src/posterLib/Makefile
src/h2/Makefile
src/h2logd/Makefile
src/shell/Makefile
src/regress/Makefile
)