Skip to content

Commit 1601eed

Browse files
committed
Fix mbstring/libmbfl/config.h
This moves libmbfl configuration to mbstring extension level and syncs the include style used as of PHP-8.4 to be able to do simultaneous in-source and out-of-source builds. The HAVE_CONFIG_H file is when doing phpize build using Autotools. Checks for strcasecmp and strings.h are also moved to mbstring extension only. The libmbfl/config.h header is now also NOT installed anymore as it is a private header used only in C files as part of the build interface (during build phase only). The libmbfl/config.h is included with angled style so the include flags take precedence and simultaneous php-src building in-source and out-of-source can be performed.
1 parent f99ca63 commit 1601eed

File tree

10 files changed

+24
-26
lines changed

10 files changed

+24
-26
lines changed

.github/labeler.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,6 @@
443443
- 'ext/json/php_json_parser.h'
444444
- 'ext/json/php_json_scanner.h'
445445
- 'ext/libxml/php_libxml.h'
446-
- 'ext/mbstring/libmbfl/config.h'
447446
- 'ext/mbstring/libmbfl/mbfl/eaw_table.h'
448447
- 'ext/mbstring/libmbfl/mbfl/mbfilter.h'
449448
- 'ext/mbstring/libmbfl/mbfl/mbfilter_8bit.h'

