rules-ext.vc 3.7 KB

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