xref: /PHP-5.4/win32/build/Makefile (revision c5ccaf1d)
1#  +----------------------------------------------------------------------+
2#  | PHP Version 5                                                        |
3#  +----------------------------------------------------------------------+
4#  | Copyright (c) 1997-2008 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) --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) --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	@$(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)
93	-@$(_VC_MANIFEST_EMBED_DLL)
94
95$(BUILD_DIR)\$(PHPLIB): $(BUILD_DIR)\$(PHPDLL)
96
97$(BUILD_DIR) $(BUILD_DIRS_SUB) $(BUILD_DIR_DEV):
98	@echo Recreating build dirs
99	@if not exist $(BUILD_DIR) mkdir $(BUILD_DIR)
100	@cd $(BUILD_DIR)
101	@for %D in ($(BUILD_DIRS_SUB)) do @if not exist %D @mkdir %D > NUL
102	@if not exist $(BUILD_DIR_DEV) @mkdir $(BUILD_DIR_DEV) > NUL
103	@cd "$(PHP_SRC_DIR)"
104
105
106clean-sapi:
107	@echo Cleaning SAPI
108	@for %D in (_x $(EXT_TARGETS)) do @if exist $(BUILD_DIR)\%D @del /F /Q $(BUILD_DIR)\%D > NUL
109	@for %D in (_x $(PECL_TARGETS)) do @if exist $(BUILD_DIR)\%D @del /F /Q $(BUILD_DIR)\%D > NUL
110	@for %D in (_x $(SAPI_TARGETS)) do @if exist $(BUILD_DIR)\%D @del /F /Q $(BUILD_DIR)\%D > NUL
111	-@del /F /Q $(BUILD_DIR)\$(PHPDLL)
112
113clean: clean-sapi
114	@echo Cleaning distribution build dirs
115	@cd $(BUILD_DIR)
116	@for %D in (_x $(BUILD_DIRS_SUB)) do @if exist %D @del /F /Q %D\*.* > NUL
117	@cd "$(PHP_SRC_DIR)"
118	-@del /F /Q $(BUILD_DIR)\*.res $(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
119	-rd /s /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING)
120
121clean-pecl:
122	@echo Cleaning PECL targets only
123	-rd /s /q $(BUILD_DIR)\pecl
124
125clean-all:
126	@echo Cleaning standard build dirs
127	@cd $(BUILD_DIR)
128	@for %D in (_x $(BUILD_DIRS_SUB)) do @if exist %D @rd /s /q %D
129	@cd "$(PHP_SRC_DIR)"
130	-@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
131
132clean-pgo: clean-all
133	-rd /s /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING)
134	-rd /s /q $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING)
135	-rd /s /q $(BUILD_DIR)\php-test-pack-$(PHP_VERSION_STRING)
136	-del /f /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip
137	-del /f /q $(BUILD_DIR)\php-debug-pack-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip
138	-del /f /q $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip
139	-del /f /q $(BUILD_DIR)\php-test-pack-$(PHP_VERSION_STRING).zip
140
141test:
142	"$(BUILD_DIR)\php.exe" -d open_basedir= -d output_buffering=0 run-tests.php $(TESTS) -p "$(BUILD_DIR)\php.exe"
143
144build-snap: generated_files
145	SET PATH=$(PATH);$(PHP_BUILD)\bin
146	@$(MAKE) "$(BUILD_DIR)\$(PHPDLL)"
147	-for %T in ($(SAPI_TARGETS)) do $(MAKE) /I /nologo "%T"
148	-for %T in ($(EXT_TARGETS)) do $(MAKE) /I /nologo "%T"
149	-for %T in ($(PECL_TARGETS)) do $(MAKE) /I /nologo "%T"
150
151build-dist: $(BUILD_DIR)\deplister.exe
152	-rd /s /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING)
153	-rd /s /q $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING)
154	-del /f /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip
155	-del /f /q $(BUILD_DIR)\php-debug-pack-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip
156	-del /f /q $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip
157	$(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)"
158	cd $(BUILD_DIR)\php-$(PHP_VERSION_STRING)
159	-$(ZIP) -9 -q -r ..\php-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip .
160	cd ..\..
161	cd $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING)
162	-$(ZIP) -9 -q -r ..\pecl-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip .
163	cd ..\..
164	cd $(BUILD_DIR)\php-test-pack-$(PHP_VERSION_STRING)
165	-$(ZIP) -9 -q -r ..\php-test-pack-$(PHP_VERSION_STRING).zip .
166	cd ..\..
167	cd $(BUILD_DIR)
168	-$(ZIP) -9 -q php-debug-pack-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip *.pdb
169	cd
170	cd
171	-$(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)
172	cd ..\..
173
174dist: all build-dist
175snap: build-snap build-devel build-dist
176
177$(BUILD_DIR)\deplister.exe:	win32\build\deplister.c
178	$(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
179
180msi-installer: dist
181	$(BUILD_DIR)\php.exe ..\php-installer\build-installer.php "$(BUILD_DIR)" "$(PHPDLL)" "$(SAPI_TARGETS)" "$(EXT_TARGETS)" "$(PECL_TARGETS)"
182
183# need to redirect, since INSTALL is a file in the root...
184install: really-install install-sdk
185
186build-lib: build-ext-libs
187	@if not exist $(BUILD_DIR_DEV)\lib mkdir $(BUILD_DIR_DEV)\lib >nul
188	@copy $(BUILD_DIR)\$(PHPLIB) $(BUILD_DIR_DEV)\lib /y >nul
189
190build-devel: build-headers build-lib
191	@if not exist $(BUILD_DIR_DEV)\script mkdir $(BUILD_DIR_DEV)\script >nul
192	@if not exist $(BUILD_DIR_DEV)\build mkdir $(BUILD_DIR_DEV)\build >nul
193	@copy win32\build\confutils.js $(BUILD_DIR_DEV)\script\ /y >nul
194	@copy win32\build\configure.tail $(BUILD_DIR_DEV)\script\ /y >nul
195	@copy win32\build\config.w32.phpize.in $(BUILD_DIR_DEV)\script\ /y >nul
196	@copy win32\build\Makefile.phpize $(BUILD_DIR_DEV)\script\ /y >nul
197	@copy win32\build\phpize.bat $(BUILD_DIR_DEV)\ /y >nul
198	@copy win32\build\template.rc $(BUILD_DIR_DEV)\build\ /y >nul
199	@copy $(BUILD_DIR)\devel\config.phpize.js $(BUILD_DIR_DEV)\script\ /y >nul
200	@copy $(BUILD_DIR)\devel\phpize.js $(BUILD_DIR_DEV)\script\ /y >nul
201	@copy $(BUILD_DIR)\devel\ext_deps.js $(BUILD_DIR_DEV)\script\ /y >nul
202
203install-sdk: build-devel
204	@xcopy /Q /Y /E /I $(BUILD_DIR_DEV)\* $(PHP_PREFIX)\SDK
205
206really-install:
207	@if not exist $(PHP_PREFIX) mkdir $(PHP_PREFIX)
208	@echo Installing files under $(PHP_PREFIX)
209	@copy $(BUILD_DIR)\*.exe $(PHP_PREFIX) /y >nul
210	@copy $(BUILD_DIR)\*.dll $(PHP_PREFIX) /y >nul
211	@echo Registering event source with syslog (requires admin rights)
212	@echo It's okay for this step to fail:
213	-$(PHP_PREFIX)\php.exe -n -dextension_dir=$(PHP_PREFIX) win32/build/registersyslog.php $(PHP_PREFIX)\$(PHPDLL)
214
215