xref: /PHP-5.3/win32/build/Makefile (revision a4979994)
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)"
25PHP_BUILD=$(PHP_BUILD)
26
27MCFILE=$(BUILD_DIR)\wsyslog.rc
28BUILD_DIR_DEV_NAME=php-$(PHP_VERSION_STRING)-devel-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE)
29BUILD_DIR_DEV=$(BUILD_DIR)\$(BUILD_DIR_DEV_NAME)
30
31all: generated_files $(EXT_TARGETS) $(PECL_TARGETS) $(SAPI_TARGETS)
32
33build_dirs: $(BUILD_DIR) $(BUILD_DIRS_SUB) $(BUILD_DIR_DEV)
34
35!if $(RE2C) == ""
36generated_files: build_dirs Zend\zend_ini_parser.c \
37	Zend\zend_language_parser.c \
38	$(PHPDEF) $(MCFILE)
39!else
40generated_files: build_dirs Zend\zend_ini_parser.c \
41	Zend\zend_language_parser.c Zend\zend_ini_scanner.c \
42	Zend\zend_language_scanner.c \
43	$(PHPDEF) $(MCFILE)
44!endif
45
46$(BUILD_DIR)\$(PHPDLL).def: $(PHP_DLL_DEF_SOURCES)
47	type $(PHP_DLL_DEF_SOURCES) > $(BUILD_DIR)\$(PHPDLL).def
48
49Zend\zend_ini_parser.c Zend\zend_ini_parser.h: Zend\zend_ini_parser.y
50	$(BISON) --output=Zend/zend_ini_parser.c -v -d -p ini_ Zend/zend_ini_parser.y
51
52Zend\zend_language_parser.c Zend\zend_language_parser.h: Zend\zend_language_parser.y
53	$(BISON) --output=Zend/zend_language_parser.c -v -d -p zend Zend/zend_language_parser.y
54
55!if $(RE2C) != ""
56Zend\zend_ini_scanner.c: Zend\zend_ini_scanner.l
57	$(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt Zend/zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l
58
59Zend\zend_language_scanner.c: Zend\zend_language_scanner.l
60	$(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt Zend/zend_language_scanner_defs.h -oZend/zend_language_scanner.c Zend/zend_language_scanner.l
61!endif
62
63PHPDLL_RES=$(BUILD_DIR)\$(PHPDLL).res
64
65$(MCFILE): win32\build\wsyslog.mc
66	$(MC) -h win32\ -r $(BUILD_DIR)\ -x $(BUILD_DIR)\ win32\build\wsyslog.mc
67
68#	$(RC) /fo $(MCFILE) $(BUILD_DIR)\wsyslog.rc
69
70!if $(MT) == ""
71_VC_MANIFEST_EMBED_EXE=
72_VC_MANIFEST_EMBED_DLL=
73!else
74_VC_MANIFEST_EMBED_EXE= if exist $@.manifest $(MT) -nologo -manifest $@.manifest -outputresource:$@;1
75_VC_MANIFEST_EMBED_DLL= if exist $@.manifest $(MT) -nologo -manifest $@.manifest -outputresource:$@;2
76!endif
77
78$(PHPDLL_RES): win32\build\template.rc
79	$(RC) /fo $(PHPDLL_RES) /d FILE_DESCRIPTION="\"PHP Script Interpreter\"" \
80		/d FILE_NAME="\"$(PHPDLL)\"" /d PRODUCT_NAME="\"PHP Script Interpreter\"" \
81		/I$(BUILD_DIR) /d MC_INCLUDE="\"$(MCFILE)\"" \
82		win32\build\template.rc
83
84$(BUILD_DIR)\$(PHPDLL): generated_files $(PHPDEF) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(PHPDLL_RES) $(MCFILE)
85	@$(CC) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(STATIC_EXT_LIBS) $(LIBS) $(PHPDLL_RES) /link /out:$(BUILD_DIR)\$(PHPDLL) $(PHP_LDFLAGS) $(LDFLAGS) $(STATIC_EXT_LDFLAGS)
86	-@$(_VC_MANIFEST_EMBED_DLL)
87
88$(BUILD_DIR)\$(PHPLIB): $(BUILD_DIR)\$(PHPDLL)
89
90$(BUILD_DIR) $(BUILD_DIRS_SUB) $(BUILD_DIR_DEV):
91	@echo Recreating build dirs
92	@if not exist $(BUILD_DIR) mkdir $(BUILD_DIR)
93	@cd $(BUILD_DIR)
94	@for %D in ($(BUILD_DIRS_SUB)) do @if not exist %D @mkdir %D > NUL
95	@if not exist $(BUILD_DIR_DEV) @mkdir $(BUILD_DIR_DEV) > NUL
96	@cd "$(PHP_SRC_DIR)"
97
98
99clean-sapi:
100	@echo Cleaning SAPI
101	@for %D in (_x $(EXT_TARGETS)) do @if exist $(BUILD_DIR)\%D @del /F /Q $(BUILD_DIR)\%D > NUL
102	@for %D in (_x $(PECL_TARGETS)) do @if exist $(BUILD_DIR)\%D @del /F /Q $(BUILD_DIR)\%D > NUL
103	@for %D in (_x $(SAPI_TARGETS)) do @if exist $(BUILD_DIR)\%D @del /F /Q $(BUILD_DIR)\%D > NUL
104	-@del /F /Q $(BUILD_DIR)\$(PHPDLL)
105
106clean: clean-sapi
107	@echo Cleaning distribution build dirs
108	@cd $(BUILD_DIR)
109	@for %D in (_x $(BUILD_DIRS_SUB)) do @if exist %D @del /F /Q %D\*.* > NUL
110	@cd "$(PHP_SRC_DIR)"
111	-@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
112	-rd /s /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING)
113
114clean-pecl:
115	@echo Cleaning PECL targets only
116	-rd /s /q $(BUILD_DIR)\pecl
117
118clean-all:
119	@echo Cleaning standard build dirs
120	@cd $(BUILD_DIR)
121	@for %D in (_x $(BUILD_DIRS_SUB)) do @if exist %D @rd /s /q %D
122	@cd "$(PHP_SRC_DIR)"
123	-@del /f /q $(BUILD_DIR)\*.res $(BUILD_DIR)\*.lib $(BUILD_DIR)\*.ilk $(BUILD_DIR)\*.pdb $(BUILD_DIR)\*.exp $(PHPDEF) $(BUILD_DIR)\*.rc $(BUILD_DIR)\*.dbg $(BUILD_DIR)\*.bin $(BUILD_DIR)\php*.dll $(BUILD_DIR)\php*.exe > NUL
124
125test:
126	"$(BUILD_DIR)\php.exe" -d open_basedir= -d output_buffering=0 run-tests.php $(TESTS) -p "$(BUILD_DIR)\php.exe"
127
128build-snap: generated_files
129	SET PATH=$(PATH);$(PHP_BUILD)\bin
130	@$(MAKE) "$(BUILD_DIR)\$(PHPDLL)"
131	-for %T in ($(SAPI_TARGETS)) do $(MAKE) /I /nologo "%T"
132	-for %T in ($(EXT_TARGETS)) do $(MAKE) /I /nologo "%T"
133	-for %T in ($(PECL_TARGETS)) do $(MAKE) /I /nologo "%T"
134
135build-dist: $(BUILD_DIR)\deplister.exe
136	-rd /s /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING)
137	-rd /s /q $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING)
138	-del /f /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip
139	-del /f /q $(BUILD_DIR)\php-debug-pack-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip
140	-del /f /q $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip
141	$(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)"
142	cd $(BUILD_DIR)\php-$(PHP_VERSION_STRING)
143	-$(ZIP) -9 -q -r ..\php-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip .
144	cd ..\..
145	cd $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING)
146	-$(ZIP) -9 -q -r ..\pecl-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip .
147	cd ..\..
148	cd $(BUILD_DIR)\php-test-pack-$(PHP_VERSION_STRING)
149	-$(ZIP) -9 -q -r ..\php-test-pack-$(PHP_VERSION_STRING).zip .
150	cd ..\..
151	cd $(BUILD_DIR)
152	-$(ZIP) -9 -q php-debug-pack-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip *.pdb
153	cd
154	cd
155	-$(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)
156	cd ..\..
157
158dist: all build-dist
159snap: build-snap build-devel build-dist
160
161$(BUILD_DIR)\deplister.exe:	win32\build\deplister.c
162	$(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
163
164msi-installer: dist
165	$(BUILD_DIR)\php.exe ..\php-installer\build-installer.php "$(BUILD_DIR)" "$(PHPDLL)" "$(SAPI_TARGETS)" "$(EXT_TARGETS)" "$(PECL_TARGETS)"
166
167# need to redirect, since INSTALL is a file in the root...
168install: really-install install-sdk
169
170build-lib:
171	@if not exist $(BUILD_DIR_DEV)\lib mkdir $(BUILD_DIR_DEV)\lib >nul
172	@copy $(BUILD_DIR)\$(PHPLIB) $(BUILD_DIR_DEV)\lib /y >nul
173
174build-devel: build-headers build-lib
175	@if not exist $(BUILD_DIR_DEV)\script mkdir $(BUILD_DIR_DEV)\script >nul
176	@if not exist $(BUILD_DIR_DEV)\build mkdir $(BUILD_DIR_DEV)\build >nul
177	@copy win32\build\confutils.js $(BUILD_DIR_DEV)\script\ /y >nul
178	@copy win32\build\configure.tail $(BUILD_DIR_DEV)\script\ /y >nul
179	@copy win32\build\config.w32.phpize.in $(BUILD_DIR_DEV)\script\ /y >nul
180	@copy win32\build\Makefile.phpize $(BUILD_DIR_DEV)\script\ /y >nul
181	@copy win32\build\phpize.bat $(BUILD_DIR_DEV)\ /y >nul
182	@copy win32\build\template.rc $(BUILD_DIR_DEV)\build\ /y >nul
183	@copy $(BUILD_DIR)\devel\config.phpize.js $(BUILD_DIR_DEV)\script\ /y >nul
184	@copy $(BUILD_DIR)\devel\phpize.js $(BUILD_DIR_DEV)\script\ /y >nul
185	@copy $(BUILD_DIR)\devel\ext_deps.js $(BUILD_DIR_DEV)\script\ /y >nul
186
187install-sdk: build-devel
188	@xcopy /Q /Y /E /I $(BUILD_DIR_DEV)\* $(PHP_PREFIX)\SDK
189
190really-install:
191	@if not exist $(PHP_PREFIX) mkdir $(PHP_PREFIX)
192	@echo Installing files under $(PHP_PREFIX)
193	@copy $(BUILD_DIR)\*.exe $(PHP_PREFIX) /y >nul
194	@copy $(BUILD_DIR)\*.dll $(PHP_PREFIX) /y >nul
195	@echo Registering event source with syslog (requires admin rights)
196	@echo It's okay for this step to fail:
197	-$(PHP_PREFIX)\php.exe -n -dextension_dir=$(PHP_PREFIX) win32/build/registersyslog.php $(PHP_PREFIX)\$(PHPDLL)
198
199