Global.nmake.pp 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. //
  2. // Global.nmake.pp
  3. //
  4. // This file is read in before any of the individual Sources.pp files
  5. // are read. It defines a few global variables to assist
  6. // Template.nmake.pp.
  7. //
  8. // This was adapted from Global.gmsvc.pp
  9. //
  10. #defun get_metalibs target,complete_libs
  11. // In Windows, we need to know the complete set of metalibs that
  12. // encapsulates each of the libraries we'd be linking with normally.
  13. // In the case where a particular library is not part of a metalib,
  14. // we include the library itself.
  15. #define actual_libs
  16. #foreach lib $[complete_libs]
  17. // Only consider libraries that we're actually building.
  18. #if $[all_libs $[and $[build_directory],$[build_target]],$[lib]]
  19. #define modmeta $[module $[TARGET],$[lib]]
  20. #if $[ne $[modmeta],]
  21. #if $[ne $[modmeta],$[target]] // We don't link with ourselves.
  22. #set actual_libs $[actual_libs] $[modmeta]
  23. #endif
  24. #else
  25. #set actual_libs $[actual_libs] $[lib]
  26. #endif
  27. #endif
  28. #end lib
  29. #set actual_libs $[unique $[actual_libs]] $[patsubst %:m,%,$[filter %:m,$[OTHER_LIBS]]]
  30. $[actual_libs]
  31. #end get_metalibs
  32. #defer actual_local_libs $[get_metalibs $[TARGET],$[complete_local_libs]]
  33. #defun decygwin frompat,topat,path
  34. #foreach file $[path]
  35. $[patsubstw $[frompat],$[topat],$[osfilename $[file]]]
  36. #end file
  37. #end decygwin
  38. #define install_lib_dir $[install_lib_dir]
  39. #define install_bin_dir $[install_bin_dir]
  40. #define install_headers_dir $[install_headers_dir]
  41. #define install_data_dir $[install_data_dir]
  42. #define install_igatedb_dir $[install_igatedb_dir]
  43. #define install_config_dir $[install_config_dir]
  44. #define install_parser_inc_dir $[install_parser_inc_dir]
  45. // Define this if we want to make .sbr files.
  46. #if $[USE_BROWSEINFO]
  47. #defer BROWSEINFO_FLAG /Fr"$[osfilename $[target:%.obj=%.sbr]]"
  48. #else
  49. #define BROWSEINFO_FLAG
  50. #endif
  51. #define CFLAGS_SHARED
  52. #include $[THISDIRPREFIX]compilerSettings.pp
  53. #if $[TEST_INLINING]
  54. // /W4 will make MSVC spit out if it inlined a fn or not, but also cause a lot of other spam warnings
  55. #define WARNING_LEVEL_FLAG /W4
  56. #define EXTRA_CDEFS FORCE_INLINING $[EXTRA_CDEFS]
  57. #endif
  58. // do NOT try to do #defer #defer CDEFINES_OPT1 $[CDEFINES_OPT1] here! it wont let Sources.pp define their own CDEFINES_OPT1! they must use EXTRA_CDEFS!
  59. #defer CDEFINES_OPT1 $[EXTRA_CDEFS]
  60. #defer CDEFINES_OPT2 $[EXTRA_CDEFS]
  61. #defer CDEFINES_OPT3 $[EXTRA_CDEFS]
  62. #defer CDEFINES_OPT4 $[EXTRA_CDEFS]
  63. #defer cdefines $[CDEFINES_OPT$[OPTIMIZE]]
  64. // Opt1 /GZ disables OPT flags, so make sure its OPT1 only
  65. #defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=/D%] $[COMMONFLAGS] $[DEBUGFLAGS] $[OPT1FLAGS]
  66. #defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=/D%] $[COMMONFLAGS] $[DEBUGFLAGS] $[if $[no_opt],$[OPT1FLAGS],$[OPTFLAGS]]
  67. #defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[if $[no_opt],$[OPT1FLAGS],$[OPTFLAGS]] $[DEBUGPDBFLAGS]
  68. #defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[if $[no_opt],$[OPT1FLAGS],$[OPTFLAGS] $[OPT4FLAGS]] $[DEBUGPDBFLAGS]
  69. //#if $[FORCE_DEBUG_FLAGS]
  70. // make them all link with non-debug msvc runtime dlls for this case
  71. //#defer DEBUGFLAGS $[subst /MDd,,$[DEBUGFLAGS]]
  72. //#defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[OPTFLAGS] $[DEBUGFLAGS]
  73. //#define LINKER_FLAGS $[LINKER_FLAGS] /debug
  74. //#else
  75. //#endif
  76. // NODEFAULTLIB ensures static libs linked in will connect to the correct msvcrt, so no debug/release mixing occurs
  77. #defer LDFLAGS_OPT1 $[LINKER_FLAGS] $[LDFLAGS_OPT1]
  78. #defer LDFLAGS_OPT2 $[LINKER_FLAGS] $[LDFLAGS_OPT2]
  79. #defer LDFLAGS_OPT3 $[LINKER_FLAGS] $[LDFLAGS_OPT3]
  80. #defer LDFLAGS_OPT4 $[LINKER_FLAGS] $[LDFLAGS_OPT4]
  81. // $[dllext] will be "_d" for debug builds, and empty for non-debug
  82. // builds. This is the extra bit of stuff we tack on to the end of a
  83. // dll name. We name the debug dll's file_d.dll, partly to be
  84. // consistent with Python's convention, and partly for our own benefit
  85. // to differentiate debug-built from non-debug-built dll's (since the
  86. // distinction is so important in Windows).
  87. #define dllext $[if $[<= $[OPTIMIZE],2],_d]
  88. #defer interrogate_ipath $[decygwin %,-S"%",$[install_parser_inc_dir]] $[decygwin %,-I"%",$[target_ipath]]
  89. // '#defer extra_cflags $[extra_cflags] /STUFF' will never work because extra_cflags hasnt been
  90. // defined yet, so this just evaluates the reference to null and removes the reference and the
  91. // the defining extra_cflags in individual sources.pp's will not picked up. use END_FLAGS instead
  92. #defer extra_cflags /EHsc /Zm500 /DWIN32_VC /DWIN32=1 $[WARNING_LEVEL_FLAG] $[END_CFLAGS]
  93. #if $[direct_tau]
  94. #define tau_ipath $[TAU_ROOT]/include
  95. #define tau_cflags /DPROFILING_ON /DTAU_STDCXXLIB /DTAU_USE_C_API
  96. #define tau_lpath $[TAU_ROOT]/lib/VC7
  97. #define tau_libs pytau.lib
  98. #else // direct_tau
  99. #define tau_ipath
  100. #define tau_cflags
  101. #define tau_lpath
  102. #define tau_libs
  103. #endif // direct_tau
  104. #defer DECYGWINED_INC_PATHLIST_ARGS $[decygwin %,/I"%",$[EXTRA_INCPATH] $[ipath] $[WIN32_PLATFORMSDK_INCPATH] $[tau_ipath]]
  105. #defer MAIN_C_COMPILE_ARGS /nologo /c $[DECYGWINED_INC_PATHLIST_ARGS] $[flags] $[extra_cflags] $[tau_cflags] "$[osfilename $[source]]"
  106. #defer COMPILE_C $[COMPILER] /Fo"$[osfilename $[target]]" $[MAIN_C_COMPILE_ARGS]
  107. #defer COMPILE_C++ $[COMPILE_C]
  108. #defer STATIC_LIB_C $[LIBBER] /nologo $[sources] /OUT:"$[osfilename $[target]]"
  109. #defer STATIC_LIB_C++ $[STATIC_LIB_C]
  110. #defer COMPILE_IDL midl /nologo /env win32 /Oicf $[DECYGWINED_INC_PATHLIST_ARGS]
  111. #defer COMPILE_RC rc /R /L 0x409 $[DECYGWINED_INC_PATHLIST_ARGS]
  112. // if we're attached, use dllbase.txt. otherwise let OS loader resolve dll addrspace collisions
  113. #if $[ne $[CTPROJS],]
  114. // use predefined bases to speed dll loading and simplify debugging
  115. #defer DLLNAMEBASE $[lib_prefix]$[TARGET]
  116. #defer DLLBASEADDRFILENAME dllbase.txt
  117. #defer DLLBASEARG "/BASE:@$[dtool_ver_dir]\$[DLLBASEADDRFILENAME],$[DLLNAMEBASE]"
  118. #else
  119. // requires dtool envvar
  120. #define GENERATE_BUILDDATE
  121. #endif
  122. #defer LINKER_DEF_FILE_ARG $[if $[LINKER_DEF_FILE],/DEF:"$[LINKER_DEF_FILE]",]
  123. #defer SHARED_LIB_C $[LINKER] /nologo /DLL $[LINKER_DEF_FILE_ARG] $[LDFLAGS_OPT$[OPTIMIZE]] $[DLLBASEARG] /OUT:"$[osfilename $[target]]" $[sources] $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH] $[tau_lpath]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] $[tau_libs] $[VER_RESOURCE]$[if $[and $[eq $[USE_COMPILER], MSVC9],$[not $[LINK_FORCE_STATIC_RELEASE_C_RUNTIME]]],; $[MT_BIN] -nologo -manifest $[target].manifest -outputresource:$[target]\;2,]
  124. #defer SHARED_LIB_C++ $[SHARED_LIB_C]
  125. #defer LINK_BIN_C $[LINKER] /nologo $[LDFLAGS_OPT$[OPTIMIZE]] $[sources] $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH] $[tau_lpath]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] $[tau_libs] /OUT:"$[osfilename $[target]]"$[if $[and $[eq $[USE_COMPILER], MSVC9],$[not $[LINK_FORCE_STATIC_RELEASE_C_RUNTIME]]],; $[MT_BIN] -nologo -manifest $[target].manifest -outputresource:$[target]\;1,]
  126. #defer LINK_BIN_C++ $[LINK_BIN_C]
  127. #defer MIDL_COMMAND $[COMPILE_IDL] /out $[ODIR] $[IDL_CDEFS:%=/D%] $[idl]