diff options
author | Wez Furlong <wez@php.net> | 2003-12-19 12:50:11 +0000 |
---|---|---|
committer | Wez Furlong <wez@php.net> | 2003-12-19 12:50:11 +0000 |
commit | a3075773ee5496c46867eb411141bc035b10487b (patch) | |
tree | 08d336fef206e2ffc9f54f3345e7be3e58a8fd71 | |
parent | 7027baee22fd9a4e01cc3450de502098e2703b06 (diff) | |
download | php-git-a3075773ee5496c46867eb411141bc035b10487b.tar.gz |
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
-rw-r--r-- | win32/build/Makefile | 43 | ||||
-rw-r--r-- | win32/build/buildconf.js | 7 | ||||
-rw-r--r-- | win32/build/config.w32 | 48 | ||||
-rw-r--r-- | win32/build/confutils.js | 148 | ||||
-rw-r--r-- | win32/build/mkdist.php | 7 |
5 files changed, 196 insertions, 57 deletions
diff --git a/win32/build/Makefile b/win32/build/Makefile index ca7159df13..951e8466eb 100644 --- a/win32/build/Makefile +++ b/win32/build/Makefile @@ -20,30 +20,31 @@ 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)\$(PHPDLL): $(PHPDEF) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(PHPDLL $(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 @@ $(BUILD_DIR)\php.exe -d open_basedir= -d safe_mode=0 -d output_buffering=0 run-t <<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)" diff --git a/win32/build/buildconf.js b/win32/build/buildconf.js index 0df49c0c56..e70ec9d8f6 100644 --- a/win32/build/buildconf.js +++ b/win32/build/buildconf.js @@ -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 @@ function find_config_w32(dirname) 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; } } } diff --git a/win32/build/config.w32 b/win32/build/config.w32 index e19c7350bc..343a8afbb9 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -3,10 +3,16 @@ // "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 @@ DEFINE("CFLAGS", "/nologo /YX /FD $(BASE_INCLUDES) /D _WINDOWS \ /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 @@ function probe_basic_headers() 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 @@ function add_extra_dirs() { 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 + '" '); + } } - } + } } diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 78e58662a9..5c34f89f3c 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -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 @@ if (!FSO.FileExists("README.CVS-RULES")) { 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 @@ build_dirs = new Array(); extension_include_code = ""; extension_module_ptrs = ""; +get_version_numbers(); + function condense_path(path) { var cd = WshShell.CurrentDirectory; @@ -59,6 +89,31 @@ function condense_path(path) (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 @@ function search_paths(thing_to_find, explicit_path, env_name) 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_LIB(libnames, target, path_to_check) } -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 @@ function CHECK_HEADER_ADD_INCLUDE(header_name, flag_name, path_to_check, use_env 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 @@ function generate_version_info_resource(makefiletarget, creditspath) 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 @@ function SAPI(sapiname, file_list, makefiletarget, cflags) resname = generate_version_info_resource(makefiletarget, configure_module_dirname); MFO.WriteLine(makefiletarget + ": $(BUILD_DIR)\\" + makefiletarget); - MFO.WriteLine("\t@echo SAPI " + configure_module_dirname + "/" + sapiname + " build complete"); + MFO.WriteLine("\t@echo 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 @@ function EXTENSION(extname, file_list, shared, cflags) 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 @@ function ADD_SOURCES(dir, file_list, target) 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 @@ function ADD_FLAG(name, flags, target) 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 get_define(name) 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 @@ function WARNING(msg) 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(); +} + diff --git a/win32/build/mkdist.php b/win32/build/mkdist.php index 21315391d4..58d3356665 100644 --- a/win32/build/mkdist.php +++ b/win32/build/mkdist.php @@ -11,7 +11,7 @@ $is_debug = preg_match("/^debug/i", $build_dir); 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 @@ EOT ); /* 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 @@ if (file_exists($snapshot_template)) { } } 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"; } ?> |