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