| 1 |
# This file should only be included in makefiles for Tcl extensions, |
| 2 |
# NOT in the makefile for Tcl itself. |
| 3 |
|
| 4 |
!ifndef _RULES_EXT_VC |
| 5 |
|
| 6 |
# We need to run from the directory the parent makefile is located in. |
| 7 |
# nmake does not tell us what makefile was used to invoke it so parent |
| 8 |
# makefile has to set the MAKEFILEVC macro or we just make a guess and |
| 9 |
# warn if we think that is not the case. |
| 10 |
!if "$(MAKEFILEVC)" == "" |
| 11 |
|
| 12 |
!if exist("$(PROJECT).vc") |
| 13 |
MAKEFILEVC = $(PROJECT).vc |
| 14 |
!elseif exist("makefile.vc") |
| 15 |
MAKEFILEVC = makefile.vc |
| 16 |
!endif |
| 17 |
!endif # "$(MAKEFILEVC)" == "" |
| 18 |
|
| 19 |
!if !exist("$(MAKEFILEVC)") |
| 20 |
MSG = ^ |
| 21 |
You must run nmake from the directory containing the project makefile.^ |
| 22 |
If you are doing that and getting this message, set the MAKEFILEVC^ |
| 23 |
macro to the name of the project makefile. |
| 24 |
!message WARNING: $(MSG) |
| 25 |
!endif |
| 26 |
|
| 27 |
!if "$(PROJECT)" == "tcl" |
| 28 |
!error The rules-ext.vc file is not intended for Tcl itself. |
| 29 |
!endif |
| 30 |
|
| 31 |
# We extract version numbers using the nmakehlp program. For now use |
| 32 |
# the local copy of nmakehlp. Once we locate Tcl, we will use that |
| 33 |
# one if it is newer. |
| 34 |
!if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "$(NATIVE_ARCH)" |
| 35 |
!if [$(CC) -nologo -DNDEBUG "nmakehlp.c" -link -subsystem:console > nul] |
| 36 |
!endif |
| 37 |
!else |
| 38 |
!if [copy x86_64-w64-mingw32-nmakehlp.exe nmakehlp.exe >NUL] |
| 39 |
!endif |
| 40 |
!endif |
| 41 |
|
| 42 |
# First locate the Tcl directory that we are working with. |
| 43 |
!if "$(TCLDIR)" != "" |
| 44 |
|
| 45 |
_RULESDIR = $(TCLDIR:/=\) |
| 46 |
|
| 47 |
!else |
| 48 |
|
| 49 |
# If an installation path is specified, that is also the Tcl directory. |
| 50 |
# Also Tk never builds against an installed Tcl, it needs Tcl sources |
| 51 |
!if defined(INSTALLDIR) && "$(PROJECT)" != "tk" |
| 52 |
_RULESDIR=$(INSTALLDIR:/=\) |
| 53 |
!else |
| 54 |
# Locate Tcl sources |
| 55 |
!if [echo _RULESDIR = \> nmakehlp.out] \ |
| 56 |
|| [nmakehlp -L generic\tcl.h >> nmakehlp.out] |
| 57 |
_RULESDIR = ..\..\tcl |
| 58 |
!else |
| 59 |
!include nmakehlp.out |
| 60 |
!endif |
| 61 |
|
| 62 |
!endif # defined(INSTALLDIR).... |
| 63 |
|
| 64 |
!endif # ifndef TCLDIR |
| 65 |
|
| 66 |
# Now look for the targets.vc file under the Tcl root. Note we check this |
| 67 |
# file and not rules.vc because the latter also exists on older systems. |
| 68 |
!if exist("$(_RULESDIR)\lib\nmake\targets.vc") # Building against installed Tcl |
| 69 |
_RULESDIR = $(_RULESDIR)\lib\nmake |
| 70 |
!elseif exist("$(_RULESDIR)\win\targets.vc") # Building against Tcl sources |
| 71 |
_RULESDIR = $(_RULESDIR)\win |
| 72 |
!else |
| 73 |
# If we have not located Tcl's targets file, most likely we are compiling |
| 74 |
# against an older version of Tcl and so must use our own support files. |
| 75 |
_RULESDIR = . |
| 76 |
!endif |
| 77 |
|
| 78 |
!if "$(_RULESDIR)" != "." |
| 79 |
# Potentially using Tcl's support files. If this extension has its own |
| 80 |
# nmake support files, need to compare the versions and pick newer. |
| 81 |
|
| 82 |
!if exist("rules.vc") # The extension has its own copy |
| 83 |
|
| 84 |
!if [echo TCL_RULES_MAJOR = \> versions.vc] \ |
| 85 |
&& [nmakehlp -V "$(_RULESDIR)\rules.vc" RULES_VERSION_MAJOR >> versions.vc] |
| 86 |
!endif |
| 87 |
!if [echo TCL_RULES_MINOR = \>> versions.vc] \ |
| 88 |
&& [nmakehlp -V "$(_RULESDIR)\rules.vc" RULES_VERSION_MINOR >> versions.vc] |
| 89 |
!endif |
| 90 |
|
| 91 |
!if [echo OUR_RULES_MAJOR = \>> versions.vc] \ |
| 92 |
&& [nmakehlp -V "rules.vc" RULES_VERSION_MAJOR >> versions.vc] |
| 93 |
!endif |
| 94 |
!if [echo OUR_RULES_MINOR = \>> versions.vc] \ |
| 95 |
&& [nmakehlp -V "rules.vc" RULES_VERSION_MINOR >> versions.vc] |
| 96 |
!endif |
| 97 |
!include versions.vc |
| 98 |
# We have a newer version of the support files, use them |
| 99 |
!if ($(TCL_RULES_MAJOR) != $(OUR_RULES_MAJOR)) || ($(TCL_RULES_MINOR) < $(OUR_RULES_MINOR)) |
| 100 |
_RULESDIR = . |
| 101 |
!endif |
| 102 |
|
| 103 |
!endif # if exist("rules.vc") |
| 104 |
|
| 105 |
!endif # if $(_RULESDIR) != "." |
| 106 |
|
| 107 |
# Let rules.vc know what copy of nmakehlp.c to use. |
| 108 |
NMAKEHLPC = $(_RULESDIR)\nmakehlp.c |
| 109 |
|
| 110 |
# Get rid of our internal defines before calling rules.vc |
| 111 |
!undef TCL_RULES_MAJOR |
| 112 |
!undef TCL_RULES_MINOR |
| 113 |
!undef OUR_RULES_MAJOR |
| 114 |
!undef OUR_RULES_MINOR |
| 115 |
|
| 116 |
!if exist("$(_RULESDIR)\rules.vc") |
| 117 |
!message *** Using $(_RULESDIR)\rules.vc |
| 118 |
!include "$(_RULESDIR)\rules.vc" |
| 119 |
!else |
| 120 |
!error *** Could not locate rules.vc in $(_RULESDIR) |
| 121 |
!endif |
| 122 |
|
| 123 |
!endif # _RULES_EXT_VC |