configure.ac

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ AC_CHECK_HEADERS(m4_normalize([
389389
pty.h
390390
pwd.h
391391
resolv.h
392-
strings.h
393392
syslog.h
394393
sysexits.h
395394
sys/ioctl.h
@@ -587,7 +586,6 @@ AC_CHECK_FUNCS(m4_normalize([
587586
statfs
588587
statvfs
589588
std_syslog
590-
strcasecmp
591589
strptime
592590
strtok_r
593591
symlink

ext/mbstring/config.m4

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,15 @@ AC_DEFUN([PHP_MBSTRING_SETUP_MBREGEX], [
5252
PHP_INSTALL_HEADERS([ext/mbstring], [php_mbregex.h php_onig_compat.h])
5353
])
5454

55+
dnl
56+
dnl PHP_MBSTRING_SETUP_LIBMBFL
57+
dnl
58+
dnl Configure bundled libmbfl. It is required and cannot be disabled.
59+
dnl
5560
AC_DEFUN([PHP_MBSTRING_SETUP_LIBMBFL], [
56-
dnl
57-
dnl Bundled libmbfl is required and can not be disabled
58-
dnl
61+
AC_CHECK_HEADERS([strings.h])
62+
AC_CHECK_FUNCS([strcasecmp])
63+
5964
PHP_MBSTRING_ADD_BUILD_DIR([libmbfl])
6065
PHP_MBSTRING_ADD_BUILD_DIR([libmbfl/mbfl])
6166
PHP_MBSTRING_ADD_BUILD_DIR([libmbfl/filters])
@@ -103,7 +108,6 @@ AC_DEFUN([PHP_MBSTRING_SETUP_LIBMBFL], [
103108
])
104109
105110
PHP_INSTALL_HEADERS([ext/mbstring], m4_normalize([
106-
libmbfl/config.h
107111
libmbfl/mbfl/eaw_table.h
108112
libmbfl/mbfl/mbfilter_8bit.h
109113
libmbfl/mbfl/mbfilter_pass.h
@@ -144,7 +148,6 @@ if test "$PHP_MBSTRING" != "no"; then
144148

145149
AS_VAR_IF([PHP_MBREGEX], [yes], [PHP_MBSTRING_SETUP_MBREGEX])
146150

147-
dnl libmbfl is required
148151
PHP_MBSTRING_SETUP_LIBMBFL
149152

150153
PHP_NEW_EXTENSION([mbstring],
@@ -159,18 +162,15 @@ if test "$PHP_MBSTRING" != "no"; then
159162
done
160163

161164
for dir in $PHP_MBSTRING_EXTRA_INCLUDES; do
162-
PHP_ADD_INCLUDE([$ext_srcdir/$dir])
163165
PHP_ADD_INCLUDE([$ext_builddir/$dir])
166+
PHP_ADD_INCLUDE([$ext_srcdir/$dir])
164167
done
165168

166-
out="php_config.h"
167-
168-
if test "$ext_shared" != "no" && test -f "$ext_builddir/config.h.in"; then
169-
out="$abs_builddir/config.h"
170-
fi
171-
172169
cat > $ext_builddir/libmbfl/config.h <<EOF
173-
#include "$out"
170+
#ifdef HAVE_CONFIG_H
171+
# include <config.h>
172+
#endif
173+
#include <php_config.h>
174174
EOF
175175

176176
PHP_INSTALL_HEADERS([ext/mbstring], [mbstring.h])

ext/mbstring/config.w32

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ if (PHP_MBSTRING != "no") {
1212
STDOUT.WriteLine("Using bundled libmbfl...");
1313

1414
ADD_FLAG("CFLAGS_MBSTRING", "-Iext/mbstring -Iext/mbstring/libmbfl -Iext/mbstring/libmbfl/mbfl \
15-
/D HAVE_STRICMP /D MBFL_DLL_EXPORT=1 /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1")
15+
/D MBFL_DLL_EXPORT=1 /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1")
1616

1717
ADD_FLAG("CFLAGS_BD_EXT_MBSTRING", "/utf-8")
1818

19-
FSO.CopyFile("ext\\mbstring\\libmbfl\\config.h.w32",
20-
"ext\\mbstring\\libmbfl\\config.h", true);
19+
var mbfl_config = FSO.CreateTextFile("ext/mbstring/libmbfl/config.h", true);
20+
mbfl_config.WriteLine("#define HAVE_STRCASECMP 1");
21+
mbfl_config.WriteLine("#define HAVE_STRICMP 1");
22+
mbfl_config.WriteLine("#include <config.w32.h>");
23+
mbfl_config.Close();
2124

2225
ADD_SOURCES("ext/mbstring/libmbfl/filters", "html_entities.c \
2326
mbfilter_7bit.c mbfilter_base64.c \
@@ -37,7 +40,7 @@ if (PHP_MBSTRING != "no") {
3740
nls_kr.c nls_neutral.c nls_ru.c nls_uni.c nls_zh.c nls_hy.c \
3841
nls_ua.c nls_tr.c", "mbstring");
3942

40-
PHP_INSTALL_HEADERS("ext/mbstring", "mbstring.h libmbfl/config.h libmbfl/mbfl/eaw_table.h libmbfl/mbfl/mbfilter.h libmbfl/mbfl/mbfilter_8bit.h libmbfl/mbfl/mbfilter_pass.h libmbfl/mbfl/mbfilter_wchar.h libmbfl/mbfl/mbfl_consts.h libmbfl/mbfl/mbfl_convert.h libmbfl/mbfl/mbfl_defs.h libmbfl/mbfl/mbfl_encoding.h libmbfl/mbfl/mbfl_filter_output.h libmbfl/mbfl/mbfl_language.h libmbfl/mbfl/mbfl_memory_device.h libmbfl/mbfl/mbfl_string.h");
43+
PHP_INSTALL_HEADERS("ext/mbstring", "mbstring.h libmbfl/mbfl/eaw_table.h libmbfl/mbfl/mbfilter.h libmbfl/mbfl/mbfilter_8bit.h libmbfl/mbfl/mbfilter_pass.h libmbfl/mbfl/mbfilter_wchar.h libmbfl/mbfl/mbfl_consts.h libmbfl/mbfl/mbfl_convert.h libmbfl/mbfl/mbfl_defs.h libmbfl/mbfl/mbfl_encoding.h libmbfl/mbfl/mbfl_filter_output.h libmbfl/mbfl/mbfl_language.h libmbfl/mbfl/mbfl_memory_device.h libmbfl/mbfl/mbfl_string.h");
4144

4245
AC_DEFINE('HAVE_MBSTRING', 1, "Define to 1 if the PHP extension 'mbstring' is available.");
4346

ext/mbstring/libmbfl/config.h.w32

Lines changed: 0 additions & 1 deletion
This file was deleted.

ext/mbstring/libmbfl/mbfl/mbfl_encoding.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*
2929
*/
3030

31-
#include "libmbfl/config.h"
31+
#include <libmbfl/config.h>
3232

3333
#ifdef HAVE_STRINGS_H
3434
/* For strncasecmp */

ext/mbstring/libmbfl/mbfl/mbfl_language.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*
2929
*/
3030

31-
#include "libmbfl/config.h"
31+
#include <libmbfl/config.h>
3232

3333
#include <stddef.h>
3434
#include <string.h>

ext/mbstring/mbstring.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/* {{{ includes */
2121
#include <limits.h>
2222

23-
#include "libmbfl/config.h"
23+
#include <libmbfl/config.h>
2424
#include "php.h"
2525
#include "php_ini.h"
2626
#include "php_variables.h"

ext/mbstring/php_mbregex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
+----------------------------------------------------------------------+
1515
*/
1616

17-
#include "libmbfl/config.h"
17+
#include <libmbfl/config.h>
1818

1919
#include "php.h"
2020
#include "php_ini.h"

win32/build/config.w32.h.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
#undef HAVE_STRUCT_STAT_ST_BLOCKS
5959
#define HAVE_STRUCT_STAT_ST_RDEV 1
6060
#define HAVE_SHUTDOWN 1
61-
#define HAVE_STRCASECMP 1
6261
#define HAVE_UTIME 1
6362
#undef HAVE_DIRENT_H
6463
#define HAVE_FCNTL_H 1

0 commit comments

Comments
 (0)