/
Makefile
142 lines (118 loc) · 5.02 KB
/
Makefile
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
.DEFAULT_GOAL := help
version := 7.3.14
tz := "Asia/Tokyo"
PHP_NET_HOST := www.php.net
pecl_version := ""
export CXXFLAGS=-std=c++11
export PKG_CONFIG_PATH=$(shell brew --prefix openssl@1.1)/lib/pkgconfig
help: ## このヘルプを表示する
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: setup
setup: ~/.php/ ## スクリプトを色々セットアップ
~/.php/:
mkdir ~/.php/
echo export 'PATH=~/.php/current/bin:$PATH' >> ~/.bash_profile
brew install autoconf re2c bison icu4c openssl curl readline libxml2 libgd libpng libjpeg bzip2 libiconv zlib
.PHONY: current
current: ## 現在のphp version
@php -v
.PHONY: ls
ls: ## マシンにインストールされているphpの一覧を取得します version不要
@ls ~/.php/
.PHONY: ls-remote
ls-remote: ## インストールできそうなstable版phpの一覧を表示します version不要
@php phpversions.php
.PHONY: use
use: ## マシンのデフォルトphpをversionに変更します
@(cd ~/.php && rm current; ln -s $(version) current)
@php -v
.PHONY: clean
clean: ## 指定されたバージョンのディレクトリをmake cleanします
(cd php-$(version) && make clean distclean)
.PHONY: fullclean
fullclean: ## 指定されたバージョンの関連ファイルを完全削除します
rm -rf php-$(version)
rm -rf php-$(version).tar.bz2
.PHONY: uninstall
uninstall: ## 指定されたバージョンを~/.phpから削除します
rm -rf ~/.php/$(version)
.PHONY: download-qa
download-qa: ## download from qa.php.net. need $user & $version
curl -Lo php-$(version).tar.bz2 "http://downloads.php.net/~$(user)/php-$(version).tar.bz2"
# ~~~~~~~~
php-$(version).tar.bz2:
curl -Lo php-$(version).tar.bz2 "https://$(PHP_NET_HOST)/distributions/php-$(version).tar.bz2"
php-$(version): php-$(version).tar.bz2
tar xf php-$(version).tar.bz2
php-$(version)/sapi/cli/php: php-$(version)
(cd php-$(version) && \
./configure -C \
--prefix=$(HOME)/.php/$(version) \
--with-config-file-path=$(HOME)/.php/$(version)/etc/ \
--with-config-file-scan-dir=$(HOME)/.php/$(version)/etc/php/ \
--with-pear \
--disable-cgi \
--enable-phpdbg \
--enable-fpm \
--with-mysqli \
--enable-pcntl \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--enable-soap \
--enable-sockets \
--with-openssl="$(shell brew --prefix openssl@1.1)" \
--with-curl=$(shell brew --prefix curl) \
--with-readline=$(shell brew --prefix readline) \
--with-libxml-dir=$(shell brew --prefix libxml2) \
--with-gd \
--with-jpeg-dir=$(shell brew --prefix libjpeg) \
--with-png-dir=$(shell brew --prefix libpng) \
--with-bz2=$(shell brew --prefix bzip2) \
--with-zlib=$(shell brew --prefix zlib) \
--with-iconv=$(shell brew --prefix libiconv) \
--enable-mbstring \
--enable-mysqlnd \
--with-pdo-mysql \
--enable-re2c-cgoto && \
make -j$(shell sysctl -n hw.ncpu) )
~/.php/$(version): php-$(version)/sapi/cli/php
(cd php-$(version) && \
make install && \
cp php.ini-development ~/.php/$(version)/etc/php.ini && \
mkdir ~/.php/$(version)/etc/php && \
echo date.timezone = $(tz) >> ~/.php/$(version)/etc/php/timezone.ini \
)
.PHONY: pecl-ls
pecl-ls: ## currentバージョンに追加インストールされているpeclライブラリの一覧を出力します
@ls `~/.php/current/bin/php-config --extension-dir`
.PHONY: pecl
pecl: ~/.php/current/etc/php/$(pecl).ini ## peclライブラリをcurrentバージョンに対してインストールします。 make pecl pecl=memcached など。xdebugだけはmake xdebugでインストールしてください
.PHONY: pecl-build
pecl-build: ## peclライブラリをpeclコマンドではなくphpize & makeでインストールします。コンパイルオプションを手動で指定できます。 make pecl-build pecl=memcached options="--enable-memcached-igbinary"
~/.php/current/bin/pecl download $(pecl)$(pecl-version)
tar xf $(pecl)*.tgz
( cd $(pecl)* && \
~/.php/current/bin/phpize && \
./configure --with-php-config=${HOME}/.php/current/bin/php-config $(options) && \
make -j$(shell sysctl -n hw.ncpu) && make install && \
echo extension=$(pecl).so > ~/.php/current/etc/php/$(pecl).ini && \
cd .. && \
rm -rf $(pecl)* package.xml; \
)
.PHONY: pecl-uninstall
pecl-uninstall: ## インストール済みのpeclライブラリを削除します
~/.php/current/bin/pecl uninstall $(pecl)
rm -f ~/.php/current/etc/php/$(pecl).ini
~/.php/current/etc/php/$(pecl).ini:
~/.php/current/bin/pecl install $(pecl)$(pecl-version)
@echo extension=$(pecl).so > ~/.php/current/etc/php/$(pecl).ini
.PHONY: xdebug
xdebug: ~/.php/current/etc/php/xdebug.ini ## xdebugをcurrentバージョンに対してインストールします。 make xdebug だけでよいです
~/.php/current/etc/php/xdebug.ini:
~/.php/current/bin/pecl install xdebug
echo "zend_extension="`~/.php/current/bin/php-config --extension-dir`/xdebug.so > ~/.php/current/etc/php/xdebug.ini
.PHONY: install
install: ~/.php/$(version)
.PHONY: reinstall
reinstall: uninstall clean install