wez Fri Dec 19 07:50:12 2003 EDT Modified files: /php-src/win32/build Makefile buildconf.js config.w32 confutils.js mkdist.php Log: Refinements for new build system: - Add major + minor version to .dll and .exe headers during linking - Handle pecl build dir correctly when pecl is a sibling of php-src - try and guess where your cygwin utils are installed (if you have them) so that we can detect bison, flex etc. - other little refinements
Index: php-src/win32/build/Makefile diff -u php-src/win32/build/Makefile:1.8 php-src/win32/build/Makefile:1.9 --- php-src/win32/build/Makefile:1.8 Sat Dec 6 11:14:03 2003 +++ php-src/win32/build/Makefile Fri Dec 19 07:50:11 2003 @@ -14,36 +14,37 @@ # | Author: Wez Furlong <[EMAIL PROTECTED]> | # +----------------------------------------------------------------------+ # -# $Id: Makefile,v 1.8 2003/12/06 16:14:03 wez Exp $ +# $Id: Makefile,v 1.9 2003/12/19 12:50:11 wez Exp $ # This is the makefile template for the win32 build CC="$(CL)" LD="$(LINK)" -all: $(BUILD_DIR) generated_files $(EXT_TARGETS) $(SAPI_TARGETS) +all: $(BUILD_DIR) $(BUILD_DIRS_SUB) generated_files $(EXT_TARGETS) $(SAPI_TARGETS) generated_files: Zend\zend_ini_parser.c \ Zend\zend_language_parser.c Zend\zend_ini_scanner.c \ Zend\zend_language_scanner.c \ + ext\standard\parsedate.c \ $(PHPDEF) -win32\phpts.def: $(PHP_DLL_DEF_SOURCES) - type $(PHP_DLL_DEF_SOURCES) > win32\phpts.def +$(BUILD_DIR)\$(PHPDLL).def: $(PHP_DLL_DEF_SOURCES) + type $(PHP_DLL_DEF_SOURCES) > $(BUILD_DIR)\$(PHPDLL).def Zend\zend_ini_parser.c Zend\zend_ini_parser.h: Zend\zend_ini_parser.y - bison --output=Zend/zend_ini_parser.c -v -d -p ini_ Zend/zend_ini_parser.y + $(BISON) --output=Zend/zend_ini_parser.c -v -d -p ini_ Zend/zend_ini_parser.y Zend\zend_language_parser.c Zend\zend_language_parser.h: Zend\zend_language_parser.y - bison --output=Zend/zend_language_parser.c -v -d -p zend Zend/zend_language_parser.y + $(BISON) --output=Zend/zend_language_parser.c -v -d -p zend Zend/zend_language_parser.y Zend\zend_ini_scanner.c: Zend\flex.skl Zend\zend_ini_scanner.l - flex -B -i -SZend/flex.skl -Pini_ -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l + $(FLEX) -B -i -SZend/flex.skl -Pini_ -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l Zend\zend_language_scanner.c: Zend\flex.skl Zend\zend_language_scanner.l - flex -i -SZend/flex.skl -Pzend -oZend/zend_language_scanner.c Zend/zend_language_scanner.l + $(FLEX) -i -SZend/flex.skl -Pzend -oZend/zend_language_scanner.c Zend/zend_language_scanner.l ext\standard\parsedate.c ext\standard\parsedate.h: ext\standard\parsedate.y - bison --output=ext/standard/parsedate.c -v -d ext/standard/parsedate.y + $(BISON) --output=ext/standard/parsedate.c -v -d ext/standard/parsedate.y PHPDLL_RES=$(BUILD_DIR)\$(PHPDLL).res @@ -57,17 +58,21 @@ $(BUILD_DIR)\$(PHPLIB): $(BUILD_DIR)\$(PHPDLL) -$(BUILD_DIR): - mkdir $(BUILD_DIR) - for %D in ($(BUILD_DIRS_SUB)) do mkdir %D +$(BUILD_DIR) $(BUILD_DIRS_SUB): + @echo Recreating build dirs + @if not exist $(BUILD_DIR) mkdir $(BUILD_DIR) + @for %D in ($(BUILD_DIRS_SUB)) do @if not exist %D @mkdir %D > NUL clean-sapi: - for %D in ($(EXT_TARGETS) $(SAPI_TARGETS)) do del /F /Q $(BUILD_DIR)\%D - del /F /Q $(BUILD_DIR)\$(PHPDLL) + @echo Cleaning SAPI + @for %D in ($(EXT_TARGETS) $(SAPI_TARGETS)) do @del /F /Q $(BUILD_DIR)\%D > NUL + @del /F /Q $(BUILD_DIR)\$(PHPDLL) clean: clean-sapi - for %D in ($(BUILD_DIRS_SUB)) do del /F /Q %D\*.* - del /F /Q $(BUILD_DIR)\*.res $(BUILD_DIR)\*.lib $(BUILD_DIR)\*.ilk $(BUILD_DIR)\*.pdb $(BUILD_DIR)\*.exp + @echo Cleaning + @for %D in ($(BUILD_DIRS_SUB)) do @del /F /Q %D\*.* > NUL + @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).zip > NUL + -rmdir /s /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING) test: <<test_suite_uses_lame_env_vars.bat @@ -76,5 +81,13 @@ <<NOKEEP dist: all + -rmdir /s /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING) + -del /f /q $(BUILD_DIR)\php-$(PHP_VERSION_STRING).zip $(BUILD_DIR)\php.exe win32/build/mkdist.php "$(BUILD_DIR)" "$(PHPDLL)" "$(SAPI_TARGETS)" "$(EXT_TARGETS)" "$(SNAPSHOT_TEMPLATE)" + cd $(BUILD_DIR)\php-$(PHP_VERSION_STRING) + -$(ZIP) -9 -r ..\php-$(PHP_VERSION_STRING).zip . + cd ..\.. + +msi-installer: dist + $(BUILD_DIR)\php.exe ..\php-installer\build-installer.php "$(BUILD_DIR)" "$(PHPDLL)" "$(SAPI_TARGETS)" "$(EXT_TARGETS)" Index: php-src/win32/build/buildconf.js diff -u php-src/win32/build/buildconf.js:1.5 php-src/win32/build/buildconf.js:1.6 --- php-src/win32/build/buildconf.js:1.5 Thu Dec 4 08:38:47 2003 +++ php-src/win32/build/buildconf.js Fri Dec 19 07:50:11 2003 @@ -1,4 +1,3 @@ -// $Id: buildconf.js,v 1.5 2003/12/04 13:38:47 wez Exp $ /* +----------------------------------------------------------------------+ | PHP Version 5 | @@ -17,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: buildconf.js,v 1.5 2003/12/04 13:38:47 wez Exp $ */ +/* $Id: buildconf.js,v 1.6 2003/12/19 12:50:11 wez Exp $ */ // This generates a configure script for win32 build WScript.StdOut.WriteLine("Rebuilding configure.js"); @@ -65,13 +64,15 @@ WScript.StdOut.WriteLine("Skipping " + dirname + "/" + n + " -- already have a module with that name"); continue; } - seen[seen.length] = n; + c = FSO.BuildPath(fc.item(), "config.w32"); if (FSO.FileExists(c)) { //WScript.StdOut.WriteLine(c); modules += "configure_module_dirname = condense_path(FSO.GetParentFolderName('" + c.replace(new RegExp('(["\\\\])', "g"), '\\$1') + "'));\r\n"; modules += file_get_contents(c); + + seen[seen.length] = n; } } } Index: php-src/win32/build/config.w32 diff -u php-src/win32/build/config.w32:1.14 php-src/win32/build/config.w32:1.15 --- php-src/win32/build/config.w32:1.14 Sat Dec 6 21:58:56 2003 +++ php-src/win32/build/config.w32 Fri Dec 19 07:50:11 2003 @@ -1,12 +1,18 @@ // vim:ft=javascript -// $Id: config.w32,v 1.14 2003/12/07 02:58:56 wez Exp $ +// $Id: config.w32,v 1.15 2003/12/19 12:50:11 wez Exp $ // "Master" config file; think of it as a configure.in // equivalent. +ARG_WITH('cygwin', 'Path to cygwin utilities on your system', '\\cygwin'); + PATH_PROG('cl'); PATH_PROG('link'); PATH_PROG('nmake'); -PATH_PROG('make'); +PATH_PROG('bison'); +PATH_PROG('flex'); +PATH_PROG('re2c'); +PATH_PROG('zip'); +PATH_PROG('lemon'); // one-shot build optimizes build by asking compiler to build // several objects at once, reducing overhead of starting new @@ -32,18 +38,18 @@ /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS"); // General link flags -DEFINE("LDFLAGS", "/nologo /libpath:$(PHP_BUILD)\\lib"); +DEFINE("LDFLAGS", "/nologo /libpath:$(PHP_BUILD)\\lib /version:" + + PHP_VERSION + "." + PHP_MINOR_VERSION + "." + PHP_RELEASE_VERSION); // General DLL link flags -DEFINE("DLL_LDFLAGS", "/dll /version:" + PHP_VERSION); +DEFINE("DLL_LDFLAGS", "/dll "); // PHP DLL link flags DEFINE("PHP_LDFLAGS", "$(DLL_LDFLAGS)"); // General libs -DEFINE("LIBS", "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib \ -advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib \ -ws2_32.lib urlmon.lib resolv.lib"); +// urlmon.lib ole32.lib oleaut32.lib uuid.lib gdi32.lib winspool.lib comdlg32.lib +DEFINE("LIBS", "kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib resolv.lib"); // Set some debug/release specific options if (PHP_DEBUG == "yes") { @@ -123,6 +129,8 @@ p = p.replace(new RegExp("include$"), "lib"); ADD_FLAG("LDFLAGS", '/libpath:"' + p + '" '); php_usual_lib_suspects += ";" + p; + } else if (!p) { + ERROR("We really need that arpa\\nameser.h file - it is part of the win32build package"); } } @@ -130,20 +138,24 @@ { var path, i, f; - path = PHP_EXTRA_INCLUDES.split(';'); - for (i = 0; i < path.length; i++) { - f = FSO.GetAbsolutePathName(path[i]); - if (FSO.FolderExists(f)) { - ADD_FLAG("CFLAGS", '/I "' + f + '" '); + if (PHP_EXTRA_INCLUDES.length) { + path = PHP_EXTRA_INCLUDES.split(';'); + for (i = 0; i < path.length; i++) { + f = FSO.GetAbsolutePathName(path[i]); + if (FSO.FolderExists(f)) { + ADD_FLAG("CFLAGS", '/I "' + f + '" '); + } } - } - path = PHP_EXTRA_LIBS.split(';'); - for (i = 0; i < path.length; i++) { - f = FSO.GetAbsolutePathName(path[i]); - if (FSO.FolderExists(f)) { - ADD_FLAG("LDFLAGS", '/libpath:"' + f + '" '); + } + if (PHP_EXTRA_LIBS.length) { + path = PHP_EXTRA_LIBS.split(';'); + for (i = 0; i < path.length; i++) { + f = FSO.GetAbsolutePathName(path[i]); + if (FSO.FolderExists(f)) { + ADD_FLAG("LDFLAGS", '/libpath:"' + f + '" '); + } } - } + } } Index: php-src/win32/build/confutils.js diff -u php-src/win32/build/confutils.js:1.19 php-src/win32/build/confutils.js:1.20 --- php-src/win32/build/confutils.js:1.19 Sat Dec 6 21:58:56 2003 +++ php-src/win32/build/confutils.js Fri Dec 19 07:50:11 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -// $Id: confutils.js,v 1.19 2003/12/07 02:58:56 wez Exp $ +// $Id: confutils.js,v 1.20 2003/12/19 12:50:11 wez Exp $ var STDOUT = WScript.StdOut; var STDERR = WScript.StdErr; @@ -36,8 +36,36 @@ WScript.Quit(10); } -// TODO: pick this up from configure.in +/* defaults; we pick up the precise versions from configure.in */ var PHP_VERSION = 5; +var PHP_MINOR_VERSION = 0; +var PHP_RELEASE_VERSION = 0; +var PHP_EXTRA_VERSION = ""; +var PHP_VERSION_STRING = "5.0.0"; + +function get_version_numbers() +{ + var cin = file_get_contents("configure.in"); + + if (cin.match(new RegExp("MAJOR_VERSION=(\\d+)"))) { + PHP_VERSION = RegExp.$1; + } + if (cin.match(new RegExp("MINOR_VERSION=(\\d+)"))) { + PHP_MINOR_VERSION = RegExp.$1; + } + if (cin.match(new RegExp("RELEASE_VERSION=(\\d+)"))) { + PHP_RELEASE_VERSION = RegExp.$1; + } + PHP_VERSION_STRING = PHP_VERSION + "." + PHP_MINOR_VERSION + "." + PHP_RELEASE_VERSION; + + if (cin.match(new RegExp("EXTRA_VERSION=\"([^\"]+)\""))) { + PHP_EXTRA_VERSION = RegExp.$1; + if (PHP_EXTRA_VERSION.length) { + PHP_VERSION_STRING += PHP_EXTRA_VERSION; + } + } + DEFINE('PHP_VERSION_STRING', PHP_VERSION_STRING); +} configure_args = new Array(); configure_subst = WScript.CreateObject("Scripting.Dictionary"); @@ -48,6 +76,8 @@ extension_include_code = ""; extension_module_ptrs = ""; +get_version_numbers(); + function condense_path(path) { var cd = WshShell.CurrentDirectory; @@ -59,6 +89,31 @@ (path.charCodeAt(cd.length) == 92 || path.charCodeAt(cd.length) == 47)) { return path.substr(cd.length + 1); } + + var a = cd.split("\\"); + var b = path.split("\\"); + var i, j; + + for (i = 0; i < b.length; i++) { + if (a[i].toLowerCase() == b[i].toLowerCase()) + continue; + if (i > 0) { + /* first difference found */ + path = ""; + for (j = 0; j < a.length - i; j++) { + path += "..\\"; + } + for (j = i; j < b.length; j++) { + path += b[j]; + if (j < b.length - 1) + path += "\\"; + } + return path; + } + /* on a different drive */ + break; + } + return path; } @@ -343,17 +398,26 @@ return place; } -function PATH_PROG(progname, def, additional_paths) +function PATH_PROG(progname, additional_paths) { var exe; var place; + var cyg_path = PHP_CYGWIN + "\\bin;" + PHP_CYGWIN + "\\usr\\local\\bin"; exe = progname + ".exe"; + if (additional_paths == null) { + additional_paths = cyg_path; + } else { + additional_paths += ";" + cyg_path; + } + place = search_paths(exe, additional_paths, "PATH"); if (place == true) { place = exe; + } else if (place != false) { + place = place + "\\" + exe; } if (place) { @@ -409,12 +473,22 @@ } -function CHECK_HEADER_ADD_INCLUDE(header_name, flag_name, path_to_check, use_env) +function CHECK_HEADER_ADD_INCLUDE(header_name, flag_name, path_to_check, use_env, add_dir_part) { + var dir_part_to_add = ""; + if (use_env == null) { use_env = true; } + // if true, add the dir part of the header_name to the include path + if (add_dir_part == null) { + add_dir_part = false; + } else if (add_dir_part) { + var basename = FSO.GetFileName(header_name); + dir_part_to_add = "\\" + header_name.substr(0, header_name.length - basename.length - 1); + } + if (path_to_check == null) { path_to_check = php_usual_include_suspects; } else { @@ -426,13 +500,17 @@ var sym; if (typeof(p) == "string") { - ADD_FLAG(flag_name, '/I "' + p + '" '); + ADD_FLAG(flag_name, '/I "' + p + dir_part_to_add + '" '); } else if (p == false) { /* not found in the defaults or the explicit paths, * so check the general extra includes; if we find * it here, no need to add another /I for it as we - * already have it covered */ + * already have it covered, unless we are adding + * the dir part.... */ p = search_paths(header_name, PHP_EXTRA_INCLUDES, null); + if (typeof(p) == "string" && add_dir_part) { + ADD_FLAG(flag_name, '/I "' + p + dir_part_to_add + '" '); + } } have = p ? 1 : 0 @@ -453,13 +531,17 @@ var res_desc = "PHP " + makefiletarget; var res_prod_name = res_desc; var credits; - var thanks = ""; + var thanks = null; var logo = ""; if (FSO.FileExists(creditspath + '/CREDITS')) { credits = FSO.OpenTextFile(creditspath + '/CREDITS', 1); res_desc = credits.ReadLine(); - thanks = credits.ReadLine(); + try { + thanks = credits.ReadLine(); + } catch (e) { + thanks = null; + } if (thanks == null) { thanks = ""; } else { @@ -507,7 +589,7 @@ resname = generate_version_info_resource(makefiletarget, configure_module_dirname); MFO.WriteLine(makefiletarget + ": $(BUILD_DIR)\\" + makefiletarget); - MFO.WriteLine("[EMAIL PROTECTED] SAPI " + configure_module_dirname + "/" + sapiname + " build complete"); + MFO.WriteLine("[EMAIL PROTECTED] SAPI " + configure_module_dirname + " build complete"); MFO.WriteLine("$(BUILD_DIR)\\" + makefiletarget + ": $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(BUILD_DIR)\\" + resname); if (makefiletarget.match(new RegExp("\\.dll$"))) { @@ -582,7 +664,7 @@ ADD_FLAG("STATIC_EXT_LDFLAGS", "$(LDFLAGS_" + EXT + ")"); ADD_FLAG("STATIC_EXT_CFLAGS", "$(CFLAGS_" + EXT + ")"); - /* find the header that declars the module pointer, + /* find the header that declares the module pointer, * so we can include it in internal_functions.c */ var ext_dir = FSO.GetFolder(configure_module_dirname); var fc = new Enumerator(ext_dir.Files); @@ -630,25 +712,32 @@ var re = new RegExp("\.[a-z0-9A-Z]+$"); dir = dir.replace(new RegExp("/", "g"), "\\"); - - var mangle_dir = dir.replace(new RegExp("[\\\\/.]", "g"), "_"); - var objs_line = ""; var srcs_line = ""; var sub_build = "$(BUILD_DIR)\\"; - sub_build += dir + "\\"; + /* if module dir is not a child of the main source dir, + * we need to tweak it; we should have detected such a + * case in condense_path and rewritten the path to + * be relative. + * This probably breaks for non-sibling dirs, but that + * is not a problem as buildconf only checks for pecl + * as either a child or a sibling */ + var build_dir = dir.replace(new RegExp("^..\\\\"), ""); - var dirs = dir.split("\\"); + var mangle_dir = build_dir.replace(new RegExp("[\\\\/.]", "g"), "_"); + var bd_flags_name = "CFLAGS_BD_" + mangle_dir.toUpperCase(); + + var dirs = build_dir.split("\\"); var i, d = ""; for (i = 0; i < dirs.length; i++) { d += dirs[i]; build_dirs[build_dirs.length] = d; d += "\\"; } + sub_build += d; - var bd_flags_name = "CFLAGS_BD_" + mangle_dir.toUpperCase(); DEFINE(bd_flags_name, "/Fo" + sub_build + " /Fd" + sub_build + " /Fp" + sub_build + " /FR" + sub_build + " "); @@ -818,7 +907,7 @@ if (configure_subst.Exists(name)) { var curr_flags = configure_subst.Item(name); - if (curr_flags.match(flags)) { + if (curr_flags.indexOf(flags) >= 0) { return; } @@ -837,7 +926,7 @@ function ADD_DEF_FILE(name) { if (!configure_subst.Exists("PHPDEF")) { - DEFINE("PHPDEF", "win32\\phpts.def"); + DEFINE("PHPDEF", "$(BUILD_DIR)\\$(PHPDLL).def"); ADD_FLAG("PHP_LDFLAGS", "/def:$(PHPDEF)"); } ADD_FLAG("PHP_DLL_DEF_SOURCES", name); @@ -869,3 +958,26 @@ STDERR.WriteBlankLines(1); } +function copy_and_subst(srcname, destname, subst_array) +{ + if (!FSO.FileExists(srcname)) { + STDOUT.WriteLine("copy_and_subst under " + configure_module_dirname); + srcname = configure_module_dirname + "\\" + srcname; + destname = configure_module_dirname + "\\" + destname; + } + + var content = file_get_contents(srcname); + var i; + + for (i = 0; i < subst_array.length; i+=2) { + var re = subst_array[i]; + var rep = subst_array[i+1]; + + content = content.replace(re, rep); + } + + var f = FSO.CreateTextFile(destname, true); + f.Write(content); + f.Close(); +} + Index: php-src/win32/build/mkdist.php diff -u php-src/win32/build/mkdist.php:1.1 php-src/win32/build/mkdist.php:1.2 --- php-src/win32/build/mkdist.php:1.1 Sat Dec 6 11:14:03 2003 +++ php-src/win32/build/mkdist.php Fri Dec 19 07:50:11 2003 @@ -1,4 +1,4 @@ -<?php # $Id: mkdist.php,v 1.1 2003/12/06 16:14:03 wez Exp $ +<?php # $Id: mkdist.php,v 1.2 2003/12/19 12:50:11 wez Exp $ /* piece together a windows binary distro */ $build_dir = $argv[1]; @@ -11,7 +11,7 @@ echo "Making dist for $build_dir\n"; -$dist_dir = $build_dir . "/_dist_"; +$dist_dir = $build_dir . "/php-" . phpversion(); @mkdir($dist_dir); @mkdir("$dist_dir/sapi"); @mkdir("$dist_dir/ext"); @@ -166,7 +166,8 @@ ); /* list build-in extensions */ $exts = get_loaded_extensions(); -fprintf($fp, "\r\nBuild-in Extensions\r\n"); +fprintf($fp, "\r\nBuilt-in Extensions\r\n"); +fwrite($fp, "===========================\r\n"); foreach ($exts as $ext) { fprintf($fp, "%s\r\n", $ext); } @@ -251,7 +252,7 @@ } } else { echo "WARNING: you don't have a snapshot template\n"; - echo " your dist will not complete\n"; + echo " your dist will not be complete\n"; } ?>
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php