forked from FirebirdSQL/php-firebird
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.m4
More file actions
executable file
·171 lines (147 loc) · 6.32 KB
/
Copy pathconfig.m4
File metadata and controls
executable file
·171 lines (147 loc) · 6.32 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
PHP_ARG_WITH([firebird],
[for Firebird support],
[AS_HELP_STRING([[--with-firebird[=DIR]]],
[Include Firebird support. DIR is the Firebird base install directory
[/opt/firebird]])])
if test "$PHP_FIREBIRD" != "no"; then
dnl Detect php-firebird version from git or VERSION file
AC_MSG_CHECKING([for php-firebird version])
if test -f "$srcdir/VERSION.txt"; then
PHP_FIREBIRD_VERSION=`cat "$srcdir/VERSION.txt" | tr -d ' \n\r\t'`
elif test -d "$srcdir/.git" -a -x "`which git 2>/dev/null`"; then
PHP_FIREBIRD_VERSION=`cd "$srcdir" && git describe --tags --always --dirty 2>/dev/null | sed 's/^v//'`
if test -z "$PHP_FIREBIRD_VERSION"; then
PHP_FIREBIRD_VERSION="0.0.0-unknown"
fi
else
PHP_FIREBIRD_VERSION="0.0.0-unknown"
fi
AC_MSG_RESULT([$PHP_FIREBIRD_VERSION])
AC_DEFINE_UNQUOTED([PHP_FIREBIRD_VERSION_STRING], ["$PHP_FIREBIRD_VERSION"], [PHP Firebird extension version])
dnl Check for minimum PHP version (8.2+)
AC_MSG_CHECKING([for minimum PHP version 8.2])
PHP_FIREBIRD_PHP_VERSION=`$PHP_CONFIG --version`
old_IFS=$IFS
IFS=.
set -- $PHP_FIREBIRD_PHP_VERSION
IFS=$old_IFS
php_major=$1
php_minor=$2
if test "$php_major" -lt 8 -o \( "$php_major" -eq 8 -a "$php_minor" -lt 2 \); then
AC_MSG_ERROR([PHP Firebird extension requires PHP 8.2 or later. Current version: $PHP_FIREBIRD_PHP_VERSION])
fi
AC_MSG_RESULT([yes (PHP $PHP_FIREBIRD_PHP_VERSION)])
AC_PATH_PROG(FB_CONFIG, fb_config, no)
if test -x "$FB_CONFIG" && test "$PHP_FIREBIRD" = "yes"; then
AC_MSG_CHECKING(for libfbconfig)
FB_CFLAGS=`$FB_CONFIG --cflags`
FB_LIBDIR=`$FB_CONFIG --libs`
FB_VERSION=`$FB_CONFIG --version`
AC_MSG_RESULT(version $FB_VERSION)
dnl Check for minimum Firebird version (3.0+)
AC_MSG_CHECKING([for minimum Firebird version 3.0])
fb_major=`echo $FB_VERSION | cut -d. -f1`
if test "$fb_major" -lt 3; then
AC_MSG_ERROR([Firebird 3.0 or later is required. Found version: $FB_VERSION])
fi
AC_MSG_RESULT([yes (Firebird $FB_VERSION)])
PHP_EVAL_LIBLINE($FB_LIBDIR, FIREBIRD_SHARED_LIBADD)
PHP_EVAL_INCLINE($FB_CFLAGS)
else
if test "$PHP_FIREBIRD" = "yes"; then
FIREBIRD_INCDIR=/opt/firebird/include
FIREBIRD_LIBDIR=/opt/firebird/lib
else
FIREBIRD_INCDIR=$PHP_FIREBIRD/include
FIREBIRD_LIBDIR=$PHP_FIREBIRD/$PHP_LIBDIR
fi
PHP_CHECK_LIBRARY(fbclient, isc_detach_database,
[
FIREBIRD_LIBNAME=fbclient
], [
PHP_CHECK_LIBRARY(gds, isc_detach_database,
[
FIREBIRD_LIBNAME=gds
], [
PHP_CHECK_LIBRARY(ib_util, isc_detach_database,
[
FIREBIRD_LIBNAME=ib_util
], [
AC_MSG_ERROR([libfbclient, libgds or libib_util not found! Check config.log for more information.])
], [
-L$FIREBIRD_LIBDIR
])
], [
-L$FIREBIRD_LIBDIR
])
], [
-L$FIREBIRD_LIBDIR
])
PHP_ADD_LIBRARY_WITH_PATH($FIREBIRD_LIBNAME, $FIREBIRD_LIBDIR, FIREBIRD_SHARED_LIBADD)
PHP_ADD_INCLUDE($FIREBIRD_INCDIR)
fi
AC_DEFINE(HAVE_FIREBIRD,1,[ ])
dnl Base source files (always compiled)
FIREBIRD_SOURCES="firebird.c fbird_error.c fbird_connection.c fbird_transaction.c fbird_batch.c fbird_query_exec.c fbird_query_prepare.c fbird_query_bind.c fbird_query_array.c fbird_datetime.c fbird_result.c fbird_metadata.c fbird_service.c fbird_events.c fbird_blobs.c fbird_inspection.c fbird_classes.c fbird_class_connection.c fbird_class_transaction.c fbird_class_statement.c fbird_class_resultset.c fbird_class_blob.c fbird_class_service.c fbird_class_event.c fbird_class_batch.c fbird_class_decfloat.c"
PHP_NEW_EXTENSION(firebird, $FIREBIRD_SOURCES, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1,[cxx])
PHP_SUBST(FIREBIRD_SHARED_LIBADD)
dnl Compiler hardening flags (Issue #164)
FIREBIRD_CFLAGS=""
AX_CHECK_COMPILE_FLAG(-Wall, [FIREBIRD_CFLAGS="$FIREBIRD_CFLAGS -Wall"])
AX_CHECK_COMPILE_FLAG(-Wextra, [FIREBIRD_CFLAGS="$FIREBIRD_CFLAGS -Wextra"])
AX_CHECK_COMPILE_FLAG(-Wformat-security, [FIREBIRD_CFLAGS="$FIREBIRD_CFLAGS -Wformat-security"])
AX_CHECK_COMPILE_FLAG(-Wno-unused-parameter, [FIREBIRD_CFLAGS="$FIREBIRD_CFLAGS -Wno-unused-parameter"])
AX_CHECK_COMPILE_FLAG(-fstack-protector-strong, [FIREBIRD_CFLAGS="$FIREBIRD_CFLAGS -fstack-protector-strong"])
dnl Pin C standard to gnu17 (Issue #165)
AX_CHECK_COMPILE_FLAG(-std=gnu17, [FIREBIRD_CFLAGS="$FIREBIRD_CFLAGS -std=gnu17"])
dnl Link-Time Optimization (LTO) — enabled by default, opt out with --disable-fbird-lto
AC_ARG_ENABLE([fbird-lto],
[AS_HELP_STRING([--disable-fbird-lto],
[Disable LTO for the firebird extension [default=enabled]])],
[PHP_FBIRD_LTO=$enableval],
[PHP_FBIRD_LTO=yes])
if test "$PHP_FBIRD_LTO" != "no"; then
dnl Auto-disable LTO on PHP < 8.3 (libtool 1.5.26 strips -flto flags,
dnl causing link failures and test regressions. Fixed upstream in PHP
dnl master via PR #21067 (libtool 2.5.4), not backported to 8.2.)
if test "$php_major" -eq 8 -a "$php_minor" -lt 3; then
AC_MSG_NOTICE([PHP 8.2 detected - disabling LTO (libtool incompatibility)])
PHP_FBIRD_LTO=no
fi
fi
if test "$PHP_FBIRD_LTO" != "no"; then
dnl Auto-disable LTO when sanitizers are active (incompatible — linker failures)
case "$CFLAGS" in
*-fsanitize=*)
AC_MSG_NOTICE([Sanitizer detected in CFLAGS - disabling LTO (incompatible)])
PHP_FBIRD_LTO=no
;;
esac
fi
if test "$PHP_FBIRD_LTO" != "no"; then
dnl GCC supports -flto=auto (parallel LTO), Clang uses -flto (no =auto suffix)
AX_CHECK_COMPILE_FLAG([-flto=auto], [
FIREBIRD_CFLAGS="$FIREBIRD_CFLAGS -flto=auto"
LDFLAGS="$LDFLAGS -flto=auto"
], [
AX_CHECK_COMPILE_FLAG([-flto], [
FIREBIRD_CFLAGS="$FIREBIRD_CFLAGS -flto"
LDFLAGS="$LDFLAGS -flto"
])
])
fi
dnl -D_FORTIFY_SOURCE=2 requires -O1 minimum (PHP defaults to -O2)
CFLAGS="$CFLAGS $FIREBIRD_CFLAGS -D_FORTIFY_SOURCE=2"
PHP_REQUIRE_CXX()
PHP_CXX_COMPILE_STDCXX([17], [mandatory], [PHP_FIREBIRD_STDCXX])
PHP_FIREBIRD_CXX_SOURCES="firebird_utils.cpp"
AS_VAR_IF([ext_shared], [no],
[PHP_ADD_SOURCES([$ext_dir],
[$PHP_FIREBIRD_CXX_SOURCES],
[$PHP_FIREBIRD_STDCXX])],
[PHP_ADD_SOURCES_X([$ext_dir],
[$PHP_FIREBIRD_CXX_SOURCES],
[$PHP_FIREBIRD_STDCXX],
[shared_objects_firebird],
[yes])])
fi