From a3075773ee5496c46867eb411141bc035b10487b Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 19 Dec 2003 12:50:11 +0000 Subject: [PATCH] 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 --- win32/build/Makefile | 43 ++++++++---- win32/build/buildconf.js | 7 +- win32/build/config.w32 | 48 ++++++++----- win32/build/confutils.js | 148 ++++++++++++++++++++++++++++++++++----- 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: < 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"; } ?> -- 2.50.1