xref: /PHP-5.6/win32/build/Makefile (revision 72ac8cf5)
1#  +----------------------------------------------------------------------+
2#  | PHP Version 5                                                        |
3#  +----------------------------------------------------------------------+
4#  | Copyright (c) 1997-2016 The PHP Group                                |
5#  +----------------------------------------------------------------------+
6#  | This source file is subject to version 3.01 of the PHP license,      |
7#  | that is bundled with this package in the file LICENSE, and is        |
8#  | available through the world-wide-web at the following url:           |
9#  | http://www.php.net/license/3_01.txt                                  |
10#  | If you did not receive a copy of the PHP license and are unable to   |
11#  | obtain it through the world-wide-web, please send a note to          |
12#  | license@php.net so we can mail you a copy immediately.               |
13#  +----------------------------------------------------------------------+
14#  | Author: Wez Furlong <wez@thebrainroom.com>                           |
15#  +----------------------------------------------------------------------+
16#
17# $Id$
18# This is the makefile template for the win32 build
19
20CC="$(PHP_CL)"
21LD="$(LINK)"
22MC="$(MC)"
23MT="$(MT)"
24RE2C="$(RE2C)"
25PGOMGR="$(PGOMGR)"
26PHP_BUILD=$(PHP_BUILD)
27
28MCFILE=$(BUILD_DIR)\wsyslog.rc
29BUILD_DIR_DEV_NAME=php-$(PHP_VERSION_STRING)-devel-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE)
30BUILD_DIR_DEV=$(BUILD_DIR)\$(BUILD_DIR_DEV_NAME)
31
32all: generated_files $(EXT_TARGETS) $(PECL_TARGETS) $(SAPI_TARGETS)
33
34build_dirs: $(BUILD_DIR) $(BUILD_DIRS_SUB) $(BUILD_DIR_DEV)
35
36!if $(RE2C) == ""
37generated_files: build_dirs Zend\zend_ini_parser.c \
38	Zend\zend_language_parser.c \
39	$(PHPDEF) $(MCFILE)
40!else
41generated_files: build_dirs Zend\zend_ini_parser.c \
42	Zend\zend_language_parser.c Zend\zend_ini_scanner.c \
43	Zend\zend_language_scanner.c \
44	$(PHPDEF) $(MCFILE)
45!endif
46
47$(BUILD_DIR)\$(PHPDLL).def: $(PHP_DLL_DEF_SOURCES)
48	type $(PHP_DLL_DEF_SOURCES) > $(BUILD_DIR)\$(PHPDLL).def
49
50Zend\zend_ini_parser.c Zend\zend_ini_parser.h: Zend\zend_ini_parser.y
51	$(BISON) --output=Zend/zend_ini_parser.c -v -d -p ini_ Zend/zend_ini_parser.y
52
53Zend\zend_language_parser.c Zend\zend_language_parser.h: Zend\zend_language_parser.y
54	$(BISON) --output=Zend/zend_language_parser.c -v -d -p zend Zend/zend_language_parser.y
55
56!if $(RE2C) != ""
57Zend\zend_ini_scanner.c: Zend\zend_ini_scanner.l
58	$(RE2C) $(RE2C_FLAGS) --no-generation-date --case-inverted -cbdFt Zend/zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l
59
60Zend\zend_language_scanner.c: Zend\zend_language_scanner.l
61	$(RE2C) $(RE2C_FLAGS) --no-generation-date --case-inverted -cbdFt Zend/zend_language_scanner_defs.h -oZend/zend_language_scanner.c Zend/zend_language_scanner.l
62!endif
63
64!if $(PGOMGR) != ""
65PHP5_PGD_OPTION=/PGD:$(PGOPGD_DIR)\php5.pgd
66!else
67PHP5_PGD_OPTION=
68!endif
69
70PHPDLL_RES=$(BUILD_DIR)\$(PHPDLL).res
71
72$(MCFILE): win32\build\wsyslog.mc
73	$(MC) -h win32\ -r $(BUILD_DIR)\ -x $(BUILD_DIR)\ win32\build\wsyslog.mc
74
75#	$(RC) /fo $(MCFILE) $(BUILD_DIR)\wsyslog.rc
76
77!if $(MT) == ""
78_VC_MANIFEST_EMBED_EXE=
79_VC_MANIFEST_EMBED_DLL=
80!else
81_VC_MANIFEST_EMBED_EXE= if exist $@.manifest $(MT) -nologo -manifest $@.manifest -outputresource:$@;1
82_VC_MANIFEST_EMBED_DLL= if exist $@.manifest $(MT) -nologo -manifest $@.manifest -outputresource:$@;2
83!endif
84
85$(PHPDLL_RES): win32\build\template.rc
86	$(RC) /fo $(PHPDLL_RES) /d FILE_DESCRIPTION="\"PHP Script Interpreter\"" \
87		/d FILE_NAME="\"$(PHPDLL)\"" /d PRODUCT_NAME="\"PHP Script Interpreter\"" \
88		/I$(BUILD_DIR) /d MC_INCLUDE="\"$(MCFILE)\"" \
89		win32\build\template.rc
90
91$(BUILD_DIR)\$(PHPDLL): generated_files $(PHPDEF) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(PHPDLL_RES) $(MCFILE)
92	@copy win32\build\default.manifest $(BUILD_DIR)\$(PHPDLL).manifest
93	@$(CC) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(STATIC_EXT_LIBS) $(LIBS) $(PHPDLL_RES) /link /out:$(BUILD_DIR)\$(PHPDLL) $(PHP5_PGD_OPTION) $(PHP_LDFLAGS) $(LDFLAGS) $(STATIC_EXT_LDFLAGS)
94	-@$(_VC_MANIFEST_EMBED_DLL)
95
96$(BUILD_DIR)\$(PHPLIB): $(BUILD_DIR)\$(PHPDLL)
97
98$(BUILD_DIR) $(BUILD_DIRS_SUB) $(BUILD_DIR_DEV):
99	@echo Recreating build dirs
100	@if not exist $(BUILD_DIR) mkdir $(BUILD_DIR)
101	@cd $(BUILD_DIR)
102	@for %D in ($(BUILD_DIRS_SUB)) do @if not exist %D @mkdir %D > NUL
103	@if not exist $(BUILD_DIR_DEV) @mkdir $(BUILD_DIR_DEV) > NUL
104	@cd "$(PHP_SRC_DIR)"
105
106
107clean-sapi:
108	@echo Cleaning SAPI
109	@for %D in (_x $(EXT_TARGETS)) do @if exist $(BUILD_DIR)\%D @del /F /Q $(BUILD_DIR)\%D > NUL
110	@for %D in (_x $(PECL_TARGETS)) do @if exist $(BUILD_DIR)\%D @del /F /Q $(BUILD_DIR)\%D > NUL
111	@for %D in (_x $(SAPI_TARGETS)) do @if exist $(BUILD_DIR)\%D @del /F /Q $(BUILD_DIR)\%D > NUL
112	-@del /F /Q $(BUILD_DIR)\$(PHPDLL)
113
114clean: clean-sapi
115	@echo Cleaning distribution build dirs
116	@cd $(BUILD_DIR)
117	@for %D in (_x $(BUILD_DIRS_SUB)) do @if exist %D @del /F /Q %D\*.* > NUL
118	@cd "$(PHP_SRC_DIR)"
119	-@del /F /Q $(BUILD_DIR)\*.res $(BUILD_DIR)\*.manifest $(BUILD_DIR)\*.lib $(BUILD_DIR)\*.ilk $(BUILD_DIR)\*.pdb $(BUILD_DIR)\*.exp $(PHPDEF) $(BUILD_DIR)\php-$(PHP_VERSION_STRING)-Win32.zip $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING)-Win32.zip > NUL
120	-rd /s /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING)
121
122clean-pecl:
123	@echo Cleaning PECL targets only
124	-rd /s /q $(BUILD_DIR)\pecl
125
126clean-all:
127	@echo Cleaning standard build dirs
128	@cd $(BUILD_DIR)
129	@for %D in (_x $(BUILD_DIRS_SUB)) do @if exist %D @rd /s /q %D
130	@cd "$(PHP_SRC_DIR)"
131	-@del /f /q $(BUILD_DIR)\*.res $(BUILD_DIR)\*.lib $(BUILD_DIR)\*.ilk $(BUILD_DIR)\*.pdb $(BUILD_DIR)\*.exp $(PHPDEF) $(BUILD_DIR)\*.rc $(BUILD_DIR)\*.manifest $(BUILD_DIR)\*.dbg $(BUILD_DIR)\*.bin $(BUILD_DIR)\php*.dll $(BUILD_DIR)\php*.exe > NUL
132
133clean-pgo: clean-all
134	-rd /s /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING)
135	-rd /s /q $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING)
136	-rd /s /q $(BUILD_DIR)\php-test-pack-$(PHP_VERSION_STRING)
137	-del /f /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip
138	-del /f /q $(BUILD_DIR)\php-debug-pack-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip
139	-del /f /q $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip
140	-del /f /q $(BUILD_DIR)\php-test-pack-$(PHP_VERSION_STRING).zip
141
142test:
143	"$(BUILD_DIR)\php.exe" -d open_basedir= -d output_buffering=0 run-tests.php $(TESTS) -p "$(BUILD_DIR)\php.exe"
144
145build-snap: generated_files
146	SET PATH=$(PATH);$(PHP_BUILD)\bin
147	@$(MAKE) "$(BUILD_DIR)\$(PHPDLL)"
148	-for %T in ($(SAPI_TARGETS)) do $(MAKE) /I /nologo "%T"
149	-for %T in ($(EXT_TARGETS)) do $(MAKE) /I /nologo "%T"
150	-for %T in ($(PECL_TARGETS)) do $(MAKE) /I /nologo "%T"
151
152build-dist: $(BUILD_DIR)\deplister.exe
153	-rd /s /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING)
154	-rd /s /q $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING)
155	-del /f /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip
156	-del /f /q $(BUILD_DIR)\php-debug-pack-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip
157	-del /f /q $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip
158	$(BUILD_DIR)\php.exe -d date.timezone=UTC -n -dphar.readonly=0 win32/build/mkdist.php "$(BUILD_DIR)" "$(PHP_BUILD)" "$(PHPDLL)" "$(SAPI_TARGETS)" "$(EXT_TARGETS) $(PHP_EXTRA_DIST_FILES)" "$(PECL_TARGETS) $(PECL_EXTRA_DIST_FILES)" "$(SNAPSHOT_TEMPLATE)"
159	cd $(BUILD_DIR)\php-$(PHP_VERSION_STRING)
160	-$(ZIP) -9 -q -r ..\php-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip .
161	cd ..\..
162	cd $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING)
163	-$(ZIP) -9 -q -r ..\pecl-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip .
164	cd ..\..
165	cd $(BUILD_DIR)\php-test-pack-$(PHP_VERSION_STRING)
166	-$(ZIP) -9 -q -r ..\php-test-pack-$(PHP_VERSION_STRING).zip .
167	cd ..\..
168	cd $(BUILD_DIR)
169	-$(ZIP) -9 -q php-debug-pack-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip *.pdb
170	cd
171	cd
172	-$(ZIP) -9 -q -r php-devel-pack-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip $(BUILD_DIR_DEV_NAME)
173	cd ..\..
174
175dist: all build-dist
176snap: build-snap build-devel build-dist
177
178$(BUILD_DIR)\deplister.exe:	win32\build\deplister.c
179	$(PHP_CL) /Fo$(BUILD_DIR)\ /Fd$(BUILD_DIR)\ /Fp$(BUILD_DIR)\ /FR$(BUILD_DIR) /Fe$(BUILD_DIR)\deplister.exe win32\build\deplister.c imagehlp.lib
180
181msi-installer: dist
182	$(BUILD_DIR)\php.exe ..\php-installer\build-installer.php "$(BUILD_DIR)" "$(PHPDLL)" "$(SAPI_TARGETS)" "$(EXT_TARGETS)" "$(PECL_TARGETS)"
183
184# need to redirect, since INSTALL is a file in the root...
185install: really-install install-sdk
186
187build-lib: build-ext-libs
188	@if not exist $(BUILD_DIR_DEV)\lib mkdir $(BUILD_DIR_DEV)\lib >nul
189	@copy $(BUILD_DIR)\$(PHPLIB) $(BUILD_DIR_DEV)\lib /y >nul
190
191build-devel: build-headers build-lib
192	@if not exist $(BUILD_DIR_DEV)\script mkdir $(BUILD_DIR_DEV)\script >nul
193	@if not exist $(BUILD_DIR_DEV)\build mkdir $(BUILD_DIR_DEV)\build >nul
194	@copy run-tests.php $(BUILD_DIR_DEV)\script\ /y >nul
195	@copy win32\build\confutils.js $(BUILD_DIR_DEV)\script\ /y >nul
196	@copy win32\build\configure.tail $(BUILD_DIR_DEV)\script\ /y >nul
197	@copy win32\build\config.w32.phpize.in $(BUILD_DIR_DEV)\script\ /y >nul
198	@copy win32\build\Makefile.phpize $(BUILD_DIR_DEV)\script\ /y >nul
199	@copy win32\build\phpize.bat $(BUILD_DIR_DEV)\ /y >nul
200	@copy win32\build\template.rc $(BUILD_DIR_DEV)\build\ /y >nul
201	@copy win32\build\default.manifest $(BUILD_DIR_DEV)\build\ /y >nul
202	@copy $(BUILD_DIR)\devel\config.phpize.js $(BUILD_DIR_DEV)\script\ /y >nul
203	@copy $(BUILD_DIR)\devel\phpize.js $(BUILD_DIR_DEV)\script\ /y >nul
204	@copy $(BUILD_DIR)\devel\ext_deps.js $(BUILD_DIR_DEV)\script\ /y >nul
205
206install-sdk: build-devel
207	@xcopy /Q /Y /E /I $(BUILD_DIR_DEV)\* $(PHP_PREFIX)\SDK
208
209really-install:
210	@if not exist $(PHP_PREFIX) mkdir $(PHP_PREFIX)
211	@if not exist $(PHP_PREFIX)\ext mkdir $(PHP_PREFIX)\ext
212	@echo Installing files under $(PHP_PREFIX)
213	@copy $(BUILD_DIR)\*.exe $(PHP_PREFIX) /y >nul
214	@copy $(BUILD_DIR)\php_*.dll $(PHP_PREFIX)\ext /y >nul
215	dir /b $(BUILD_DIR)\php_*.dll > $(BUILD_DIR)\extension_dlls.txt
216	@xcopy $(BUILD_DIR)\*.dll /exclude:$(BUILD_DIR)\extension_dlls.txt $(PHP_PREFIX) /y >nul
217	@echo Registering event source with syslog (requires admin rights)
218	@echo It's okay for this step to fail:
219	-$(PHP_PREFIX)\php.exe -n -dextension_dir=$(PHP_PREFIX) win32/build/registersyslog.php $(PHP_PREFIX)\$(PHPDLL)
220
221