-
Notifications
You must be signed in to change notification settings - Fork 6
/
configure.in
109 lines (91 loc) · 3.31 KB
/
configure.in
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
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(PL/php, 1.4dev, [email protected])
AC_CONFIG_SRCDIR([plphp_io.c])
AC_CONFIG_HEADER([config.h])
# Checks for common programs.
AC_PROG_CC
AC_PROG_AWK
AC_PROG_GREP
AC_ARG_WITH([php], AC_HELP_STRING([--with-php=DIR],
[specify a path to the PHP installation]), [PHP_PATH=$withval])
AC_ARG_WITH([postgres], AC_HELP_STRING([--with-postgres=DIR],
[specify a path to the PostgreSQL installation]), [PG_PATH=$withval])
AC_ARG_ENABLE([debug], AC_HELP_STRING([--enable-debug],
[build with debug information]), [DEBUG="$enableval" ],[])
# Checks for header files.
AC_CHECK_HEADERS([fcntl.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
# Checks for library functions.
AC_CHECK_FUNCS([strcasecmp strdup])
AC_MSG_CHECKING([whether to build with debug information])
if test "$DEBUG" = "yes"; then
CPPFLAGS+="-g";
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
# check for pg_config
AC_PATH_PROG([PG_CONFIG], [pg_config], [], [$PG_PATH:$PG_PATH/bin:$PATH])
if test "$PG_CONFIG" = ""; then
AC_MSG_ERROR([Cannot locate pg_config])
fi
AC_SUBST(PG_CONFIG)
PGXS=$($PG_CONFIG --pgxs)
AC_CHECK_FILE($PGXS, [], AC_MSG_ERROR([file $PGXS doesn't exist]))
# ' hello text editor
AC_SUBST(PGXS)
# check for PostgreSQL version
AC_MSG_CHECKING([for PostgreSQL version])
PG_VERSION=$($PG_CONFIG --version|$AWK '{ print $2 }')
PG_MAJOR_VERSION=$(echo "$PG_VERSION"|$AWK -F. '{ print $1 }')
PG_MINOR_VERSION=$(echo "$PG_VERSION"|$AWK -F. '{ print substr($2,1,1) }')
AC_MSG_RESULT([$PG_VERSION])
STOP="no"
if test $PG_MAJOR_VERSION -lt 8 ; then
STOP="yes"
else
if test "$PG_MAJOR_VERSION" = 8 -a "$PG_MINOR_VERSION" -lt 1 ; then
STOP="yes"
fi
fi
if test "$STOP" = "yes"; then
AC_MSG_ERROR([PosgreSQL 8.1 or newer required])
fi
AC_DEFINE_UNQUOTED(PG_MAJOR_VERSION,$PG_MAJOR_VERSION,[PostgreSQL major version])
AC_DEFINE_UNQUOTED(PG_MINOR_VERSION,$PG_MINOR_VERSION,[PostgreSQL minor version])
# check for php-config
AC_PATH_PROGS([PHP_CONFIG], [php-config], [], [$PHP_PATH:$PHP_PATH/bin:$PATH])
if test "$PHP_CONFIG" = ""; then
AC_MSG_ERROR([Cannot locate php-config])
fi
LIBS="$LIBS $($PHP_CONFIG --libs)"
LDFLAGS="$LDFLAGS $($PHP_CONFIG --ldflags) -L$($PHP_CONFIG --prefix)/lib"
# we need php include files path to check for ZTS
CPPFLAGS="$CPPFLAGS $($PHP_CONFIG --includes)"
# checking if ZTS (zend thread safety) is enabled
AC_CHECK_DECL(ZTS, [zts_enabled="yes"], [zts_enabled="no"], [ #include "php_config.h" ])
if test "$zts_enabled" = "yes"; then
AC_MSG_ERROR([PL/php requires non thread-safe PHP build.
Please rebuild your PHP library with thread-safe support disabled])
fi
AC_MSG_CHECKING([whether PHP is compiled with the Embed SAPI])
$PHP_CONFIG --php-sapis | $GREP embed >/dev/null 2>&1
if test $? = 0; then
embed_sapi_present=yes
else
embed_sapi_present=no
fi
AC_MSG_RESULT([$embed_sapi_present])
if test "$embed_sapi_present" = "no"; then
AC_MSG_ERROR([PL/php requires the Embed PHP SAPI.
Please rebuild your PHP library with --enable-embed])
fi
# Checks for libraries.
AC_CHECK_LIB([php5], [php_module_startup],[], [have_php5="no"], [$PHP_LDFLAGS])
if test "$have_php5" = "no"; then
AC_MSG_ERROR([Cannot find PHP 5 SAPI library])
fi
AC_CONFIG_FILES([Makefile])
AC_OUTPUT