1# +----------------------------------------------------------------------+ 2# | PHP Version 7 | 3# +----------------------------------------------------------------------+ 4# | Copyright (c) 1997-2017 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 32!if "$(DEBUGGER)" == "1" 33DEBUGGER_CMD=devenv 34DEBUGGER_ARGS=/debugexe 35!else 36DEBUGGER_CMD= 37DEBUGGER_ARGS= 38!endif 39 40all: generated_files $(EXT_TARGETS) $(PECL_TARGETS) $(SAPI_TARGETS) 41 42build_dirs: $(BUILD_DIR) $(BUILD_DIRS_SUB) $(BUILD_DIR_DEV) 43 44!if $(RE2C) == "" 45generated_files: build_dirs Zend\zend_ini_parser.c \ 46 Zend\zend_language_parser.c \ 47 sapi\phpdbg\phpdbg_parser.c \ 48 $(PHPDEF) $(MCFILE) 49!else 50generated_files: build_dirs Zend\zend_ini_parser.c \ 51 Zend\zend_language_parser.c Zend\zend_ini_scanner.c \ 52 Zend\zend_language_scanner.c \ 53 sapi\phpdbg\phpdbg_parser.c sapi\phpdbg\phpdbg_lexer.c \ 54 $(PHPDEF) $(MCFILE) 55!endif 56 57$(BUILD_DIR)\$(PHPDLL).def: $(PHP_DLL_DEF_SOURCES) 58 type $(PHP_DLL_DEF_SOURCES) > $(BUILD_DIR)\$(PHPDLL).def 59 60Zend\zend_ini_parser.c Zend\zend_ini_parser.h: Zend\zend_ini_parser.y 61 $(BISON) --output=Zend/zend_ini_parser.c -v -d -p ini_ Zend/zend_ini_parser.y 62 63Zend\zend_language_parser.c Zend\zend_language_parser.h: Zend\zend_language_parser.y 64 $(BISON) --output=Zend/zend_language_parser.c -v -d -p zend Zend/zend_language_parser.y 65 @if "$(SED)" neq "" $(SED) -i "s,^int zendparse\(.*\),ZEND_API int zendparse\1,g" Zend/zend_language_parser.c 66 @if "$(SED)" neq "" $(SED) -i "s,^int zendparse\(.*\),ZEND_API int zendparse\1,g" Zend/zend_language_parser.h 67 @if "$(SED)" neq "" $(SED) -i "s,^#ifndef YYTOKENTYPE,#include \"zend.h\"\n#ifndef YYTOKENTYPE,g" Zend/zend_language_parser.h 68 69sapi\phpdbg\phpdbg_parser.c sapi\phpdbg\phpdbg_parser.h: sapi\phpdbg\phpdbg_parser.y 70 $(BISON) --output=sapi/phpdbg/phpdbg_parser.c -v -d -p phpdbg_ sapi/phpdbg/phpdbg_parser.y 71 72!if $(RE2C) != "" 73Zend\zend_ini_scanner.c: Zend\zend_ini_scanner.l 74 $(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 75 76Zend\zend_language_scanner.c: Zend\zend_language_scanner.l 77 $(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 78 79sapi\phpdbg\phpdbg_lexer.c: sapi\phpdbg\phpdbg_lexer.l 80 $(RE2C) $(RE2C_FLAGS) --no-generation-date -cbdFo sapi/phpdbg/phpdbg_lexer.c sapi/phpdbg/phpdbg_lexer.l 81!endif 82 83!if "$(ZTS)" == "1" 84PHP7_PGD_SUFFIX=ts 85!else 86PHP7_PGD_SUFFIX= 87!endif 88 89!if $(PGOMGR) != "" 90PHP7_PGD_OPTION=/PGD:$(PGOPGD_DIR)\php7$(PHP7_PGD_SUFFIX).pgd 91!else 92PHP7_PGD_OPTION= 93!endif 94 95PHPDLL_RES=$(BUILD_DIR)\$(PHPDLL).res 96 97$(MCFILE): win32\build\wsyslog.mc 98 $(MC) -h win32\ -r $(BUILD_DIR)\ -x $(BUILD_DIR)\ win32\build\wsyslog.mc 99 100# $(RC) /fo $(MCFILE) $(BUILD_DIR)\wsyslog.rc 101 102!if $(MT) == "" 103_VC_MANIFEST_EMBED_EXE= 104_VC_MANIFEST_EMBED_DLL= 105!else 106_VC_MANIFEST_EMBED_EXE= if exist $@.manifest $(MT) -nologo -manifest $@.manifest -outputresource:$@;1 107_VC_MANIFEST_EMBED_DLL= if exist $@.manifest $(MT) -nologo -manifest $@.manifest -outputresource:$@;2 108!endif 109 110$(PHPDLL_RES): win32\build\template.rc 111 $(RC) /nologo /fo $(PHPDLL_RES) /d FILE_DESCRIPTION="\"PHP Script Interpreter\"" \ 112 /d FILE_NAME="\"$(PHPDLL)\"" /d PRODUCT_NAME="\"PHP Script Interpreter\"" \ 113 /I$(BUILD_DIR) /d MC_INCLUDE="\"$(MCFILE)\"" \ 114 win32\build\template.rc 115 116$(BUILD_DIR)\$(PHPDLL): generated_files $(PHPDEF) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(PHPDLL_RES) $(MCFILE) 117 @copy win32\build\default.manifest $(BUILD_DIR)\$(PHPDLL).manifest >nul 118# @$(CC) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(STATIC_EXT_LIBS) $(LIBS) $(PHPDLL_RES) /link /out:$(BUILD_DIR)\$(PHPDLL) $(PHP7_PGD_OPTION) $(PHP_LDFLAGS) $(LDFLAGS) $(STATIC_EXT_LDFLAGS) 119 @"$(LINK)" $(PHP_GLOBAL_OBJS_RESP) $(STATIC_EXT_OBJS_RESP) $(STATIC_EXT_LIBS) $(LIBS) $(PHPDLL_RES) /out:$(BUILD_DIR)\$(PHPDLL) $(PHP7_PGD_OPTION) $(PHP_LDFLAGS) $(LDFLAGS) $(STATIC_EXT_LDFLAGS) 120 -@$(_VC_MANIFEST_EMBED_DLL) 121 122$(BUILD_DIR)\$(PHPLIB): $(BUILD_DIR)\$(PHPDLL) 123 124$(BUILD_DIR) $(BUILD_DIRS_SUB) $(BUILD_DIR_DEV): 125 @echo Recreating build dirs 126 @if not exist $(BUILD_DIR) mkdir $(BUILD_DIR) 127 @cd $(BUILD_DIR) 128 @for %D in ($(BUILD_DIRS_SUB)) do @if not exist %D @mkdir %D > NUL 129 @if not exist $(BUILD_DIR_DEV) @mkdir $(BUILD_DIR_DEV) > NUL 130 @cd "$(PHP_SRC_DIR)" 131 132 133clean-sapi: 134 @echo Cleaning SAPI 135 @for %D in (_x $(EXT_TARGETS)) do @if exist $(BUILD_DIR)\%D @del /F /Q $(BUILD_DIR)\%D > NUL 136 @for %D in (_x $(PECL_TARGETS)) do @if exist $(BUILD_DIR)\%D @del /F /Q $(BUILD_DIR)\%D > NUL 137 @for %D in (_x $(SAPI_TARGETS)) do @if exist $(BUILD_DIR)\%D @del /F /Q $(BUILD_DIR)\%D > NUL 138 -@del /F /Q $(BUILD_DIR)\$(PHPDLL) 139 140clean: clean-sapi 141 @echo Cleaning distribution build dirs 142 @cd $(BUILD_DIR) 143 @for %D in (_x $(BUILD_DIRS_SUB)) do @if exist %D @del /F /Q %D\*.* > NUL 144 @cd "$(PHP_SRC_DIR)" 145 -@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 146 -rd /s /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING) 147 148clean-pecl: 149 @echo Cleaning PECL targets only 150 -rd /s /q $(BUILD_DIR)\pecl 151 152clean-all: 153 @echo Cleaning standard build dirs 154 @cd $(BUILD_DIR) 155 @for %D in (_x $(BUILD_DIRS_SUB)) do @if exist %D @rd /s /q %D 156 @cd "$(PHP_SRC_DIR)" 157 -@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 158 159clean-pgo: clean-all 160 -rd /s /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING) 161 -rd /s /q $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING) 162 -rd /s /q $(BUILD_DIR)\php-test-pack-$(PHP_VERSION_STRING) 163 -del /f /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip 164 -del /f /q $(BUILD_DIR)\php-debug-pack-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip 165 -del /f /q $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip 166 -del /f /q $(BUILD_DIR)\php-test-pack-$(PHP_VERSION_STRING).zip 167 168 169!if $(PHP_TEST_INI_PATH) == "" 170test: set-tmp-env 171 $(DEBUGGER_CMD) $(DEBUGGER_ARGS) "$(BUILD_DIR)\php.exe" -d open_basedir= -d output_buffering=0 run-tests.php $(TESTS) -p "$(BUILD_DIR)\php.exe" 172 173run: set-tmp-env 174 $(DEBUGGER_CMD) $(DEBUGGER_ARGS) "$(BUILD_DIR)\php.exe" $(ARGS) 175!else 176test: set-tmp-env 177 $(DEBUGGER_CMD) $(DEBUGGER_ARGS) "$(BUILD_DIR)\php.exe" -n -c $(PHP_TEST_INI_PATH) -d open_basedir= -d output_buffering=0 -d memory_limit=-1 run-tests.php -p "$(BUILD_DIR)\php.exe" -n -c $(PHP_TEST_INI_PATH) $(TESTS) 178 179run: set-tmp-env 180 $(DEBUGGER_CMD) $(DEBUGGER_ARGS) "$(BUILD_DIR)\php.exe" -n -c $(PHP_TEST_INI_PATH) $(ARGS) 181!endif 182 183build-snap: set-tmp-env generated_files 184 @$(MAKE) "$(BUILD_DIR)\$(PHPDLL)" 185 -for %T in ($(SAPI_TARGETS)) do $(MAKE) /I /nologo "%T" 186 -for %T in ($(EXT_TARGETS)) do $(MAKE) /I /nologo "%T" 187 -for %T in ($(PECL_TARGETS)) do $(MAKE) /I /nologo "%T" 188 189build-dist: $(BUILD_DIR)\deplister.exe 190 -rd /s /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING) 191 -rd /s /q $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING) 192 -del /f /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip 193 -del /f /q $(BUILD_DIR)\php-debug-pack-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip 194 -del /f /q $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip 195 $(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)" 196 cd $(BUILD_DIR)\php-$(PHP_VERSION_STRING) 197 -$(ZIP) -9 -q -r ..\php-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip . 198 cd $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING) 199 -$(ZIP) -9 -q -r ..\pecl-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip . 200 cd $(BUILD_DIR)\php-test-pack-$(PHP_VERSION_STRING) 201 -$(ZIP) -9 -q -r ..\php-test-pack-$(PHP_VERSION_STRING).zip . 202 cd $(BUILD_DIR) 203 -$(ZIP) -9 -q php-debug-pack-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip *.pdb 204 -$(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) 205 cd $(BUILD_DIR) 206 207dist: all build-dist 208snap: build-snap build-devel build-dist 209 210$(BUILD_DIR)\deplister.exe: win32\build\deplister.c 211 $(PHP_CL) /nologo /Fo$(BUILD_DIR)\ /Fd$(BUILD_DIR)\ /Fp$(BUILD_DIR)\ /FR$(BUILD_DIR) /Fe$(BUILD_DIR)\deplister.exe win32\build\deplister.c imagehlp.lib 212 213msi-installer: dist 214 $(BUILD_DIR)\php.exe ..\php-installer\build-installer.php "$(BUILD_DIR)" "$(PHPDLL)" "$(SAPI_TARGETS)" "$(EXT_TARGETS)" "$(PECL_TARGETS)" 215 216# need to redirect, since INSTALL is a file in the root... 217install: really-install install-sdk 218 219build-lib: build-ext-libs 220 @if not exist $(BUILD_DIR_DEV)\lib mkdir $(BUILD_DIR_DEV)\lib >nul 221 @copy $(BUILD_DIR)\$(PHPLIB) $(BUILD_DIR_DEV)\lib /y >nul 222 223build-devel: build-headers build-lib 224 @if not exist $(BUILD_DIR_DEV)\script mkdir $(BUILD_DIR_DEV)\script >nul 225 @if not exist $(BUILD_DIR_DEV)\build mkdir $(BUILD_DIR_DEV)\build >nul 226 @copy run-tests.php $(BUILD_DIR_DEV)\script\ /y >nul 227 @copy win32\build\confutils.js $(BUILD_DIR_DEV)\script\ /y >nul 228 @copy win32\build\configure.tail $(BUILD_DIR_DEV)\script\ /y >nul 229 @copy win32\build\config.w32.phpize.in $(BUILD_DIR_DEV)\script\ /y >nul 230 @copy win32\build\Makefile.phpize $(BUILD_DIR_DEV)\script\ /y >nul 231 @copy win32\build\phpize.bat $(BUILD_DIR_DEV)\ /y >nul 232 @copy win32\build\template.rc $(BUILD_DIR_DEV)\build\ /y >nul 233 @copy win32\build\default.manifest $(BUILD_DIR_DEV)\build\ /y >nul 234 @copy $(BUILD_DIR)\devel\config.phpize.js $(BUILD_DIR_DEV)\script\ /y >nul 235 @copy $(BUILD_DIR)\devel\phpize.js $(BUILD_DIR_DEV)\script\ /y >nul 236 @copy $(BUILD_DIR)\devel\ext_deps.js $(BUILD_DIR_DEV)\script\ /y >nul 237 238install-sdk: build-devel 239 @xcopy /Q /Y /E /I $(BUILD_DIR_DEV)\* $(PHP_PREFIX)\SDK 240 241really-install: 242 @if not exist $(PHP_PREFIX) mkdir $(PHP_PREFIX) 243 @if not exist $(PHP_PREFIX)\ext mkdir $(PHP_PREFIX)\ext 244 @echo Installing files under $(PHP_PREFIX) 245 @if exist $(BUILD_DIR)\*.exe copy $(BUILD_DIR)\*.exe $(PHP_PREFIX) /y >nul 246 @type nul > $(BUILD_DIR)\extension_dlls.txt 247 @if exist $(BUILD_DIR)\php_*.dll copy $(BUILD_DIR)\php_*.dll $(PHP_PREFIX)\ext /y >nul & dir /b $(BUILD_DIR)\php_*.dll > $(BUILD_DIR)\extension_dlls.txt 248 @xcopy $(BUILD_DIR)\*.dll /exclude:$(BUILD_DIR)\extension_dlls.txt $(PHP_PREFIX) /y >nul 249 @echo Registering event source with syslog (requires admin rights) 250 @echo It's okay for this step to fail: 251 -$(PHP_PREFIX)\php.exe -n -dextension_dir=$(PHP_PREFIX) win32/build/registersyslog.php $(PHP_PREFIX)\$(PHPDLL) 252 253