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