-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-osx
executable file
·106 lines (92 loc) · 2.97 KB
/
build-osx
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
#!/usr/bin/env bash
# Copyright (c) 2022, Manticore Software LTD (https://manticoresearch.com)
# This program is free software; you can redistribute it and/or modify
# it under the terms of the The PHP License, version 3.01. You should have
# received a copy of the license along with this program; if you did not,
# you can find it at https://www.php.net/license/3_01.txt
set -e
install_deps() {
brew install bash curl autoconf automake bison re2c zstd git openssl zlib cmake libzip librdkafka
OPENSSL_PREFIX="$(brew --prefix openssl)"
LIBRDKAFKA_PREFIX="$(brew --prefix librdkafka)"
OPENSSL_CFLAGS="-I${OPENSSL_PREFIX}/include"
OPENSSL_LIBS="-L${OPENSSL_PREFIX}/lib -lcrypto -lssl"
export OPENSSL_PREFIX OPENSSL_CFLAGS OPENSSL_LIBS
export PATH="${OPENSSL_PREFIX}/bin:${PATH}"
export LDFLAGS="-L${OPENSSL_PREFIX}/lib -L${LIBRDKAFKA_PREFIX}/lib"
export CPPFLAGS="-I${OPENSSL_PREFIX}/include -I${LIBRDKAFKA_PREFIX}/include"
export PKG_CONFIG_PATH="${OPENSSL_PREFIX}/lib/pkgconfig"
}
install_dev_deps() {
brew install libxml2 oniguruma libgmp
}
export -f install_deps install_dev_deps
. ./build-bash-base.sh "$@"
hide_dynamic_libs() {
! which brew && return
for lib in "$@"; do
LIB_PATH=$(brew --prefix "$lib")
if ls "$LIB_PATH"/lib/*.dylib; then
for f in "$LIB_PATH"/lib/*.dylib; do
mv "$f" "$f.bak"
done
fi
done
}
restore_dynamic_libs() {
! which brew && return
for lib in "$@"; do
LIB_PATH=$(brew --prefix "$lib")
if ls "$LIB_PATH"/lib/*.dylib.bak; then
for f in "$LIB_PATH"/lib/*.dylib.bak; do
mv "$f" "${f%*.bak}"
done
fi
done
}
# Leave only static libs on
hide_dynamic_libs zstd zlib
MAKE_LDFLAGS=
ENABLE_SHARED=yes
ENABLE_STATIC=no
if [[ "$BUILD_STATIC" == 1 ]]; then
MAKE_LDFLAGS=-ldl
ENABLE_SHARED=no
ENABLE_STATIC=yes
fi
# Bison version hack
bison_ver=$(bison --version | head -n1 | cut -d' ' -f4)
if [[ "$bison_ver" =~ ^2\.[0-9]+$ ]]; then
if which brew; then
bison=$(brew info bison | grep files | cut -d' ' -f1)
else
bison=$(test -d /usr/local/opt && echo "$_" || which /usr)
fi
export YACC="$bison/bin/bison"
fi
# Fix the path for the librdkafka
kafka_prefix=$(brew --prefix librdkafka)
sed "s|SEARCH_PATH=\"/usr/local /usr\"|SEARCH_PATH=\"${kafka_prefix}\"|" configure > configure-new
mv configure-new configure
chmod +x configure
./configure \
CFLAGS="-O3 -lresolv -Wno-implicit-function-declaration" \
--prefix="$BUILD_PREFIX" --disable-all \
--enable-shared=$ENABLE_SHARED --enable-static=$ENABLE_STATIC --with-layout=GNU \
--with-pear=no --disable-cgi --disable-phpdbg \
--with-pcre-jit --enable-zstd --with-libzstd \
--enable-pcntl --enable-posix \
--enable-sockets \
--enable-swoole \
--with-rdkafka \
--with-openssl --with-zlib --with-zip \
--enable-filter \
--with-curl \
--enable-opcache \
--enable-mbstring \
"${BUILD_EXTRA[@]}"
make LDFLAGS=$MAKE_LDFLAGS -j8
make install-cli
strip dist/bin/php
# Return skipped dynamic libs
restore_dynamic_libs zstd zlib