xref: /PHP-7.2/TSRM/tsrm.m4 (revision 902d39a3)
1m4_include([TSRM/m4/gethostbyname.m4])
2
3dnl TSRM_CHECK_GCC_ARG(ARG, ACTION-IF-FOUND, ACTION-IF-NOT_FOUND)
4AC_DEFUN([TSRM_CHECK_GCC_ARG],[
5  gcc_arg_name=[ac_cv_gcc_arg]translit($1,A-Z-,a-z_)
6  AC_CACHE_CHECK([whether $CC supports $1], [ac_cv_gcc_arg]translit($1,A-Z-,a-z_), [
7  echo 'void somefunc() { };' > conftest.c
8  cmd='$CC $1 -c conftest.c'
9  if eval $cmd 2>&1 | egrep -e $1 >/dev/null ; then
10    ac_result=no
11  else
12    ac_result=yes
13  fi
14  eval $gcc_arg_name=$ac_result
15  rm -f conftest.*
16  ])
17  if eval test "\$$gcc_arg_name" = "yes"; then
18    $2
19  else
20    :
21    $3
22  fi
23])
24
25AC_DEFUN([TSRM_BASIC_CHECKS],[
26
27AC_REQUIRE([AC_PROG_CC])dnl
28dnl AC_REQUIRE([AM_PROG_CC_STDC])dnl
29AC_REQUIRE([AC_PROG_CC_C_O])dnl
30AC_REQUIRE([AC_PROG_RANLIB])dnl
31
32AC_CHECK_HEADERS(stdarg.h)
33
34AC_CHECK_FUNCS(sigprocmask)
35
36AX_FUNC_WHICH_GETHOSTBYNAME_R()
37
38])
39
40
41AC_DEFUN([TSRM_CHECK_PTH],[
42
43AC_MSG_CHECKING(for GNU Pth)
44PTH_PREFIX="`$1 --prefix`"
45if test -z "$PTH_PREFIX"; then
46  AC_MSG_RESULT(Please check your Pth installation)
47fi
48
49CPPFLAGS="$CPPFLAGS `$1 --cflags`"
50LDFLAGS="$LDFLAGS `$1 --ldflags`"
51LIBS="$LIBS `$1 --libs`"
52
53AC_DEFINE(GNUPTH, 1, [Whether you use GNU Pth])
54AC_MSG_RESULT(yes - installed in $PTH_PREFIX)
55
56])
57
58AC_DEFUN([TSRM_CHECK_ST],[
59  if test -r "$1/include/st.h"; then
60    CPPFLAGS="$CPPFLAGS -I$1/include"
61    LDFLAGS="$LDFLAGS -L$1/lib"
62  elif test -r "$1/st.h"; then
63    CPPFLAGS="$CPPFLAGS -I$1"
64    LDFLAGS="$LDFLAGS -L$1"
65  fi
66  AC_CHECK_HEADERS(st.h,[],[
67    AC_MSG_ERROR([Sorry[,] I was unable to locate the State Threads header file.  Please specify the prefix using --with-tsrm-st=/prefix])
68  ])
69  LIBS="$LIBS -lst"
70  AC_MSG_CHECKING(for SGI's State Threads)
71  AC_MSG_RESULT(yes)
72  AC_DEFINE(TSRM_ST, 1, [ ])
73])
74
75sinclude(threads.m4)
76
77AC_DEFUN([TSRM_CHECK_PTHREADS],[
78
79PTHREADS_CHECK
80
81if test "$beos_threads" = "1"; then
82  AC_DEFINE(BETHREADS, 1, Whether to use native BeOS threads)
83else
84  if test "$pthreads_working" != "yes"; then
85    AC_MSG_ERROR(Your system seems to lack POSIX threads.)
86  fi
87
88  AC_DEFINE(PTHREADS, 1, Whether to use Pthreads)
89
90  AC_MSG_CHECKING(for POSIX threads)
91  AC_MSG_RESULT(yes)
92fi
93])
94
95AC_DEFUN([TSRM_THREADS_CHECKS],[
96
97dnl For the thread implementations, we always use --with-*
98dnl to maintain consistency
99
100AC_ARG_WITH(tsrm-pth,
101[  --with-tsrm-pth[=pth-config]
102                          Use GNU Pth],[
103  TSRM_PTH=$withval
104],[
105  TSRM_PTH=no
106])
107
108AC_ARG_WITH(tsrm-st,
109[  --with-tsrm-st          Use SGI's State Threads],[
110  TSRM_ST=$withval
111],[
112  TSRM_ST=no
113])
114
115AC_ARG_WITH(tsrm-pthreads,
116[  --with-tsrm-pthreads    Use POSIX threads (default)],[
117  TSRM_PTHREADS=$withval
118],[
119  TSRM_PTHREADS=yes
120])
121
122test "$TSRM_PTH" = "yes" && TSRM_PTH=pth-config
123
124if test "$TSRM_PTH" != "no"; then
125  TSRM_CHECK_PTH($TSRM_PTH)
126elif test "$TSRM_ST" != "no"; then
127  TSRM_CHECK_ST($TSRM_ST)
128elif test "$TSRM_PTHREADS" != "no"; then
129  TSRM_CHECK_PTHREADS
130fi
131
132])
133