rbb 99/12/23 13:01:32
Modified: src acinclude.m4 configure.in src/modules/mpm config.m4 Log: First stab at logic to determine which threading library to use. This also gets rid of the hack of always putting -pthread in the CFLAGS variable. Revision Changes Path 1.8 +43 -0 apache-2.0/src/acinclude.m4 Index: acinclude.m4 =================================================================== RCS file: /home/cvs/apache-2.0/src/acinclude.m4,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- acinclude.m4 1999/12/20 03:09:43 1.7 +++ acinclude.m4 1999/12/23 21:01:27 1.8 @@ -95,3 +95,46 @@ fi ]) +dnl +dnl APACHE_CHECK_THREADS() +dnl +dnl Determine the best flags for linking against a threading library. +dnl +AC_DEFUN(THREAD_TEST, [ +AC_TRY_RUN( [ +#include <pthread.h> + +void *thread_routine(void *data) { + return data; +} + +int main() { + pthread_t thd; + int data = 1; + return pthread_create(&thd, NULL, thread_routine, &data); +} ], [ + THREADS_WORKING="yes" + ], [ + THREADS_WORKING="no" + ], THREADS_WORKING="no" ) ] ) + +define(APACHE_CHECK_THREADS, [dnl + cflags_orig="$CFLAGS" + ldflags_orig="$LDFLAGS" + for test_cflag in $1; do + for test_ldflag in $2; do + CFLAGS="$test_cflag $cflags_orig" + LDFLAGS="$test_ldflag $ldflags_orig" + THREAD_TEST() + if test "$THREADS_WORKING" = "yes"; then + break + fi + done + if test "$THREADS_WORKING" = "yes"; then + threads_result="Updating CFLAGS and LDFLAGS" + break + fi + threads_result="Threads not found" + done +] ) + 1.15 +4 -0 apache-2.0/src/configure.in Index: configure.in =================================================================== RCS file: /home/cvs/apache-2.0/src/configure.in,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- configure.in 1999/12/21 21:41:40 1.14 +++ configure.in 1999/12/23 21:01:28 1.15 @@ -73,6 +73,10 @@ dnl ## Check for library functions +AC_MSG_CHECKING([for which threading library to use]) +APACHE_CHECK_THREADS('' -pthread -D_REENTRANT, '' -lpthread -lc_r) +AC_MSG_RESULT("$threads_result") + dnl See Comment #Spoon AC_CHECK_FUNCS( \ 1.5 +0 -2 apache-2.0/src/modules/mpm/config.m4 Index: config.m4 =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/mpm/config.m4,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- config.m4 1999/12/20 03:09:50 1.4 +++ config.m4 1999/12/23 21:01:31 1.5 @@ -46,8 +46,6 @@ dnl XXX - We should be checking for the proper flags to use on a particular dnl platform. This will cover a couple of them, anyway - CFLAGS="-pthread $CFLAGS" - CXXFLAGS="-pthread $CXXFLAGS" AC_CHECK_HEADER(pthread.h, [ ],[ AC_MSG_ERROR(This MPM requires pthreads. Try --with-mpm=prefork.)