comparison configure @ 1528:7770ef82c463

Configure correct C compiler options for Pthreads
author Adam Chlipala <adam@chlipala.net>
date Thu, 04 Aug 2011 17:06:50 -0400
parents b5d78407886d
children 3b57a6ddef1a
comparison
equal deleted inserted replaced
1527:cccf8bf64b30 1528:7770ef82c463
627 MLTON 627 MLTON
628 OPENSSL_LDFLAGS 628 OPENSSL_LDFLAGS
629 OPENSSL_LIBS 629 OPENSSL_LIBS
630 OPENSSL_INCLUDES 630 OPENSSL_INCLUDES
631 PKG_CONFIG 631 PKG_CONFIG
632 PTHREAD_CFLAGS
633 PTHREAD_LIBS
634 PTHREAD_CC
635 ax_pthread_config
632 OTOOL64 636 OTOOL64
633 OTOOL 637 OTOOL
634 LIPO 638 LIPO
635 NMEDIT 639 NMEDIT
636 DSYMUTIL 640 DSYMUTIL
11814 11818
11815 ac_config_headers="$ac_config_headers config.h" 11819 ac_config_headers="$ac_config_headers config.h"
11816 11820
11817 11821
11818 11822
11823
11824 ac_ext=c
11825 ac_cpp='$CPP $CPPFLAGS'
11826 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
11827 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
11828 ac_compiler_gnu=$ac_cv_c_compiler_gnu
11829
11830 ax_pthread_ok=no
11831
11832 # We used to check for pthread.h first, but this fails if pthread.h
11833 # requires special compiler flags (e.g. on True64 or Sequent).
11834 # It gets checked for in the link test anyway.
11835
11836 # First of all, check if the user has set any of the PTHREAD_LIBS,
11837 # etcetera environment variables, and if threads linking works using
11838 # them:
11839 if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
11840 save_CFLAGS="$CFLAGS"
11841 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
11842 save_LIBS="$LIBS"
11843 LIBS="$PTHREAD_LIBS $LIBS"
11844 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5
11845 $as_echo_n "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... " >&6; }
11846 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11847 /* end confdefs.h. */
11848
11849 /* Override any GCC internal prototype to avoid an error.
11850 Use char because int might match the return type of a GCC
11851 builtin and then its argument prototype would still apply. */
11852 #ifdef __cplusplus
11853 extern "C"
11854 #endif
11855 char pthread_join ();
11856 int
11857 main ()
11858 {
11859 return pthread_join ();
11860 ;
11861 return 0;
11862 }
11863 _ACEOF
11864 if ac_fn_c_try_link "$LINENO"; then :
11865 ax_pthread_ok=yes
11866 fi
11867 rm -f core conftest.err conftest.$ac_objext \
11868 conftest$ac_exeext conftest.$ac_ext
11869 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_ok" >&5
11870 $as_echo "$ax_pthread_ok" >&6; }
11871 if test x"$ax_pthread_ok" = xno; then
11872 PTHREAD_LIBS=""
11873 PTHREAD_CFLAGS=""
11874 fi
11875 LIBS="$save_LIBS"
11876 CFLAGS="$save_CFLAGS"
11877 fi
11878
11879 # We must check for the threads library under a number of different
11880 # names; the ordering is very important because some systems
11881 # (e.g. DEC) have both -lpthread and -lpthreads, where one of the
11882 # libraries is broken (non-POSIX).
11883
11884 # Create a list of thread flags to try. Items starting with a "-" are
11885 # C compiler flags, and other items are library names, except for "none"
11886 # which indicates that we try without any flags at all, and "pthread-config"
11887 # which is a program returning the flags for the Pth emulation library.
11888
11889 ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
11890
11891 # The ordering *is* (sometimes) important. Some notes on the
11892 # individual items follow:
11893
11894 # pthreads: AIX (must check this before -lpthread)
11895 # none: in case threads are in libc; should be tried before -Kthread and
11896 # other compiler flags to prevent continual compiler warnings
11897 # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
11898 # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
11899 # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
11900 # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
11901 # -pthreads: Solaris/gcc
11902 # -mthreads: Mingw32/gcc, Lynx/gcc
11903 # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
11904 # doesn't hurt to check since this sometimes defines pthreads too;
11905 # also defines -D_REENTRANT)
11906 # ... -mt is also the pthreads flag for HP/aCC
11907 # pthread: Linux, etcetera
11908 # --thread-safe: KAI C++
11909 # pthread-config: use pthread-config program (for GNU Pth library)
11910
11911 case "${host_cpu}-${host_os}" in
11912 *solaris*)
11913
11914 # On Solaris (at least, for some versions), libc contains stubbed
11915 # (non-functional) versions of the pthreads routines, so link-based
11916 # tests will erroneously succeed. (We need to link with -pthreads/-mt/
11917 # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
11918 # a function called by this macro, so we could check for that, but
11919 # who knows whether they'll stub that too in a future libc.) So,
11920 # we'll just look for -pthreads and -lpthread first:
11921
11922 ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
11923 ;;
11924
11925 *-darwin*)
11926 ax_pthread_flags="-pthread $ax_pthread_flags"
11927 ;;
11928 esac
11929
11930 if test x"$ax_pthread_ok" = xno; then
11931 for flag in $ax_pthread_flags; do
11932
11933 case $flag in
11934 none)
11935 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work without any flags" >&5
11936 $as_echo_n "checking whether pthreads work without any flags... " >&6; }
11937 ;;
11938
11939 -*)
11940 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with $flag" >&5
11941 $as_echo_n "checking whether pthreads work with $flag... " >&6; }
11942 PTHREAD_CFLAGS="$flag"
11943 ;;
11944
11945 pthread-config)
11946 # Extract the first word of "pthread-config", so it can be a program name with args.
11947 set dummy pthread-config; ac_word=$2
11948 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
11949 $as_echo_n "checking for $ac_word... " >&6; }
11950 if ${ac_cv_prog_ax_pthread_config+:} false; then :
11951 $as_echo_n "(cached) " >&6
11952 else
11953 if test -n "$ax_pthread_config"; then
11954 ac_cv_prog_ax_pthread_config="$ax_pthread_config" # Let the user override the test.
11955 else
11956 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
11957 for as_dir in $PATH
11958 do
11959 IFS=$as_save_IFS
11960 test -z "$as_dir" && as_dir=.
11961 for ac_exec_ext in '' $ac_executable_extensions; do
11962 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
11963 ac_cv_prog_ax_pthread_config="yes"
11964 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
11965 break 2
11966 fi
11967 done
11968 done
11969 IFS=$as_save_IFS
11970
11971 test -z "$ac_cv_prog_ax_pthread_config" && ac_cv_prog_ax_pthread_config="no"
11972 fi
11973 fi
11974 ax_pthread_config=$ac_cv_prog_ax_pthread_config
11975 if test -n "$ax_pthread_config"; then
11976 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_config" >&5
11977 $as_echo "$ax_pthread_config" >&6; }
11978 else
11979 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
11980 $as_echo "no" >&6; }
11981 fi
11982
11983
11984 if test x"$ax_pthread_config" = xno; then continue; fi
11985 PTHREAD_CFLAGS="`pthread-config --cflags`"
11986 PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
11987 ;;
11988
11989 *)
11990 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the pthreads library -l$flag" >&5
11991 $as_echo_n "checking for the pthreads library -l$flag... " >&6; }
11992 PTHREAD_LIBS="-l$flag"
11993 ;;
11994 esac
11995
11996 save_LIBS="$LIBS"
11997 save_CFLAGS="$CFLAGS"
11998 LIBS="$PTHREAD_LIBS $LIBS"
11999 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
12000
12001 # Check for various functions. We must include pthread.h,
12002 # since some functions may be macros. (On the Sequent, we
12003 # need a special flag -Kthread to make this header compile.)
12004 # We check for pthread_join because it is in -lpthread on IRIX
12005 # while pthread_create is in libc. We check for pthread_attr_init
12006 # due to DEC craziness with -lpthreads. We check for
12007 # pthread_cleanup_push because it is one of the few pthread
12008 # functions on Solaris that doesn't have a non-functional libc stub.
12009 # We try pthread_create on general principles.
12010 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12011 /* end confdefs.h. */
12012 #include <pthread.h>
12013 static void routine(void *a) { a = 0; }
12014 static void *start_routine(void *a) { return a; }
12015 int
12016 main ()
12017 {
12018 pthread_t th; pthread_attr_t attr;
12019 pthread_create(&th, 0, start_routine, 0);
12020 pthread_join(th, 0);
12021 pthread_attr_init(&attr);
12022 pthread_cleanup_push(routine, 0);
12023 pthread_cleanup_pop(0) /* ; */
12024 ;
12025 return 0;
12026 }
12027 _ACEOF
12028 if ac_fn_c_try_link "$LINENO"; then :
12029 ax_pthread_ok=yes
12030 fi
12031 rm -f core conftest.err conftest.$ac_objext \
12032 conftest$ac_exeext conftest.$ac_ext
12033
12034 LIBS="$save_LIBS"
12035 CFLAGS="$save_CFLAGS"
12036
12037 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_ok" >&5
12038 $as_echo "$ax_pthread_ok" >&6; }
12039 if test "x$ax_pthread_ok" = xyes; then
12040 break;
12041 fi
12042
12043 PTHREAD_LIBS=""
12044 PTHREAD_CFLAGS=""
12045 done
12046 fi
12047
12048 # Various other checks:
12049 if test "x$ax_pthread_ok" = xyes; then
12050 save_LIBS="$LIBS"
12051 LIBS="$PTHREAD_LIBS $LIBS"
12052 save_CFLAGS="$CFLAGS"
12053 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
12054
12055 # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
12056 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for joinable pthread attribute" >&5
12057 $as_echo_n "checking for joinable pthread attribute... " >&6; }
12058 attr_name=unknown
12059 for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
12060 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12061 /* end confdefs.h. */
12062 #include <pthread.h>
12063 int
12064 main ()
12065 {
12066 int attr = $attr; return attr /* ; */
12067 ;
12068 return 0;
12069 }
12070 _ACEOF
12071 if ac_fn_c_try_link "$LINENO"; then :
12072 attr_name=$attr; break
12073 fi
12074 rm -f core conftest.err conftest.$ac_objext \
12075 conftest$ac_exeext conftest.$ac_ext
12076 done
12077 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $attr_name" >&5
12078 $as_echo "$attr_name" >&6; }
12079 if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
12080
12081 cat >>confdefs.h <<_ACEOF
12082 #define PTHREAD_CREATE_JOINABLE $attr_name
12083 _ACEOF
12084
12085 fi
12086
12087 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if more special flags are required for pthreads" >&5
12088 $as_echo_n "checking if more special flags are required for pthreads... " >&6; }
12089 flag=no
12090 case "${host_cpu}-${host_os}" in
12091 *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
12092 *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
12093 esac
12094 { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${flag}" >&5
12095 $as_echo "${flag}" >&6; }
12096 if test "x$flag" != xno; then
12097 PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
12098 fi
12099
12100 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PTHREAD_PRIO_INHERIT" >&5
12101 $as_echo_n "checking for PTHREAD_PRIO_INHERIT... " >&6; }
12102 if ${ax_cv_PTHREAD_PRIO_INHERIT+:} false; then :
12103 $as_echo_n "(cached) " >&6
12104 else
12105
12106 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12107 /* end confdefs.h. */
12108
12109 #include <pthread.h>
12110 int
12111 main ()
12112 {
12113 int i = PTHREAD_PRIO_INHERIT;
12114 ;
12115 return 0;
12116 }
12117 _ACEOF
12118 if ac_fn_c_try_link "$LINENO"; then :
12119 ax_cv_PTHREAD_PRIO_INHERIT=yes
12120 else
12121 ax_cv_PTHREAD_PRIO_INHERIT=no
12122 fi
12123 rm -f core conftest.err conftest.$ac_objext \
12124 conftest$ac_exeext conftest.$ac_ext
12125
12126 fi
12127 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_PRIO_INHERIT" >&5
12128 $as_echo "$ax_cv_PTHREAD_PRIO_INHERIT" >&6; }
12129 if test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"; then :
12130
12131 $as_echo "#define HAVE_PTHREAD_PRIO_INHERIT 1" >>confdefs.h
12132
12133 fi
12134
12135 LIBS="$save_LIBS"
12136 CFLAGS="$save_CFLAGS"
12137
12138 # More AIX lossage: must compile with xlc_r or cc_r
12139 if test x"$GCC" != xyes; then
12140 for ac_prog in xlc_r cc_r
12141 do
12142 # Extract the first word of "$ac_prog", so it can be a program name with args.
12143 set dummy $ac_prog; ac_word=$2
12144 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
12145 $as_echo_n "checking for $ac_word... " >&6; }
12146 if ${ac_cv_prog_PTHREAD_CC+:} false; then :
12147 $as_echo_n "(cached) " >&6
12148 else
12149 if test -n "$PTHREAD_CC"; then
12150 ac_cv_prog_PTHREAD_CC="$PTHREAD_CC" # Let the user override the test.
12151 else
12152 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
12153 for as_dir in $PATH
12154 do
12155 IFS=$as_save_IFS
12156 test -z "$as_dir" && as_dir=.
12157 for ac_exec_ext in '' $ac_executable_extensions; do
12158 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
12159 ac_cv_prog_PTHREAD_CC="$ac_prog"
12160 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
12161 break 2
12162 fi
12163 done
12164 done
12165 IFS=$as_save_IFS
12166
12167 fi
12168 fi
12169 PTHREAD_CC=$ac_cv_prog_PTHREAD_CC
12170 if test -n "$PTHREAD_CC"; then
12171 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PTHREAD_CC" >&5
12172 $as_echo "$PTHREAD_CC" >&6; }
12173 else
12174 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
12175 $as_echo "no" >&6; }
12176 fi
12177
12178
12179 test -n "$PTHREAD_CC" && break
12180 done
12181 test -n "$PTHREAD_CC" || PTHREAD_CC="${CC}"
12182
12183 else
12184 PTHREAD_CC=$CC
12185 fi
12186 else
12187 PTHREAD_CC="$CC"
12188 fi
12189
12190
12191
12192
12193
12194 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
12195 if test x"$ax_pthread_ok" = xyes; then
12196 echo >/dev/null
12197 :
12198 else
12199 ax_pthread_ok=no
12200 echo "Your C compiler does not support POSIX threads."; exit 1
12201 fi
12202 ac_ext=c
12203 ac_cpp='$CPP $CPPFLAGS'
12204 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
12205 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
12206 ac_compiler_gnu=$ac_cv_c_compiler_gnu
12207
12208
12209
12210
11819 found=false 12211 found=false
11820 12212
11821 # Check whether --with-openssl was given. 12213 # Check whether --with-openssl was given.
11822 if test "${with_openssl+set}" = set; then : 12214 if test "${with_openssl+set}" = set; then :
11823 withval=$with_openssl; 12215 withval=$with_openssl;
12177 fi 12569 fi
12178 12570
12179 if test $WORKING_VERSION = "1"; then 12571 if test $WORKING_VERSION = "1"; then
12180 VERSION="$VERSION + `hg identify || (cat .hg_archival.txt | grep 'node\:') || echo ?`" 12572 VERSION="$VERSION + `hg identify || (cat .hg_archival.txt | grep 'node\:') || echo ?`"
12181 fi 12573 fi
12574
12575
12182 12576
12183 12577
12184 12578
12185 12579
12186 12580