From c220b0dcfab61bd6f1d633d56dafd78171b3a457 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Mon, 11 Dec 2017 16:26:24 +0000 Subject: Allow standard targets to be selectively disabled. Automatic install for extension stubs and public headers if present. Print installation dir, remove useless partial print of preprocessor defines. --- win/rules.vc | 2 +- win/targets.vc | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/win/rules.vc b/win/rules.vc index 9b917b6..10bc26e 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -1681,8 +1681,8 @@ TCLNMAKECONFIG = "$(OUT_DIR)\tcl.nmake" !message *** Intermediate directory will be '$(TMP_DIR)' !message *** Output directory will be '$(OUT_DIR)' +!message *** Installation, if selected, will be in '$(_INSTALLDIR)' !message *** Suffix for binaries will be '$(SUFX)' -!message *** Optional defines are '$(OPTDEFINES)' !message *** Compiler version $(VCVER). Target machine is $(MACHINE) !message *** Host architecture is $(NATIVE_ARCH) diff --git a/win/targets.vc b/win/targets.vc index ca227d8..7f1d388 100644 --- a/win/targets.vc +++ b/win/targets.vc @@ -36,17 +36,63 @@ $(PRJLIB): $(PRJ_OBJS) $(RESFILE) -@del $*.exp !endif -!ifndef DISABLE_STANDARD_TARGETS +!if "$(PRJ_HEADERS)" != "" && "$(PRJ_OBJS)" != "" +$(PRJ_OBJS): $(PRJ_HEADERS) +!endif + +# If parent makefile has defined stub objects, add their installation +# to the default install +!if "$(PRJ_STUBOBJS)" != "" +default-install: default-install-stubs +!endif + +# Unlike the other default targets, these cannot be in rules.vc because +# the executed command depends on existence of macro PRJ_HEADERS_PUBLIC +# that the parent makefile will not define until after including rules-ext.vc +!if "$(PRJ_HEADERS_PUBLIC)" != "" +default-install: default-install-headers +default-install-headers: + @echo Installing headers to '$(INCLUDE_INSTALL_DIR)' + @for %f in ($(PRJ_HEADERS_PUBLIC)) do @$(COPY) %f "$(INCLUDE_INSTALL_DIR)" +!endif + +!if "$(DISABLE_STANDARD_TARGETS)" == "" DISABLE_STANDARD_TARGETS = 0 !endif +!if "$(DISABLE_TARGET_setup)" == "" +DISABLE_TARGET_setup = 0 +!endif +!if "$(DISABLE_TARGET_install)" == "" +DISABLE_TARGET_install = 0 +!endif +!if "$(DISABLE_TARGET_clean)" == "" +DISABLE_TARGET_clean = 0 +!endif +!if "$(DISABLE_TARGET_test)" == "" +DISABLE_TARGET_test = 0 +!endif +!if "$(DISABLE_TARGET_shell)" == "" +DISABLE_TARGET_shell = 0 +!endif + !if !$(DISABLE_STANDARD_TARGETS) +!if !$(DISABLE_TARGET_setup) setup: default-setup +!endif +!if !$(DISABLE_TARGET_install) install: default-install +!endif +!if !$(DISABLE_TARGET_clean) clean: default-clean realclean: hose hose: default-hose distclean: realclean default-distclean +!endif +!if !$(DISABLE_TARGET_test) test: default-test +!endif +!if !$(DISABLE_TARGET_shell) shell: default-shell !endif +!endif # DISABLE_STANDARD_TARGETS -- cgit v0.12 From 8c866ee6be6f90cf26e2a1001319046bc2cd1bd6 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Tue, 12 Dec 2017 17:32:21 +0000 Subject: Add -L option to nmakehlp to locate directories --- win/nmakehlp.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 100 insertions(+), 1 deletion(-) diff --git a/win/nmakehlp.c b/win/nmakehlp.c index 0439d1c..16d89a1 100644 --- a/win/nmakehlp.c +++ b/win/nmakehlp.c @@ -39,7 +39,6 @@ #endif - /* protos */ static int CheckForCompilerFeature(const char *option); @@ -47,6 +46,7 @@ static int CheckForLinkerFeature(const char **options, int count); static int IsIn(const char *string, const char *substring); static int SubstituteFile(const char *substs, const char *filename); static int QualifyPath(const char *path); +static int LocateDependency(const char *keyfile); static const char *GetVersionFromFile(const char *filename, const char *match, int numdots); static DWORD WINAPI ReadFromPipe(LPVOID args); @@ -172,6 +172,18 @@ main( return 2; } return QualifyPath(argv[2]); + + case 'L': + if (argc != 3) { + chars = snprintf(msg, sizeof(msg) - 1, + "usage: %s -L keypath\n" + "Emit the fully qualified path of directory containing keypath\n" + "exitcodes: 0 == success, 1 == not found, 2 == error\n", argv[0]); + WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, + &dwWritten, NULL); + return 2; + } + return LocateDependency(argv[2]); } } chars = snprintf(msg, sizeof(msg) - 1, @@ -701,6 +713,93 @@ QualifyPath( } /* + * Implements LocateDependency for a single directory. See that command + * for an explanation. + * Returns 0 if found after printing the directory. + * Returns 1 if not found but no errors. + * Returns 2 on any kind of error + * Basically, these are used as exit codes for the process. + */ +static int LocateDependencyHelper(const char *dir, const char *keypath) +{ + HANDLE hSearch; + char path[MAX_PATH+1]; + int dirlen, keylen, ret; + WIN32_FIND_DATA finfo; + + if (dir == NULL || keypath == NULL) + return 2; /* Have no real error reporting mechanism into nmake */ + dirlen = strlen(dir); + if ((dirlen + 3) > sizeof(path)) + return 2; + strncpy(path, dir, dirlen); + strncpy(path+dirlen, "\\*", 3); /* Including terminating \0 */ + keylen = strlen(keypath); + +#if 0 /* This function is not available in Visual C++ 6 */ + /* + * Use numerics 0 -> FindExInfoStandard, + * 1 -> FindExSearchLimitToDirectories, + * as these are not defined in Visual C++ 6 + */ + hSearch = FindFirstFileEx(path, 0, &finfo, 1, NULL, 0); +#else + hSearch = FindFirstFile(path, &finfo); +#endif + if (hSearch == INVALID_HANDLE_VALUE) + return 1; /* Not found */ + + /* Loop through all subdirs checking if the keypath is under there */ + ret = 1; /* Assume not found */ + do { + int sublen; + /* + * We need to check it is a directory despite the + * FindExSearchLimitToDirectories in the above call. See SDK docs + */ + if ((finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) + continue; + sublen = strlen(finfo.cFileName); + if ((dirlen+1+sublen+1+keylen+1) > sizeof(path)) + continue; /* Path does not fit, assume not matched */ + strncpy(path+dirlen+1, finfo.cFileName, sublen); + path[dirlen+1+sublen] = '\\'; + strncpy(path+dirlen+1+sublen+1, keypath, keylen+1); + if (PathFileExists(path)) { + /* Found a match, print to stdout */ + path[dirlen+1+sublen] = '\0'; + QualifyPath(path); + ret = 0; + break; + } + } while (FindNextFile(hSearch, &finfo)); + FindClose(hSearch); + return ret; +} + +/* + * LocateDependency -- + * + * Locates a dependency for a package. + * keypath - a relative path within the package directory + * that is used to confirm it is the correct directory. + * The search path for the package directory is currently only + * the parent and grandparent of the current working directory. + * If found, the command prints + * name_DIRPATH= + * and returns 0. If not found, does not print anything and returns 1. + */ +static int LocateDependency(const char *keypath) +{ + int ret; + ret = LocateDependencyHelper("..", keypath); + if (ret != 0) + ret = LocateDependencyHelper("..\\..", keypath); + return ret; +} + + +/* * Local variables: * mode: c * c-basic-offset: 4 -- cgit v0.12 From 48549d55b04fb4d2eb8df460ffac8ea552676073 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Wed, 13 Dec 2017 10:03:54 +0000 Subject: Updated nmake system to make use of the new nmakehlp -L option for locating dependencies. --- win/nmakehlp.c | 12 +++++++---- win/rules-ext.vc | 19 +++++++++++----- win/rules.vc | 66 ++++++++++++++++++++++++++++++++++++++++++-------------- 3 files changed, 72 insertions(+), 25 deletions(-) diff --git a/win/nmakehlp.c b/win/nmakehlp.c index 16d89a1..025bb99 100644 --- a/win/nmakehlp.c +++ b/win/nmakehlp.c @@ -791,10 +791,14 @@ static int LocateDependencyHelper(const char *dir, const char *keypath) */ static int LocateDependency(const char *keypath) { - int ret; - ret = LocateDependencyHelper("..", keypath); - if (ret != 0) - ret = LocateDependencyHelper("..\\..", keypath); + int i, ret; + static char *paths[] = {"..", "..\\..", "..\\..\\.."}; + + for (i = 0; i < (sizeof(paths)/sizeof(paths[0])); ++i) { + ret = LocateDependencyHelper(paths[i], keypath); + if (ret == 0) + return ret; + } return ret; } diff --git a/win/rules-ext.vc b/win/rules-ext.vc index 3aba80d..58c70fa 100644 --- a/win/rules-ext.vc +++ b/win/rules-ext.vc @@ -28,6 +28,12 @@ macro to the name of the project makefile. !error The rules-ext.vc file is not intended for Tcl itself. !endif +# We extract version numbers using the nmakehlp program. For now use +# the local copy of nmakehlp. Once we locate Tcl, we will use that +# one if it is newer. +!if [$(CC) -nologo "nmakehlp.c" -link -subsystem:console > nul] +!endif + # First locate the Tcl directory that we are working with. !ifdef TCLDIR @@ -36,13 +42,20 @@ _RULESDIR = $(TCLDIR:/=\) !else # If an installation path is specified, that is also the Tcl directory. -# Also, tk never builds against an installed Tcl, it needs Tcl sources +# Also Tk never builds against an installed Tcl, it needs Tcl sources !if defined(INSTALLDIR) && "$(PROJECT)" != "tk" _RULESDIR=$(INSTALLDIR:/=\) !else +# Locate Tcl sources +!if [echo _RULESDIR = \> nmakehlp.out] \ + || [nmakehlp -L generic\tcl.h >> nmakehlp.out] _RULESDIR = ..\..\tcl +!else +!include nmakehlp.out !endif +!endif # defined(INSTALLDIR).... + !endif # ifndef TCLDIR # Now look for the targets.vc file under the Tcl root. Note we check this @@ -63,10 +76,6 @@ _RULESDIR = . !if exist("rules.vc") # The extension has its own copy -# We extract version numbers using the nmakehlp program. -!if [$(CC) -nologo "$(_RULESDIR)\nmakehlp.c" -link -subsystem:console > nul] -!endif - !if [echo TCL_RULES_MAJOR = \> versions.vc] \ && [nmakehlp -V "$(_RULESDIR)\rules.vc" RULES_VERSION_MAJOR >> versions.vc] !endif diff --git a/win/rules.vc b/win/rules.vc index 10bc26e..7fc51c1 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -256,8 +256,13 @@ _TCL_H = ..\generic\tcl.h TCLINSTALL = 0 # Tk always builds against Tcl source, not an installed Tcl !if "$(TCLDIR)" == "" -TCLDIR = ../../tcl +!if [echo TCLDIR = \> nmakehlp.out] \ + || [nmakehlp -L generic\tcl.h >> nmakehlp.out] +!error *** Could not locate Tcl source directory. !endif +!include nmakehlp.out +!endif # TCLDIR == "" + _TCLDIR = $(TCLDIR:/=\) _TCL_H = $(_TCLDIR)\generic\tcl.h !if !exist("$(_TCL_H)") @@ -285,21 +290,32 @@ TCLINSTALL = 0 _TCL_H = $(_TCLDIR)\generic\tcl.h !endif -!else # TCLDIR is not defined +!else # # Case 2(c) for extensions with TCLDIR undefined + +# Need to locate Tcl depending on whether it needs Tcl source or not. +# If we don't, check the INSTALLDIR for an installed Tcl first + +!if exist("$(_INSTALLDIR)\include\tcl.h") && !$(NEED_TCL_SOURCE) -!if exist("$(_INSTALLDIR)\include\tcl.h") # Case 2(c) for extensions with TCLDIR undefined TCLINSTALL = 1 TCLDIR = $(_INSTALLDIR)\.. # NOTE: we will be resetting _INSTALLDIR to _INSTALLDIR/lib for extensions # later so the \.. accounts for the /lib _TCLDIR = $(_INSTALLDIR)\.. _TCL_H = $(_TCLDIR)\include\tcl.h -!elseif exist("..\..\tcl\generic\tcl.h") + +!else # exist(...) && ! $(NEED_TCL_SOURCE) + +!if [echo _TCLDIR = \> nmakehlp.out] \ + || [nmakehlp -L generic\tcl.h >> nmakehlp.out] +!error *** Could not locate Tcl source directory. +!endif +!include nmakehlp.out TCLINSTALL = 0 -TCLDIR = ..\..\tcl -_TCLDIR = $(TCLDIR) +TCLDIR = $(_TCLDIR) _TCL_H = $(_TCLDIR)\generic\tcl.h -!endif + +!endif # exist(...) && ! $(NEED_TCL_SOURCE) !endif # TCLDIR @@ -325,17 +341,30 @@ _TK_H = $(_TKDIR)\generic\tk.h !else # TKDIR not defined -!if exist("$(_INSTALLDIR)\..\include\tk.h") +# Need to locate Tcl depending on whether it needs Tcl source or not. +# If we don't, check the INSTALLDIR for an installed Tcl first + +!if exist("$(_INSTALLDIR)\include\tk.h") && !$(NEED_TK_SOURCE) + TKINSTALL = 1 +# NOTE: we will be resetting _INSTALLDIR to _INSTALLDIR/lib for extensions +# later so the \.. accounts for the /lib _TKDIR = $(_INSTALLDIR)\.. _TK_H = $(_TKDIR)\include\tk.h TKDIR = $(_TKDIR) -!elseif exist("$(_TCLDIR)\include\tk.h") -TKINSTALL = 1 -_TKDIR = $(_TCLDIR) -_TK_H = $(_TKDIR)\include\tk.h -TKDIR = $(_TKDIR) + +!else # exist("$(_INSTALLDIR)\include\tk.h") && !$(NEED_TK_SOURCE) + +!if [echo _TKDIR = \> nmakehlp.out] \ + || [nmakehlp -L generic\tk.h >> nmakehlp.out] +!error *** Could not locate Tk source directory. !endif +!include nmakehlp.out +TKINSTALL = 0 +TKDIR = $(_TKDIR) +_TK_H = $(_TKDIR)\generic\tk.h + +!endif # exist("$(_INSTALLDIR)\include\tk.h") && !$(NEED_TK_SOURCE) !endif # TKDIR @@ -1518,13 +1547,12 @@ default-clean: @if exist $(WINDIR)\versions.vc del $(WINDIR)\versions.vc @if exist $(WINDIR)\version.vc del $(WINDIR)\version.vc -default-hose: +default-hose: default-clean @echo Hosing $(OUT_DIR)\* ... @if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR) +# Only for backward compatibility default-distclean: default-hose - @if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe - @if exist $(WINDIR)\nmakehlp.obj del $(WINDIR)\nmakehlp.obj default-setup: @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR) @@ -1679,6 +1707,12 @@ TCLNMAKECONFIG = "$(OUT_DIR)\tcl.nmake" # Display stats being used. #---------------------------------------------------------- +!if !$(DOING_TCL) +!message *** Building against Tcl at '$(_TCLDIR)' +!endif +!if !$(DOING_TK) && $(NEED_TK) +!message *** Building against Tk at '$(_TKDIR)' +!endif !message *** Intermediate directory will be '$(TMP_DIR)' !message *** Output directory will be '$(OUT_DIR)' !message *** Installation, if selected, will be in '$(_INSTALLDIR)' -- cgit v0.12 From 556dc3036e36d2449fe4feaece94487adfd745b8 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 14 Dec 2017 12:02:13 +0000 Subject: Fix (harmless) compiler warning with Visual Studio --- generic/tclStubInit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 544c28e..6c20340 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -110,7 +110,7 @@ static unsigned short TclWinNToHS(unsigned short ns) { } #define TclWinGetPlatformId winGetPlatformId static int -TclWinGetPlatformId() +TclWinGetPlatformId(void) { return 2; /* VER_PLATFORM_WIN32_NT */; } -- cgit v0.12