Global.nmake.pp 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. // It is a clone of Global.gmsvc.pp that has been adapter do work
  9. // with nmake and visual studio. I didn't call it Global.msvc.pp
  10. // so as not to confuse it with the previous Global.msvc.pp which
  11. // attempts to create visual studio projects.
  12. //
  13. // Steven "Sauce" Osman, July 17, 2003
  14. #defun get_metalibs target,complete_libs
  15. // In Windows, we need to know the complete set of metalibs that
  16. // encapsulates each of the libraries we'd be linking with normally.
  17. // In the case where a particular library is not part of a metalib,
  18. // we include the library itself.
  19. #define actual_libs
  20. #foreach lib $[complete_libs]
  21. // Only consider libraries that we're actually building.
  22. #if $[all_libs $[and $[build_directory],$[build_target]],$[lib]]
  23. #define modmeta $[module $[TARGET],$[lib]]
  24. #if $[ne $[modmeta],]
  25. #if $[ne $[modmeta],$[target]] // We don't link with ourselves.
  26. #set actual_libs $[actual_libs] $[modmeta]
  27. #endif
  28. #else
  29. #set actual_libs $[actual_libs] $[lib]
  30. #endif
  31. #endif
  32. #end lib
  33. #set actual_libs $[unique $[actual_libs]] $[patsubst %:m,%,$[filter %:m,$[OTHER_LIBS]]]
  34. $[actual_libs]
  35. #end get_metalibs
  36. #defun decygwin frompat,topat,path
  37. #foreach file $[path]
  38. $[patsubstw $[frompat],$[topat],$[osfilename $[file]]]
  39. #end file
  40. #end decygwin
  41. #define install_lib_dir $[install_lib_dir]
  42. #define install_bin_dir $[install_bin_dir]
  43. #define install_headers_dir $[install_headers_dir]
  44. #define install_data_dir $[install_data_dir]
  45. #define install_igatedb_dir $[install_igatedb_dir]
  46. #define install_config_dir $[install_config_dir]
  47. #define install_parser_inc_dir $[install_parser_inc_dir]
  48. // Define this if we want to make .sbr files.
  49. #if $[USE_BROWSEINFO]
  50. #defer BROWSEINFO_FLAG /Fr"$[osfilename $[target:%.obj=%.sbr]]"
  51. #else
  52. #define BROWSEINFO_FLAG
  53. #endif
  54. #define CFLAGS_SHARED
  55. // Define LINK_ALL_STATIC to generate static libs instead of DLL's.
  56. #if $[ne $[LINK_ALL_STATIC],]
  57. #define dlink_all_static LINK_ALL_STATIC
  58. #define build_dlls
  59. #define build_libs yes
  60. #define dlllib lib
  61. #else
  62. #define dlink_all_static
  63. #define build_dlls yes
  64. #define build_libs
  65. #define dlllib dll
  66. #endif
  67. #include $[THISDIRPREFIX]compilerSettings.pp
  68. #if $[TEST_INLINING]
  69. // /W4 will make MSVC spit out if it inlined a fn or not, but also cause a lot of other spam warnings
  70. #define WARNING_LEVEL_FLAG /W4
  71. #define EXTRA_CDEFS FORCE_INLINING $[EXTRA_CDEFS]
  72. #endif
  73. // 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!
  74. #defer CDEFINES_OPT1 $[if $[NO_DEBUG_CDEF],,_DEBUG] $[dlink_all_static] $[EXTRA_CDEFS]
  75. #defer CDEFINES_OPT2 $[if $[NO_DEBUG_CDEF],,_DEBUG] $[dlink_all_static] $[EXTRA_CDEFS]
  76. #defer CDEFINES_OPT3 $[dlink_all_static] $[EXTRA_CDEFS]
  77. #defer CDEFINES_OPT4 NDEBUG $[dlink_all_static] $[EXTRA_CDEFS]
  78. // Opt1 /GZ disables OPT flags, so make sure its OPT1 only
  79. #defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=/D%] $[COMMONFLAGS] $[DEBUGFLAGS] $[OPT1FLAGS]
  80. #defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=/D%] $[COMMONFLAGS] $[DEBUGFLAGS] $[OPTFLAGS]
  81. #defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[OPTFLAGS] $[DEBUGPDBFLAGS]
  82. #defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[OPTFLAGS] $[OPT4FLAGS] $[DEBUGPDBFLAGS]
  83. //#if $[FORCE_DEBUG_FLAGS]
  84. // make them all link with non-debug msvc runtime dlls for this case
  85. //#defer DEBUGFLAGS $[subst /MDd,,$[DEBUGFLAGS]]
  86. //#defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=/D%] $[COMMONFLAGS] $[RELEASEFLAGS] $[OPTFLAGS] $[DEBUGFLAGS]
  87. //#define LINKER_FLAGS $[LINKER_FLAGS] /debug
  88. //#else
  89. //#endif
  90. // NODEFAULTLIB ensures static libs linked in will connect to the correct msvcrt, so no debug/release mixing occurs
  91. #defer LDFLAGS_OPT1 $[LINKER_FLAGS] $[LDFLAGS_OPT1]
  92. #defer LDFLAGS_OPT2 $[LINKER_FLAGS] $[LDFLAGS_OPT2]
  93. #defer LDFLAGS_OPT3 $[LINKER_FLAGS] $[LDFLAGS_OPT3]
  94. #defer LDFLAGS_OPT4 $[LINKER_FLAGS] $[LDFLAGS_OPT4]
  95. // $[dllext] will be "_d" for debug builds, and empty for non-debug
  96. // builds. This is the extra bit of stuff we tack on to the end of a
  97. // dll name. We name the debug dll's file_d.dll, partly to be
  98. // consistent with Python's convention, and partly for our own benefit
  99. // to differentiate debug-built from non-debug-built dll's (since the
  100. // distinction is so important in Windows).
  101. #define dllext $[if $[<= $[OPTIMIZE],2],_d]
  102. // note: does NOT include .dll or .lib at end
  103. #defun get_dllname dll_basename
  104. $[if $[ne $[DONT_USE_PANDA_DLL_NAMING],], $[dll_basename], lib$[dll_basename]$[dllext]]
  105. #end get_dllname
  106. #defer interrogate_ipath $[decygwin %,-I"%",$[target_ipath]]
  107. #defer interrogate_spath $[decygwin %,-S"%",$[install_parser_inc_dir]]
  108. // '#defer extra_cflags $[extra_cflags] /STUFF' will never work because extra_cflags hasnt been
  109. // defined yet, so this just evaluates the reference to null and removes the reference and the
  110. // the defining extra_cflags in individual sources.pp's will not picked up. use END_FLAGS instead
  111. #defer extra_cflags /EHsc /Zm300 /DWIN32_VC /DWIN32 $[WARNING_LEVEL_FLAG] $[END_CFLAGS]
  112. #defer DECYGWINED_INC_PATHLIST_ARGS $[decygwin %,/I"%",$[EXTRA_INCPATH] $[ipath] $[WIN32_PLATFORMSDK_INCPATH]]
  113. #defer MAIN_C_COMPILE_ARGS /nologo /c $[DECYGWINED_INC_PATHLIST_ARGS] $[flags] $[extra_cflags] "$[osfilename $[source]]"
  114. #defer COMPILE_C $[COMPILER] /Fo"$[osfilename $[target]]" $[MAIN_C_COMPILE_ARGS]
  115. #defer COMPILE_C++ $[COMPILE_C]
  116. #defer STATIC_LIB_C $[LIBBER] /nologo $[sources] /OUT:"$[osfilename $[target]]"
  117. #defer STATIC_LIB_C++ $[STATIC_LIB_C]
  118. #defer COMPILE_IDL midl /nologo /env win32 /Oicf $[DECYGWINED_INC_PATHLIST_ARGS]
  119. #defer COMPILE_RC rc /R /D "NDEBUG" /L 0x409 $[DECYGWINED_INC_PATHLIST_ARGS]
  120. // if we're attached, use dllbase.txt. otherwise let OS loader resolve dll addrspace collisions
  121. #if $[ne $[CTPROJS],]
  122. // use predefined bases to speed dll loading and simplify debugging
  123. #defer DLLNAMEBASE $[get_dllname $[TARGET]]
  124. #defer DLLBASEADDRFILENAME dllbase.txt
  125. #defer DLLBASEARG "/BASE:@$[dtool_ver_dir]\$[DLLBASEADDRFILENAME],$[DLLNAMEBASE]"
  126. #else
  127. // requires dtool envvar
  128. #define GENERATE_BUILDDATE
  129. #endif
  130. #defer LINKER_DEF_FILE_ARG $[if $[LINKER_DEF_FILE],/DEF:"$[LINKER_DEF_FILE]",]
  131. //#defer ver_resource $[directory]\ver.res
  132. //#defer SHARED_LIB_C link /nologo /dll /VERBOSE:LIB $[LDFLAGS_OPT$[OPTIMIZE]] /OUT:"$[osfilename $[target]]" $[sources] $[decygwin %,/LIBPATH:"%",$[lpath]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]]
  133. #defer SHARED_LIB_C $[LINKER] /nologo /DLL $[LINKER_DEF_FILE_ARG] $[LDFLAGS_OPT$[OPTIMIZE]] $[DLLBASEARG] /OUT:"$[osfilename $[target]]" $[sources] $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]]
  134. #defer SHARED_LIB_C++ $[SHARED_LIB_C]
  135. #defer LINK_BIN_C $[LINKER] /nologo $[LDFLAGS_OPT$[OPTIMIZE]] $[sources] $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] /OUT:"$[osfilename $[target]]"
  136. #defer LINK_BIN_C++ $[LINK_BIN_C]
  137. #if $[ne $[LINK_ALL_STATIC],]
  138. #defer SHARED_LIB_C $[STATIC_LIB_C]
  139. #defer SHARED_LIB_C++ $[STATIC_LIB_C++]
  140. #defer ODIR_SHARED $[ODIR_STATIC]
  141. #endif