1dnl ##
2dnl ##  GNU Pth - The GNU Portable Threads
3dnl ##  Copyright (c) 1999-2006 Ralf S. Engelschall <rse@engelschall.com>
4dnl ##
5dnl ##  This file is part of GNU Pth, a non-preemptive thread scheduling
6dnl ##  library which can be found at http://www.gnu.org/software/pth/.
7dnl ##
8dnl ##  This library is free software; you can redistribute it and/or
9dnl ##  modify it under the terms of the GNU Lesser General Public
10dnl ##  License as published by the Free Software Foundation; either
11dnl ##  version 2.1 of the License, or (at your option) any later version.
12dnl ##
13dnl ##  This library is distributed in the hope that it will be useful,
14dnl ##  but WITHOUT ANY WARRANTY; without even the implied warranty of
15dnl ##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16dnl ##  Lesser General Public License for more details.
17dnl ##
18dnl ##  You should have received a copy of the GNU Lesser General Public
19dnl ##  License along with this library; if not, write to the Free Software
20dnl ##  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21dnl ##  USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
22dnl ##
23dnl ##  configure.ac: Pth Autoconf specification
24dnl ##
25
26dnl #                              ``Programming in Bourne-Shell
27dnl #                                is a higher form of masochism.''
28dnl #                                           -- Unknown
29
30dnl ##
31dnl ##  PROLOG
32dnl ##
33
34dnl #   standard Autoconf prolog
35AC_PREREQ(2.52)dnl
36AC_REVISION([1.0])
37
38dnl #   autoconf initialization
39AC_INIT(pthsem,2.0.8)
40AM_INIT_AUTOMAKE
41AC_ENABLESUBDIR
42AC_HEADLINE(dnl
43pthsem, Portable Threads, dnl
44PTH_VERSION, [$PACKAGE_VERSION], [0x200208], dnl
45[Copyright (c) 2005-2009 Martin Koegler <mkoegler@auto.tuwien.ac.at>]
46[Copyright (c) 1999-2006 Ralf S. Engelschall <rse@engelschall.com>])
47AC_CONFIG_PARAM(config.param)
48AC_CONFIG_HEADER(pth_acdef.h)dnl
49AC_PREFIX_DEFAULT(/usr/local)
50AC_PLATFORM(PLATFORM)
51
52dnl ##
53dnl ##  BUILD TOOLS
54dnl ##
55
56AC_MSG_PART(Build Tools)
57
58AC_PROG_CC
59AC_PROG_CPP
60AC_PROG_EGREP
61AC_SET_MAKE
62AC_CHECK_DEBUGGING
63case "$PLATFORM" in
64        #   Solaris 2.7/x86 is slightly broken
65        *-pc-solaris2.[[78]] [)] enable_shared=no ;;
66esac
67AC_PROG_LIBTOOL
68
69dnl ##  Support for some special platform/compiler options
70case "$PLATFORM:$CC" in
71    *-sun-solaris2*:cc )
72        #   shut-up harmless warnings caused by do-while macros on Solaris
73        test ".$ac_cv_prog_gcc" = ".no" && CFLAGS="$CFLAGS -w"
74        ;;
75    *-*-sysv*uw[[27]]*:cc )
76        #   shut-up harmless warnings caused by do-while macros on UnixWare
77        CFLAGS="$CFLAGS -w"
78        ;;
79    *-hp-hpux*:cc )
80        #   HPUX needs a few special options to find its ANSI C brain
81        CFLAGS="$CFLAGS -Ae -O"
82        ;;
83    *-hp-hpux*:CC )
84        #   HPUX outputs useless warnings
85        CFLAGS="$CFLAGS -w"
86        ;;
87    *-sgi-irix6.2:cc )
88        #   shut-up warnings caused by IRIX brain-dead 32/64 bit stuff
89        LDFLAGS="$LDFLAGS -woff 85 -Wl,-woff,84 -Wl,-woff,85"
90        ;;
91    *-sgi-irix6.5.[[2-9]]:cc )
92        #   since IRIX 6.5.2 the C compiler is smart enough,
93        #   but the linker is still complaining, of course
94        LDFLAGS="$LDFLAGS -woff 84,85,134"
95        ;;
96    *-sgi-irix6.5:cc )
97        #   shut-up warnings caused by IRIX brain-dead 32/64 bit stuff
98        CFLAGS="$CFLAGS -woff 1110,1048"
99        LDFLAGS="$LDFLAGS -woff 84,85,134"
100        ;;
101    *-dec-osf4*:cc )
102        #   make sure the standard compliant functions are used on Tru64/OSF1 4.x
103        CFLAGS="$CFLAGS -std"
104        ;;
105    *-dec-osf5*:cc )
106        #   make sure the standard compliant functions are used on Tru64/OSF1 5.x
107        CFLAGS="$CFLAGS -std -D_XOPEN_SOURCE_EXTENDED"
108        ;;
109    *-*-isc*:* )
110        #   ISC is brain-dead and needs a bunch of options to find its brain
111        CPPFLAGS="$CPPFLAGS -D_POSIX_SOURCE";
112        LIBS="$LIBS -lcposix -linet";
113        ;;
114    *-*-aix4.1*:cc )
115        #   AIX 4.1.x' cc complains about our use of "volatile"
116        CPPFLAGS="$CPPFLAGS '-Dvolatile=/**/'";
117        ;;
118esac
119
120dnl ##
121dnl ##   MANDATORY PLATFORM ENVIRONMENT
122dnl ##
123
124AC_MSG_PART(Mandatory Platform Environment)
125
126dnl # check for standard headers
127AC_HEADER_STDC
128AC_HAVE_HEADERS(dnl
129   stdio.h stdlib.h stdarg.h string.h signal.h unistd.h setjmp.h fcntl.h dnl
130   errno.h sys/types.h sys/time.h sys/wait.h sys/stat.h sys/socket.h)
131AC_CHECK_FUNCS(dnl
132   gettimeofday select sigaction sigprocmask sigpending sigsuspend)
133AC_BEGIN_DECISION([mandatory system headers and functions])
134AC_IFALLYES(dnl
135   header:stdio.h header:stdlib.h header:stdarg.h header:string.h dnl
136   header:signal.h header:unistd.h header:setjmp.h header:fcntl.h header:errno.h dnl
137   header:sys/types.h header:sys/time.h header:sys/wait.h header:sys/stat.h header:sys/socket.h dnl
138   func:gettimeofday func:select func:sigaction func:sigprocmask dnl
139   func:sigpending func:sigsuspend,
140   AC_DECIDE(fine, [all fine]))
141AC_END_DECISION
142
143
144dnl ##
145dnl ##  OPTIONAL PLATFORM ENVIRONMENT
146dnl ##
147
148AC_MSG_PART(Optional Platform Environment)
149
150dnl #  check for the number of signals
151AC_CHECK_NSIG(PTH_NSIG)
152
153dnl #  check for size of fd_set (FDSETSIZE)
154AC_CHECK_FDSETSIZE(PTH_FDSETSIZE)
155
156dnl # check whether poll(2)'s input stuff has to be faked
157AC_CHECK_FUNCS(poll)
158AC_CHECK_DEFINE(POLLIN, poll.h)
159AC_MSG_CHECKING(whether poll(2) facility has to be faked)
160AC_IFALLYES(func:poll define:POLLIN, PTH_FAKE_POLL=0, PTH_FAKE_POLL=1)
161if test .$PTH_FAKE_POLL = .1; then
162    msg="yes"
163else
164    msg="no"
165fi
166AC_SUBST(PTH_FAKE_POLL)
167AC_MSG_RESULT([$msg])
168
169dnl # check for clock_gettime
170AC_CHECK_DEFINE(CLOCK_MONOTONIC, time.h)
171AC_CHECK_DEFINE(__NR_clock_gettime, sys/syscall.h)
172AC_SEARCH_LIBS(clock_gettime,[],[AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [have clock_gettime])])
173
174dnl # check for readv/writev environment
175AC_HAVE_HEADERS(sys/uio.h)
176AC_CHECK_FUNCS(readv writev)
177AC_MSG_CHECKING(whether readv(2)/writev(2) facility has to be faked)
178AC_IFALLYES(func:readv func:writev header:sys/uio.h, PTH_FAKE_RWV=0, PTH_FAKE_RWV=1)
179if test .$PTH_FAKE_RWV = .1; then
180    msg="yes"
181else
182    msg="no"
183fi
184AC_SUBST(PTH_FAKE_RWV)
185AC_MSG_RESULT([$msg])
186
187dnl # check for various other functions which would be nice to have
188AC_CHECK_FUNCS(usleep strerror)
189
190dnl # check for various other headers which we might need
191AC_HAVE_HEADERS(sys/resource.h net/errno.h paths.h)
192
193dnl # at least the test programs need some socket stuff
194AC_SEARCH_LIBS(gethostname, [nsl],,[AC_SEARCH_LIBS(gethostbyname, [nsl])])
195AC_SEARCH_LIBS(accept, [socket])
196
197dnl # check whether we've to use a non-standard #include <sys/select.h>  to get
198dnl # the definition for fd_set under AIX and other brain-dead platforms.
199AC_HAVE_HEADERS(sys/select.h)
200EXTRA_INCLUDE_SYS_SELECT_H="#include <sys/select.h>"
201if test ".$ac_cv_header_sys_select_h" != .yes; then
202    EXTRA_INCLUDE_SYS_SELECT_H="/* $EXTRA_INCLUDE_SYS_SELECT_H */"
203fi
204AC_SUBST(EXTRA_INCLUDE_SYS_SELECT_H)
205
206dnl # check whether we've to define sig_atomic_t
207AC_CHECK_TYPEDEF(sig_atomic_t, signal.h)
208FALLBACK_SIG_ATOMIC_T="typedef int sig_atomic_t;"
209if test ".$ac_cv_typedef_sig_atomic_t" = .yes; then
210    FALLBACK_SIG_ATOMIC_T="/* $FALLBACK_SIG_ATOMIC_T */"
211fi
212AC_SUBST(FALLBACK_SIG_ATOMIC_T)
213
214dnl # check whether we've to define pid_t
215AC_CHECK_TYPEDEF(pid_t, sys/types.h)
216FALLBACK_PID_T="typedef int pid_t;"
217if test ".$ac_cv_typedef_pid_t" = .yes; then
218    FALLBACK_PID_T="/* $FALLBACK_PID_T */"
219fi
220AC_SUBST(FALLBACK_PID_T)
221
222dnl # check whether we've to define size_t
223AC_CHECK_TYPEDEF(size_t, stdlib.h)
224FALLBACK_SIZE_T="typedef unsigned int size_t;"
225if test ".$ac_cv_typedef_size_t" = .yes; then
226    FALLBACK_SIZE_T="/* $FALLBACK_SIZE_T */"
227fi
228AC_SUBST(FALLBACK_SIZE_T)
229
230dnl # check whether we've to define ssize_t
231AC_CHECK_TYPEDEF(ssize_t, sys/types.h)
232FALLBACK_SSIZE_T="typedef unsigned int ssize_t;"
233if test ".$ac_cv_typedef_ssize_t" = .yes; then
234    FALLBACK_SSIZE_T="/* $FALLBACK_SSIZE_T */"
235fi
236AC_SUBST(FALLBACK_SSIZE_T)
237
238dnl # check whether we've to define off_t
239AC_CHECK_TYPEDEF(off_t, sys/types.h)
240FALLBACK_OFF_T="typedef int off_t;"
241if test ".$ac_cv_typedef_off_t" = .yes; then
242    FALLBACK_OFF_T="/* $FALLBACK_OFF_T */"
243fi
244AC_SUBST(FALLBACK_OFF_T)
245
246dnl # check whether stack_t exists instead of sigaltstack
247AC_CHECK_TYPEDEF(stack_t, signal.h)
248
249dnl # check whether ss_base instead of ss_sp attribute exists
250AC_CHECK_STRUCTATTR(ss_base, sigaltstack, sys/signal.h)
251AC_CHECK_STRUCTATTR(ss_sp,   sigaltstack, sys/signal.h)
252
253dnl # check for gettimeofday() variant
254AC_MSG_CHECKING(for a single-argument based gettimeofday)
255cross_compile=no
256AC_TRY_COMPILE([
257#include <sys/types.h>
258#include <sys/time.h>
259#include <unistd.h>
260],[
261struct timeval tv;
262(void)gettimeofday(&tv);
263],
264msg="yes"
265,
266msg="no"
267)
268case $PLATFORM in
269    *-*-aix4* ) msg="no" ;; # on AIX the compiler test doesn't work
270    *-*-isc* )  msg="no" ;; # on ISC the compiler test doesn't work
271esac
272if test ".$msg" = .yes; then
273    AC_DEFINE(HAVE_GETTIMEOFDAY_ARGS1, 1, [define if gettimeofday(2) wants a single-argument only])
274fi
275AC_MSG_RESULT([$msg])
276
277dnl # check for struct timespec
278AC_MSG_CHECKING(for struct timespec)
279cross_compile=no
280AC_TRY_COMPILE([
281#include <time.h>
282#include <sys/time.h>
283],[
284struct timespec ts;
285],
286msg="yes"
287,
288msg="no"
289)
290if test ".$msg" = .yes; then
291    AC_DEFINE(HAVE_STRUCT_TIMESPEC, 1, [define if exists "struct timespec"])
292fi
293AC_MSG_RESULT([$msg])
294
295dnl # check for network/socket size type
296AC_CHECK_SOCKLENTYPE([
297FALLBACK_SOCKLEN_T="typedef ${ac_type} socklen_t;"
298if test ".$ac_type" = ".socklen_t"; then
299    FALLBACK_SOCKLEN_T="/* $FALLBACK_SOCKLEN_T */"
300fi
301AC_SUBST(FALLBACK_SOCKLEN_T)
302])
303
304dnl # check for filedescriptor number type
305AC_CHECK_NFDSTYPE([
306FALLBACK_NFDS_T="typedef ${ac_type} nfds_t;"
307if test ".$ac_type" = ".nfds_t"; then
308    FALLBACK_NFDS_T="/* $FALLBACK_NFDS_T */"
309fi
310AC_SUBST(FALLBACK_NFDS_T)
311])
312
313dnl # check for 64-bit types (for pth_snprintf.c)
314AC_CHECK_LONGLONG
315AC_CHECK_LONGDOUBLE
316
317dnl ##
318dnl ##  MACHINE CONTEXT IMPLEMENTATION
319dnl ##
320
321AC_MSG_PART(Machine Context Implementation)
322
323dnl #
324dnl #  1. determine possibilities
325dnl #
326
327dnl #  check for MCSC method
328AC_CHECK_HEADER(ucontext.h,,, [#include <sys/types.h>])
329AC_CHECK_FUNCS(makecontext swapcontext getcontext setcontext)
330AC_CHECK_MCSC(mcsc=yes, mcsc=no)
331
332dnl #  check for SJLJ method
333AC_CHECK_HEADERS(signal.h)
334AC_CHECK_FUNCS(sigsetjmp siglongjmp setjmp longjmp _setjmp _longjmp)
335AC_CHECK_FUNCS(sigaltstack sigstack)
336AC_CHECK_SJLJ(sjlj=yes, sjlj=no, sjlj_type)
337
338dnl #
339dnl #  2. make a general decision
340dnl #
341
342if test ".$mcsc" = .yes; then
343    mctx_mth=mcsc
344    mctx_dsp=sc
345    mctx_stk=mc
346elif test ".$sjlj" = .yes; then
347    mctx_mth=sjlj
348    mctx_dsp=$sjlj_type
349    mctx_stk=none
350    AC_IFALLYES(func:sigstack,    mctx_stk=ss)
351    AC_IFALLYES(func:sigaltstack, mctx_stk=sas)
352    case $mctx_dsp in
353         sjljlx|sjljisc|sjljw32 ) mctx_stk=none
354    esac
355else
356    AC_ERROR([no appropriate mctx method found])
357fi
358
359dnl #
360dnl #  3. allow decision to be overridden by user
361dnl #
362
363AC_ARG_WITH(mctx-mth,dnl
364[  --with-mctx-mth=ID      force mctx method      (mcsc,sjlj)],[
365case $withval in
366    mcsc|sjlj ) mctx_mth=$withval ;;
367    * ) AC_ERROR([invalid mctx method -- allowed: mcsc,sjlj]) ;;
368esac
369])dnl
370AC_ARG_WITH(mctx-dsp,dnl
371[  --with-mctx-dsp=ID      force mctx dispatching (sc,ssjlj,sjlj,usjlj,sjlje,...)],[
372case $withval in
373    sc|ssjlj|sjlj|usjlj|sjlje|sjljlx|sjljisc|sjljw32 ) mctx_dsp=$withval ;;
374    * ) AC_ERROR([invalid mctx dispatching -- allowed: sc,ssjlj,sjlj,usjlj,sjlje,sjljlx,sjljisc,sjljw32]) ;;
375esac
376])dnl
377AC_ARG_WITH(mctx-stk,dnl
378[  --with-mctx-stk=ID      force mctx stack setup (mc,ss,sas,...)],[
379case $withval in
380    mc|ss|sas|none ) mctx_stk=$withval ;;
381    * ) AC_ERROR([invalid mctx stack setup -- allowed: mc,ss,sas,none]) ;;
382esac
383])dnl
384
385dnl #
386dnl #  4. determine a few additional details
387dnl #
388
389dnl #  whether sigaltstack has to use stack_t instead of struct sigaltstack
390AC_CHECK_TYPEDEF(stack_t, signal.h)
391
392dnl #  direction of stack grow
393AC_CHECK_STACKGROWTH(PTH_STACKGROWTH)
394if test ".$ac_cv_check_stackgrowth" = ".down"; then
395    PTH_STACK_GROWTH="down"
396else
397    PTH_STACK_GROWTH="up"
398fi
399AC_SUBST(PTH_STACK_GROWTH)
400
401dnl #  GNU Hurd has a broken libc which has stubs for sigaltstack and
402dnl #  sigstack. When the following Autoconf checks for them are run, it
403dnl #  even crashes the system. So we have to disable these checks here.
404case $PLATFORM in
405    *86-*-gnu0* ) ac_cv_func_sigaltstack="no"; ac_cv_func_sigstack="no" ;;
406esac
407
408dnl #  how to specify stacks for the various functions
409AC_CHECK_STACKSETUP(makecontext, pth_skaddr_makecontext, pth_sksize_makecontext)
410AC_CHECK_STACKSETUP(sigaltstack, pth_skaddr_sigaltstack, pth_sksize_sigaltstack)
411AC_CHECK_STACKSETUP(sigstack,    pth_skaddr_sigstack,    pth_sksize_sigstack)
412
413dnl #  how to implement POSIX compliant sig{set,long}jmp()
414case $mctx_dsp in [
415    ssjlj )
416        pth_sigjmpbuf='sigjmp_buf'
417        pth_sigsetjmp='sigsetjmp(buf,1)'
418        pth_siglongjmp='siglongjmp(buf,val)'
419        ;;
420    sjlj )
421        pth_sigjmpbuf='jmp_buf'
422        pth_sigsetjmp='setjmp(buf)'
423        pth_siglongjmp='longjmp(buf,val)'
424        ;;
425    usjlj )
426        pth_sigjmpbuf='jmp_buf'
427        pth_sigsetjmp='_setjmp(buf)'
428        pth_siglongjmp='_longjmp(buf,val)'
429        ;;
430    sjlje )
431        pth_sigjmpbuf='jmp_buf'
432        pth_sigsetjmp='setjmp(buf)'
433        pth_siglongjmp='longjmp(buf,val)'
434        ;;
435    sjljlx|sjljisc|sjljw32 )
436        pth_sigjmpbuf='sigjmp_buf'
437        pth_sigsetjmp='sigsetjmp(buf,1)'
438        pth_siglongjmp='siglongjmp(buf,val)'
439        ;;
440] esac
441pth_sigjmpbuf="#define pth_sigjmpbuf $pth_sigjmpbuf"
442pth_sigsetjmp="#define pth_sigsetjmp(buf) $pth_sigsetjmp"
443pth_siglongjmp="#define pth_siglongjmp(buf,val) $pth_siglongjmp"
444AC_SUBST(pth_sigjmpbuf)
445AC_SUBST(pth_sigsetjmp)
446AC_SUBST(pth_siglongjmp)
447
448dnl #
449dnl #  5. export the results
450dnl #
451
452AC_DEFINE_UNQUOTED(PTH_MCTX_MTH_use, [PTH_MCTX_MTH_$mctx_mth], [define for machine context method])
453AC_DEFINE_UNQUOTED(PTH_MCTX_DSP_use, [PTH_MCTX_DSP_$mctx_dsp], [define for machine context dispatching])
454AC_DEFINE_UNQUOTED(PTH_MCTX_STK_use, [PTH_MCTX_STK_$mctx_stk], [define for machine context stack])
455
456PTH_MCTX_ID="$mctx_mth/$mctx_dsp/$mctx_stk"
457AC_MSG_RESULT([decision on mctx implementation... ${TB}${PTH_MCTX_ID}${TN}])
458AC_SUBST(PTH_MCTX_ID)
459
460AC_MSG_VERBOSE([decided mctx method: $mctx_mth])
461AC_MSG_VERBOSE([decided mctx dispatching: $mctx_dsp])
462AC_MSG_VERBOSE([decided mctx stack setup: $mctx_stk])
463
464
465dnl ##
466dnl ##  SYSTEM CALL MAPPING
467dnl ##
468
469AC_MSG_PART(System Call Mapping)
470
471dnl #   check for syscall(2)
472AC_CHECK_HEADERS(sys/syscall.h sys/socketcall.h)
473AC_CHECK_FUNCS(syscall)
474AC_CHECK_DEFINE(SYS_read, sys/syscall.h)
475
476dnl #   check for dlsym(3) with RTLD_NEXT
477AC_CHECK_HEADERS(dlfcn.h)
478AC_CHECK_DEFINE(RTLD_NEXT, dlfcn.h)
479
480dnl #   check for path to dynamic C library
481AC_MSG_CHECKING([for syscall dynamic libraries])
482pth_syscall_libs=""
483dirs=`echo "$LDFLAGS" |\
484      sed -e 's;-L\([[^ ]]*\);<\1>;g' |\
485      sed -e 's;^[[^<]]*<;;' -e 's;>[[^<]]*<; ;g' -e 's;>.*$;;'`
486dirs="$dirs /usr/lib /lib"
487libs=`echo "$LIBS" |\
488      sed -e 's;-l\([[^ ]]*\);<\1>;g' |\
489      sed -e 's;^[[^<]]*<;;' -e 's;>[[^<]]*<; ;g' -e 's;>.*$;;'`
490libs="$libs c"
491for lib in $libs; do
492    for dir in $dirs; do
493        for ext in so sl; do
494            if test -f "${dir}/lib${lib}.${ext}"; then
495                if test ".$pth_syscall_libs" = .; then
496                    pth_syscall_libs="${dir}/lib${lib}.${ext}"
497                else
498                    pth_syscall_libs="${pth_syscall_libs}:${dir}/lib${lib}.${ext}"
499                fi
500            fi
501        done
502    done
503done
504AC_MSG_RESULT([$pth_syscall_libs])
505AC_DEFINE_UNQUOTED(PTH_SYSCALL_LIBS,
506                   ["$pth_syscall_libs"],
507                   [define for the paths to syscall dynamic libraries])
508
509AC_MSG_CHECKING([whether soft system call mapping is used])
510AC_ARG_ENABLE(syscall-soft,dnl
511[  --enable-syscall-soft   enable soft system call mapping (default=no)],
512enable_syscall_soft="$enableval",
513if test ".$enable_syscall_soft" = .; then
514    enable_syscall_soft=no
515fi
516)dnl
517if test .$enable_syscall_soft = .yes; then
518    PTH_SYSCALL_SOFT=1
519    msg="yes"
520else
521    PTH_SYSCALL_SOFT=0
522    msg="no"
523fi
524AC_MSG_RESULT([$msg])
525AC_SUBST(PTH_SYSCALL_SOFT)
526
527AC_MSG_CHECKING([whether hard system call mapping is used])
528AC_ARG_ENABLE(syscall-hard,dnl
529[  --enable-syscall-hard   enable hard system call mapping (default=no)],
530enable_syscall_hard="$enableval",[
531if test ".$enable_syscall_hard" = .; then
532    enable_syscall_hard=no
533fi
534])dnl
535if test ".$enable_syscall_hard" = .yes; then
536    AC_IFALLYES(func:syscall header:sys/syscall.h define:SYS_read,
537                enable_syscall_hard=yes, enable_syscall_hard=no)
538fi
539if test ".$enable_syscall_hard" = .yes; then
540    PTH_SYSCALL_HARD=1
541    msg="yes"
542    AC_SEARCH_LIBS(dlsym, [dl])
543    AC_CHECK_FUNCS(dlopen dlsym dlclose)
544else
545    PTH_SYSCALL_HARD=0
546    msg="no"
547fi
548AC_MSG_RESULT([$msg])
549AC_SUBST(PTH_SYSCALL_HARD)
550if test ".$enable_syscall_hard" = .yes; then
551    echo "${TB}Warning: The hard system call mapping variant is an experimental feature.${TN}"
552    echo "${TB}         It is not guaranteed to work if the mapped system calls on your${TN}"
553    echo "${TB}         platform do not 100% comply to the POSIX.1-2001/SUSv3 prototypes.${TN}"
554fi
555
556
557dnl ##
558dnl ##  BUILD PARAMETERS
559dnl ##
560
561AC_MSG_PART(Build Parameters)
562
563AC_ARG_ENABLE(compat,dnl
564[  --enable-compat        install GNU pth compat function (default=no)],
565enable_compat="$enableval",
566if test ".$enable_compat" = .; then
567    enable_compat=no
568fi
569)dnl
570AC_MSG_RESULT([$enable_compat])
571AM_CONDITIONAL(ENABLE_COMPAT, test x$enable_compat = xyes)
572
573dnl #  whether to build Pthread library
574AC_MSG_CHECKING(whether to build Pthread library)
575AC_ARG_ENABLE(pthread,dnl
576[  --enable-pthread        build Pthread library (default=no)],
577enable_pthread="$enableval",
578if test ".$enable_pthread" = .; then
579    enable_pthread=no
580fi
581)dnl
582AC_MSG_RESULT([$enable_pthread])
583AM_CONDITIONAL(ENABLE_PTHREAD, test x$enable_pthread = xyes)
584if test ".$enable_pthread" = .yes; then
585    PTHREAD_O=pthread.o       dnl # only for stripped down Pth source tree
586    LIBPTHREAD_A=libpthread.a dnl # only for stripped down Pth source tree
587    LIBPTHREAD_LA=libpthread.la
588    PTHREAD_CONFIG_1='$(S)pthread-config.1'
589    PTHREAD_3='$(S)pthread.3'
590    INSTALL_PTHREAD=install-pthread
591    UNINSTALL_PTHREAD=uninstall-pthread
592    TEST_PTHREAD=test_pthread
593    enable_syscall_soft=yes
594    PTH_SYSCALL_SOFT=1
595    AC_HAVE_HEADERS(pthread.h)
596    ac_warn=no
597    if test ".$ac_cv_header_pthread_h" = .yes; then
598        warn=yes
599        changequote(<<,>>)
600        case $PLATFORM in
601            *-*-freebsd* ) ac_warn=no ;;
602            *-*-linux*   ) ac_warn=no ;;
603            *-*-solaris* ) ac_warn=no ;;
604            *-*-irix*    ) ac_warn=no ;;
605        esac
606        changequote([,])
607    fi
608    if test ".$ac_warn" = .yes; then
609        echo "${TB}Warning: You seem to have a vendor Pthread library installed.${TN}"
610        echo "${TB}         There might be conflicts with its pthread.h under compile-time!${TN}"
611    fi
612else
613    PTHREAD_O=""     dnl # only for stripped down Pth source tree
614    LIBPTHREAD_A=""  dnl # only for stripped down Pth source tree
615    LIBPTHREAD_LA=""
616    PTHREAD_CONFIG_1=""
617    PTHREAD_3=""
618    INSTALL_PTHREAD=""
619    UNINSTALL_PTHREAD=""
620    TEST_PTHREAD=""
621fi
622AC_SUBST(PTHREAD_O)
623AC_SUBST(LIBPTHREAD_A)
624AC_SUBST(LIBPTHREAD_LA)
625AC_SUBST(PTHREAD_CONFIG_1)
626AC_SUBST(PTHREAD_3)
627AC_SUBST(INSTALL_PTHREAD)
628AC_SUBST(UNINSTALL_PTHREAD)
629AC_SUBST(TEST_PTHREAD)
630
631dnl #   whether to build against OSSP ex library
632AC_CHECK_EXTLIB(OSSP ex, ex, __ex_ctx, ex.h,
633                AC_DEFINE(PTH_EX, 1, [define if using OSSP ex in GNU pth]))
634
635dnl #   whether to build against Sfio library
636PTH_EXT_SFIO=0
637AC_CHECK_EXTLIB(Sfio, sfio, sfdisc, sfio.h, PTH_EXT_SFIO=1)
638AC_SUBST(PTH_EXT_SFIO)
639
640dnl #   whether to build against Dmalloc library
641AC_CHECK_EXTLIB(Dmalloc, dmalloc, dmalloc_debug, dmalloc.h,
642                AC_DEFINE(PTH_DMALLOC, 1, [define if using Dmalloc in GNU pth]))
643
644dnl ##
645dnl ##  Valgrind support
646dnl ##
647
648AC_ARG_WITH(valgrind,[  --with-valgrind[[=DIR]]   include annotation for valgrind (default=no)],[
649  if test -d "$with_valgrind"; then
650	CPPFLAGS="$CPPFLAGS -I$with_valgrind/include"
651  fi
652  AC_CHECK_DEFINE(VALGRIND_STACK_REGISTER, valgrind/valgrind.h)
653])
654
655dnl ##
656dnl ##  OUTPUT SUBSTITUTION
657dnl ##
658
659AC_MSG_PART(Output Substitution)
660
661AC_OUTPUT(dnl
662Makefile dnl
663debian/Makefile dnl
664compat/Makefile dnl
665pthread-config dnl
666pthread.h dnl
667compat/pth-config dnl
668pth-config dnl
669pthsem.pc dnl
670pth.h dnl
671pth_acmac.h dnl
672,dnl
673chmod +rx pthread-config
674chmod +rx pth-config
675)dnl
676if test ".$enable_pthread" = .no; then
677    rm -f pthread-config
678    rm -f pthread.h
679fi
680
681