Template.msvc.pp 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  1. //
  2. // Template.msvc.pp
  3. //
  4. // This file defines the set of output files that will be generated to
  5. // support a makefile build system invoking Microsoft's Visual C++
  6. // command-line compiler. It rolls libraries into their metalibs,
  7. // generates .dll files, compiles source files to .obj files, and does
  8. // other Windows-specific things.
  9. //
  10. // Before this file is processed, the following files are read and
  11. // processed (in order):
  12. // The Package.pp file in the root of the current source hierarchy
  13. // (e.g. $PANDA/Package.pp)
  14. // $DTOOL/Package.pp
  15. // $DTOOL/Config.pp
  16. // $DTOOL/Config.Platform.pp
  17. // $DTOOL/pptempl/System.pp
  18. // The user's PPREMAKE_CONFIG file.
  19. // $DTOOL/pptempl/Global.pp
  20. // $DTOOL/pptempl/Global.msvc.pp
  21. // All of the Sources.pp files in the current source hierarchy
  22. // $DTOOL/Depends.pp, once for each Sources.pp file
  23. // Template.msvc.pp (this file), once for each Sources.pp file
  24. #defun decygwin frompat,topat,path
  25. #foreach file $[path]
  26. #if $[isfullpath $[file]]
  27. $[patsubstw $[frompat],$[topat],$[cygpath_w $[file]]]
  28. #else
  29. $[patsubstw $[frompat],$[topat],$[osfilename $[file]]]
  30. #endif
  31. #end file
  32. #end decygwin
  33. // should overwrite read-only files
  34. #define NT_COPYCMD xcopy /Y /Q /R
  35. #define dtool_ver_dir_cyg $[DTOOL_INSTALL]/src/dtoolbase
  36. #define dtool_ver_dir $[decygwin %,%,$[dtool_ver_dir_cyg]]
  37. //////////////////////////////////////////////////////////////////////
  38. #if $[or $[eq $[DIR_TYPE], src],$[eq $[DIR_TYPE], metalib]]
  39. //////////////////////////////////////////////////////////////////////
  40. // For a source directory, build a single Makefile with rules to build
  41. // each target.
  42. // This is the real set of lib_targets we'll be building. On Windows,
  43. // we don't build the shared libraries which are included on metalibs.
  44. #define real_lib_targets
  45. #define deferred_objs
  46. #forscopes lib_target
  47. #if $[eq $[module $[TARGET],$[TARGET]],]
  48. // This library is not on a metalib, so we can build it.
  49. #set real_lib_targets $[real_lib_targets] $[TARGET]
  50. #else
  51. // This library is on a metalib, so we can't build it, but we
  52. // should build all the obj's that go into it.
  53. #set deferred_objs $[deferred_objs] \
  54. $[patsubst %.c %.cxx %.yxx %.lxx,$[so_dir]\%.obj,%,,$[get_sources] $[get_igateoutput]]
  55. #endif
  56. #end lib_target
  57. // We need to know the various targets we'll be building.
  58. // $[lib_targets] will be the list of dynamic libraries,
  59. // $[static_lib_targets] the list of static libraries, and
  60. // $[bin_targets] the list of binaries. $[test_bin_targets] is the
  61. // list of binaries that are to be built only when specifically asked
  62. // for.
  63. #define lib_targets $[patsubst %,$[so_dir]\lib%$[dllext].$[dlllib],$[active_target(metalib_target noinst_lib_target)] $[real_lib_targets]]
  64. #define static_lib_targets $[active_target(static_lib_target ss_lib_target):%=$[st_dir]\lib%$[dllext].lib]
  65. #define bin_targets \
  66. $[active_target(bin_target noinst_bin_target):%=$[st_dir]\%.exe] \
  67. $[active_target(sed_bin_target):%=$[st_dir]\%]
  68. #define test_bin_targets $[active_target(test_bin_target):%=$[st_dir]\%.exe]
  69. // And these variables will define the various things we need to
  70. // install.
  71. #define install_lib $[active_target(metalib_target static_lib_target ss_lib_target)] $[real_lib_targets]
  72. #define install_bin $[active_target(bin_target)]
  73. #define install_scripts $[sort $[INSTALL_SCRIPTS(metalib_target lib_target static_lib_target ss_lib_target bin_target)] $[INSTALL_SCRIPTS]]
  74. #define install_headers $[sort $[INSTALL_HEADERS(metalib_target lib_target static_lib_target ss_lib_target bin_target)] $[INSTALL_HEADERS]]
  75. #define install_parser_inc $[sort $[INSTALL_PARSER_INC]]
  76. #define install_data $[sort $[INSTALL_DATA(metalib_target lib_target static_lib_target ss_lib_target bin_target)] $[INSTALL_DATA]]
  77. #define install_config $[sort $[INSTALL_CONFIG(metalib_target lib_target static_lib_target ss_lib_target bin_target)] $[INSTALL_CONFIG]]
  78. #define install_igatedb $[sort $[get_igatedb(metalib_target lib_target)]]
  79. // $[so_sources] is the set of sources that belong on a shared object,
  80. // and $[st_sources] is the set of sources that belong on a static
  81. // object, like a static library or an executable. In Windows, we
  82. // don't need to make this distinction, but we do anyway in case we
  83. // might in the future for some nutty reason.
  84. #define so_sources $[get_sources(metalib_target lib_target noinst_lib_target)]
  85. #define st_sources $[get_sources(static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target)]
  86. // These are the source files that our dependency cache file will
  87. // depend on. If it's an empty list, we won't bother writing rules to
  88. // freshen the cache file.
  89. #define dep_sources $[sort $[filter %.c %.cxx %.yxx %.lxx %.h %.I %.I,$[so_sources] $[st_sources]]]
  90. #if $[eq $[so_dir],$[st_dir]]
  91. // If the static and shared directories are the same, we have to use the
  92. // same rules to build both shared and static targets.
  93. #set st_sources $[so_sources] $[st_sources]
  94. #set so_sources
  95. #endif
  96. // And these are the various source files, extracted out by type.
  97. #define cxx_so_sources $[filter %.cxx,$[so_sources]]
  98. #define cxx_st_sources $[filter %.cxx,$[st_sources]]
  99. #define c_so_sources $[filter %.c,$[so_sources]]
  100. #define c_st_sources $[filter %.c,$[st_sources]]
  101. #define yxx_so_sources $[filter %.yxx,$[so_sources]]
  102. #define yxx_st_sources $[filter %.yxx,$[st_sources]]
  103. #define lxx_so_sources $[filter %.lxx,$[so_sources]]
  104. #define lxx_st_sources $[filter %.lxx,$[st_sources]]
  105. // This map variable gets us all the various source files from all the
  106. // targets in this directory. We need it to look up the context in
  107. // which to build a particular source file, since some targets may
  108. // have different requirements (e.g. different local_libs, or
  109. // different USE_this or USE_that) than other targets.
  110. #map all_sources get_sources(metalib_target lib_target noinst_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target)
  111. // We define $[complete_local_libs] as the full set of libraries (from
  112. // within this tree) that we must link a particular target with. It
  113. // is the transitive closure of our dependent libs: the libraries we
  114. // depend on, plus the libraries *those* libraries depend on, and so
  115. // on.
  116. #defer complete_local_libs $[unique $[closure all_libs,$[active_libs]]]
  117. #defer actual_local_libs $[get_metalibs $[TARGET],$[complete_local_libs]]
  118. // And $[complete_ipath] is the list of directories (from within this
  119. // tree) we should add to our -I list. It's basically just one for
  120. // each directory named in the $[complete_local_libs], above, plus
  121. // whatever else the user might have explicitly named in
  122. // $[LOCAL_INCS].
  123. #defer complete_ipath $[all_libs $[RELDIR],$[complete_local_libs]] $[RELDIR($[LOCAL_INCS:%=%\])]
  124. // $[target_ipath] is the proper ipath to put on the command line,
  125. // from the context of a particular target.
  126. #defer target_ipath $[TOPDIR] $[sort $[complete_ipath]] $[other_trees:%=%\include] $[get_ipath]
  127. // $[file_ipath] is the ipath from the context of a particular source
  128. // file, given in $[file]. It uses the all_sources map to look up
  129. // the target the source file belongs on, to get the proper context.
  130. #defer file_ipath $[all_sources $[target_ipath],$[file]]
  131. // These are the complete set of extra flags the compiler requires,
  132. // from the context of a particular file, given in $[file].
  133. #defer cflags $[all_sources $[get_cflags] $[CFLAGS],$[file]] $[CFLAGS_OPT$[OPTIMIZE]]
  134. #defer c++flags $[all_sources $[get_cflags] $[C++FLAGS],$[file]] $[CFLAGS_OPT$[OPTIMIZE]]
  135. // These are the same flags, sans the compiler optimizations.
  136. #defer noopt_c++flags $[all_sources $[get_cflags] $[C++FLAGS],$[file]] $[CFLAGS_OPT$[OPTIMIZE]]
  137. // $[complete_lpath] is rather like $[complete_ipath]: the list of
  138. // directories (from within this tree) we should add to our -L list.
  139. #defer complete_lpath $[static_libs $[RELDIR:%=%\$[st_dir]],$[actual_local_libs]] $[dynamic_libs $[RELDIR:%=%\$[so_dir]],$[actual_local_libs]]
  140. // $[lpath] is like $[target_ipath]: it's the list of directories we
  141. // should add to our -L list, from the context of a particular target.
  142. #defer lpath $[sort $[complete_lpath]] $[other_trees:%=%\lib] $[get_lpath]
  143. // And $[libs] is the set of libraries we will link with.
  144. #defer libs $[unique $[actual_local_libs:%=%$[dllext]] $[patsubst %:c,,%:m %,%$[dllext],$[OTHER_LIBS]] $[get_libs]]
  145. // Okay, we're ready. Start outputting the Makefile now.
  146. #output Makefile
  147. #format makefile
  148. #### Generated automatically by $[PPREMAKE] $[PPREMAKE_VERSION] from $[SOURCEFILE].
  149. ################################# DO NOT EDIT ###########################
  150. // The 'all' rule makes all the stuff in the directory except for the
  151. // test_bin_targets. It doesn't do any installation, however.
  152. #define all_targets \
  153. Makefile \
  154. $[if $[dep_sources],$[DEPENDENCY_CACHE_FILENAME]] \
  155. $[if $[so_sources],$[so_dir]] \
  156. $[if $[st_sources],$[st_dir]] \
  157. $[sort $[lib_targets] $[static_lib_targets] $[bin_targets]] \
  158. $[deferred_objs] \
  159. $[TARGET(special_target)]
  160. all : $[all_targets]
  161. // The 'test' rule makes all the test_bin_targets.
  162. test : $[test_bin_targets]
  163. // We implement 'clean' simply by removing the odirs, since all of our
  164. // generated output ends up in one or the other of these. Effective.
  165. // It does assume that the odirs are not '.', however.
  166. clean :
  167. #if $[so_sources]
  168. -rmdir /s /q $[so_dir]
  169. #endif
  170. #if $[st_sources]
  171. -rmdir /s /q $[st_dir]
  172. #endif
  173. -del /f *.pyc *.pyo // Also scrub out old generated Python code.
  174. // 'cleanall' is not much more thorough than 'clean': At the moment,
  175. // it also cleans up the bison and flex output, as well as the
  176. // dependency cache file.
  177. cleanall : clean
  178. #if $[yxx_so_sources] $[yxx_st_sources] $[lxx_so_sources] $[lxx_st_sources]
  179. -del /f $[patsubst %.yxx %.lxx,%.cxx,$[yxx_so_sources] $[yxx_st_sources] $[lxx_so_sources] $[lxx_st_sources]]
  180. #endif
  181. #if $[ne $[DEPENDENCY_CACHE_FILENAME],]
  182. -del /f $[DEPENDENCY_CACHE_FILENAME]
  183. #endif
  184. // Now, 'install' and 'uninstall'. These simply copy files into the
  185. // install directory (or remove them). The 'install' rule also makes
  186. // the directories if necessary.
  187. #define installed_files \
  188. $[INSTALL_SCRIPTS:%=$[install_bin_dir]\%] \
  189. $[INSTALL_HEADERS:%=$[install_headers_dir]\%] \
  190. $[INSTALL_PARSER_INC:%=$[install_parser_inc_dir]\%] \
  191. $[INSTALL_DATA:%=$[install_data_dir]\%] \
  192. $[INSTALL_CONFIG:%=$[install_config_dir]\%]
  193. #define install_targets \
  194. $[sort \
  195. $[if $[install_lib],$[install_lib_dir]] \
  196. $[if $[install_bin] $[install_scripts],$[install_bin_dir]] \
  197. $[if $[install_headers],$[install_headers_dir]] \
  198. $[if $[install_parser_inc],$[install_parser_inc_dir]] \
  199. $[if $[install_data],$[install_data_dir]] \
  200. $[if $[install_config],$[install_config_dir]] \
  201. $[if $[install_igatedb],$[install_igatedb_dir]] \
  202. ] \
  203. $[active_target(metalib_target lib_target static_lib_target ss_lib_target):%=install-lib%] \
  204. $[active_target(bin_target sed_bin_target):%=install-%] \
  205. $[installed_files]
  206. install : all $[install_targets]
  207. uninstall : $[active_target(metalib_target lib_target static_lib_target ss_lib_target):%=uninstall-lib%] $[active_target(bin_target):%=uninstall-%]
  208. #foreach file $[sort $[installed_files]]
  209. -del /f $[file]
  210. #end file
  211. // We need a rule for each directory we might need to make. This
  212. // loops through the full set of directories and creates a rule to
  213. // make each one, as needed.
  214. #foreach directory $[sort \
  215. $[if $[so_sources],$[so_dir]] \
  216. $[if $[st_sources],$[st_dir]] \
  217. $[if $[install_lib],$[install_lib_dir]] \
  218. $[if $[install_bin] $[install_scripts],$[install_bin_dir]] \
  219. $[if $[install_headers],$[install_headers_dir]] \
  220. $[if $[install_parser_inc],$[install_parser_inc_dir]] \
  221. $[if $[install_data],$[install_data_dir]] \
  222. $[if $[install_config],$[install_config_dir]] \
  223. $[if $[install_igatedb],$[install_igatedb_dir]] \
  224. ]
  225. $[osfilename $[directory]] :
  226. mkdir $[osfilename $[directory]]
  227. #end directory
  228. // Now it's time to start generating the rules to make our actual
  229. // targets.
  230. /////////////////////////////////////////////////////////////////////
  231. // First, the dynamic libraries. Each lib_target and metalib_target
  232. // is a dynamic library.
  233. /////////////////////////////////////////////////////////////////////
  234. #forscopes metalib_target lib_target
  235. // In Windows, we don't actually build all the libraries. In
  236. // particular, we don't build any libraries that are listed on a
  237. // metalib. Is this one such library?
  238. #define build_it $[eq $[module $[TARGET],$[TARGET]],]
  239. // We might need to define a BUILDING_ symbol for win32. We use the
  240. // BUILDING_DLL variable name, defined typically in the metalib, for
  241. // this; but in some cases, where the library isn't part of a metalib,
  242. // we define BUILDING_DLL directly for the target.
  243. #define building_var $[or $[BUILDING_DLL],$[module $[BUILDING_DLL],$[TARGET]]]
  244. // $[igatescan] is the set of C++ headers and source files that we
  245. // need to scan for interrogate. $[igateoutput] is the name of the
  246. // generated .cxx file that interrogate will produce (and which we
  247. // should compile into the library). $[igatedb] is the name of the
  248. // generated .in file that interrogate will produce (and which should
  249. // be installed into the /etc directory).
  250. #define igatescan $[get_igatescan]
  251. #define igateoutput $[get_igateoutput]
  252. #define igatedb $[get_igatedb]
  253. // If this is a metalib, it may have a number of components that
  254. // include interrogated interfaces. If so, we need to generate a
  255. // 'module' file within this library. This is mainly necessary for
  256. // Python; it contains a table of all of the interrogated functions,
  257. // so we can load the library as a Python module and have access to
  258. // the interrogated functions.
  259. // $[igatemscan] is the set of .in files generated by all of our
  260. // component libraries. If it is nonempty, then we do need to
  261. // generate a module, and $[igatemout] is the name of the .cxx file
  262. // that interrogate will produce to make this module.
  263. #define igatemscan $[components $[get_igatedb:%=$[RELDIR]\$[so_dir]\%],$[active_component_libs]]
  264. #define igatemout $[if $[igatemscan],lib$[TARGET]_module.cxx]
  265. #if $[build_it]
  266. // Now output the rule to actually link the library from all of its
  267. // various .obj files.
  268. #define sources \
  269. $[unique $[patsubst %.cxx %.c %.yxx %.lxx,$[so_dir]\%.obj,%,,$[get_sources] $[igateoutput] $[igatemout]]] \
  270. $[components $[unique $[patsubst %.cxx %.c %.yxx %.lxx,$[RELDIR]\$[so_dir]\%.obj,%,,$[get_sources] $[get_igateoutput]]],$[active_component_libs]]
  271. #define varname $[subst -,_,lib$[TARGET]_so]
  272. $[varname] = $[osfilename $[sources]]
  273. #define target $[so_dir]\lib$[TARGET]$[dllext].$[dlllib]
  274. #define sources $($[varname])
  275. #define flags $[get_cflags] $[C++FLAGS] $[CFLAGS_OPT$[OPTIMIZE]] $[CFLAGS_SHARED] $[building_var:%=/D%]
  276. #if $[GENERATE_BUILDDATE]
  277. $[target] : $[sources] "$[dtool_ver_dir]\version.rc"
  278. // first generate builddate for rc compiler
  279. cl /nologo /EP "$[dtool_ver_dir]\verdate.cpp" > "$[TEMP]\verdate.h"
  280. rc /n /I$[TEMP] /fo$[ver_resource] $[filter /D%, $[flags]] "$[dtool_ver_dir]\version.rc"
  281. rm -f "$[dtool_ver_dir]\verdate.h"
  282. #else
  283. $[target] : $[sources]
  284. #endif
  285. #if $[filter %.cxx %.yxx %.lxx,$[get_sources]]
  286. $[SHARED_LIB_C++]
  287. #else
  288. $[SHARED_LIB_C]
  289. #endif
  290. #if $[build_dlls]
  291. $[so_dir]\lib$[TARGET]$[dllext].lib : $[so_dir]\lib$[TARGET]$[dllext].dll
  292. #endif
  293. #if $[build_pdbs]
  294. $[so_dir]\lib$[TARGET]$[dllext].pdb : $[so_dir]\lib$[TARGET]$[dllext].dll
  295. #endif
  296. #endif
  297. // Here are the rules to install and uninstall the library and
  298. // everything that goes along with it.
  299. #define installed_files \
  300. $[if $[build_it], \
  301. $[if $[build_dlls],$[install_lib_dir]\lib$[TARGET]$[dllext].dll] \
  302. $[install_lib_dir]\lib$[TARGET]$[dllext].lib \
  303. $[if $[and $[build_dlls],$[build_pdbs]],$[install_lib_dir]\lib$[TARGET]$[dllext].pdb] \
  304. ] \
  305. $[INSTALL_SCRIPTS:%=$[install_bin_dir]\%] \
  306. $[INSTALL_HEADERS:%=$[install_headers_dir]\%] \
  307. $[INSTALL_DATA:%=$[install_data_dir]\%] \
  308. $[INSTALL_CONFIG:%=$[install_config_dir]\%] \
  309. $[igatedb:%=$[install_igatedb_dir]\%]
  310. install-lib$[TARGET] : $[installed_files]
  311. uninstall-lib$[TARGET] :
  312. #foreach file $[sort $[installed_files]]
  313. -del /f $[file]
  314. #end file
  315. #if $[build_dlls]
  316. $[install_lib_dir]\lib$[TARGET]$[dllext].dll : $[so_dir]\lib$[TARGET]$[dllext].dll
  317. #define local lib$[TARGET]$[dllext].dll
  318. #define dest $[install_lib_dir]
  319. $[NT_COPYCMD] $[so_dir]\$[local] $[dest]
  320. #endif
  321. $[install_lib_dir]\lib$[TARGET]$[dllext].lib : $[so_dir]\lib$[TARGET]$[dllext].lib
  322. #define local lib$[TARGET]$[dllext].lib
  323. #define dest $[install_lib_dir]
  324. $[NT_COPYCMD] $[so_dir]\$[local] $[dest]
  325. #if $[and $[build_dlls],$[build_pdbs]]
  326. $[install_lib_dir]\lib$[TARGET]$[dllext].pdb : $[so_dir]\lib$[TARGET]$[dllext].pdb
  327. #define local lib$[TARGET]$[dllext].pdb
  328. #define dest $[install_lib_dir]
  329. $[NT_COPYCMD] $[so_dir]\$[local] $[dest]
  330. #endif
  331. #if $[igatescan]
  332. // Now, some additional rules to generate and compile the interrogate
  333. // data, if needed.
  334. // The library name is based on this library.
  335. #define igatelib lib$[TARGET]
  336. // The module name comes from the metalib that includes this library.
  337. #define igatemod $[module $[TARGET],$[TARGET]]
  338. #if $[eq $[igatemod],]
  339. // Unless no metalib includes this library.
  340. #define igatemod $[TARGET]
  341. #endif
  342. $[install_igatedb_dir]\$[igatedb] : $[so_dir]\$[igatedb]
  343. #define local $[igatedb]
  344. #define dest $[install_igatedb_dir]
  345. $[NT_COPYCMD] $[so_dir]\$[local] $[dest]
  346. lib$[TARGET]_igatescan = $[osfilename $[igatescan]]
  347. $[so_dir]\$[igatedb] $[so_dir]\$[igateoutput] : $[sort $[patsubst %.h,%.h,%.I,%.I,%.T,%.T,%,,$[dependencies $[igatescan]] $[igatescan:%=./%]]]
  348. // We use forward slash for interrogate because it prefers those.
  349. interrogate -od $[so_dir]/$[igatedb] -oc $[so_dir]/$[igateoutput] $[interrogate_options] -module "$[igatemod]" -library "$[igatelib]" $(lib$[TARGET]_igatescan)
  350. #define target $[igateoutput:%.cxx=$[so_dir]\%.obj]
  351. #define source $[so_dir]\$[igateoutput]
  352. #define ipath . $[target_ipath]
  353. #define flags $[get_cflags] $[C++FLAGS] $[CFLAGS_OPT$[OPTIMIZE]] $[CFLAGS_SHARED] $[building_var:%=/D%]
  354. $[target] : $[source]
  355. $[COMPILE_C++]
  356. #endif // $[igatescan]
  357. #if $[igatemout]
  358. // And finally, some additional rules to build the interrogate module
  359. // file into the library, if this is a metalib that includes
  360. // interrogated components.
  361. #define igatelib lib$[TARGET]
  362. #define igatemod $[TARGET]
  363. lib$[TARGET]_igatemscan = $[osfilename $[igatemscan]]
  364. #define target $[so_dir]\$[igatemout]
  365. #define sources $(lib$[TARGET]_igatemscan)
  366. $[target] : $[sources]
  367. interrogate_module -oc $[target] -module "$[igatemod]" -library "$[igatelib]" -python $[sources]
  368. #define target $[igatemout:%.cxx=$[so_dir]\%.obj]
  369. #define source $[so_dir]\$[igatemout]
  370. #define ipath . $[target_ipath]
  371. #define flags $[get_cflags] $[C++FLAGS] $[CFLAGS_OPT$[OPTIMIZE]] $[CFLAGS_SHARED] $[building_var:%=/D%]
  372. $[target] : $[source]
  373. $[COMPILE_C++]
  374. #endif // $[igatescan]
  375. #end metalib_target lib_target
  376. /////////////////////////////////////////////////////////////////////
  377. // Now, the noninstalled dynamic libraries. These are presumably used
  378. // only within this directory, or at the most within this tree, and
  379. // also presumably will never include interrogate data. That, plus
  380. // the fact that we don't need to generate install rules, makes it a
  381. // lot simpler.
  382. /////////////////////////////////////////////////////////////////////
  383. #forscopes noinst_lib_target
  384. #define varname $[subst -,_,lib$[TARGET]_so]
  385. $[varname] = $[osfilename $[unique $[patsubst %.cxx %.c %.yxx %.lxx,$[so_dir]\%.obj,%,,$[get_sources]]]]
  386. #define target $[so_dir]\lib$[TARGET]$[dllext].$[dlllib]
  387. #define sources $($[varname])
  388. $[target] : $[sources]
  389. #if $[filter %.cxx %.yxx %.lxx,$[get_sources]]
  390. $[SHARED_LIB_C++]
  391. #else
  392. $[SHARED_LIB_C]
  393. #endif
  394. #if $[build_dlls]
  395. $[so_dir]\lib$[TARGET]$[dllext].lib : $[so_dir]\lib$[TARGET]$[dllext].dll
  396. #endif
  397. #if $[build_pdbs]
  398. $[so_dir]\lib$[TARGET]$[dllext].pdb : $[so_dir]\lib$[TARGET]$[dllext].dll
  399. #endif
  400. #end noinst_lib_target
  401. /////////////////////////////////////////////////////////////////////
  402. // Now the static libraries. Again, we assume there's no interrogate
  403. // interfaces going on in here, and there's no question of this being
  404. // a metalib, making the rules relatively simple.
  405. /////////////////////////////////////////////////////////////////////
  406. #forscopes static_lib_target ss_lib_target
  407. #define varname $[subst -,_,lib$[TARGET]_a]
  408. $[varname] = $[osfilename $[unique $[patsubst %.cxx %.c %.yxx %.lxx,$[st_dir]\%.obj,%,,$[get_sources]]]]
  409. #define target $[st_dir]\lib$[TARGET]$[dllext].lib
  410. #define sources $($[varname])
  411. $[target] : $[sources]
  412. #if $[filter %.cxx %.yxx %.lxx,$[get_sources]]
  413. $[STATIC_LIB_C++]
  414. #else
  415. $[STATIC_LIB_C]
  416. #endif
  417. #define installed_files \
  418. $[install_lib_dir]\lib$[TARGET]$[dllext].lib \
  419. $[INSTALL_SCRIPTS:%=$[install_bin_dir]\%] \
  420. $[INSTALL_HEADERS:%=$[install_headers_dir]\%] \
  421. $[INSTALL_DATA:%=$[install_data_dir]\%] \
  422. $[INSTALL_CONFIG:%=$[install_config_dir]\%]
  423. install-lib$[TARGET] : $[installed_files]
  424. uninstall-lib$[TARGET] :
  425. #foreach file $[sort $[installed_files]]
  426. -del /f $[file]
  427. #end file
  428. $[install_lib_dir]\lib$[TARGET]$[dllext].lib : $[st_dir]\lib$[TARGET]$[dllext].lib
  429. #define local lib$[TARGET]$[dllext].lib
  430. #define dest $[install_lib_dir]
  431. $[NT_COPYCMD] $[st_dir]\$[local] $[dest]
  432. #end static_lib_target ss_lib_target
  433. /////////////////////////////////////////////////////////////////////
  434. // The sed_bin_targets are a special bunch. These are scripts that
  435. // are to be preprocessed with sed before being installed, for
  436. // instance to insert a path or something in an appropriate place.
  437. /////////////////////////////////////////////////////////////////////
  438. #forscopes sed_bin_target
  439. $[TARGET] : $[st_dir]\$[TARGET]
  440. #define target $[st_dir]\$[TARGET]
  441. #define source $[SOURCE]
  442. #define script $[COMMAND]
  443. $[target] : $[source]
  444. $[SED]
  445. #define installed_files \
  446. $[install_bin_dir]\$[TARGET]
  447. install-$[TARGET] : $[installed_files]
  448. uninstall-$[TARGET] :
  449. #foreach file $[sort $[installed_files]]
  450. -del /f $[file]
  451. #end file
  452. #define local $[TARGET]
  453. #define dest $[install_bin_dir]
  454. $[install_bin_dir]\$[TARGET] : $[st_dir]\$[TARGET]
  455. $[NT_COPYCMD] $[st_dir]\$[local] $[dest]
  456. #end sed_bin_target
  457. /////////////////////////////////////////////////////////////////////
  458. // And now, the bin_targets. These are normal C++ executables. No
  459. // interrogate, metalibs, or any such nonsense here.
  460. /////////////////////////////////////////////////////////////////////
  461. #forscopes bin_target
  462. $[TARGET] : $[st_dir]\$[TARGET].exe
  463. #define varname $[subst -,_,bin_$[TARGET]]
  464. $[varname] = $[osfilename $[unique $[patsubst %.cxx %.c %.yxx %.lxx,$[st_dir]\%.obj,%,,$[get_sources]]]]
  465. #define target $[st_dir]\$[TARGET].exe
  466. #define sources $($[varname])
  467. #define ld $[get_ld]
  468. #define transitive_link $[complete_local_libs]
  469. $[target] : $[sources]
  470. #if $[ld]
  471. // If there's a custom linker defined for the target, we have to use it.
  472. $[ld] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%]
  473. #else
  474. // Otherwise, we can use the normal linker.
  475. #if $[filter %.cxx %.yxx %.lxx,$[get_sources]]
  476. $[LINK_BIN_C++]
  477. #else
  478. $[LINK_BIN_C]
  479. #endif
  480. #endif
  481. #define transitive_link
  482. #if $[build_pdbs]
  483. $[st_dir]\$[TARGET].pdb : $[st_dir]\$[TARGET].exe
  484. #endif
  485. #define installed_files \
  486. $[install_bin_dir]\$[TARGET].exe \
  487. $[if $[build_pdbs],$[install_bin_dir]\$[TARGET].pdb] \
  488. $[INSTALL_SCRIPTS:%=$[install_bin_dir]\%] \
  489. $[INSTALL_HEADERS:%=$[install_headers_dir]\%] \
  490. $[INSTALL_DATA:%=$[install_data_dir]\%] \
  491. $[INSTALL_CONFIG:%=$[install_config_dir]\%]
  492. install-$[TARGET] : $[installed_files]
  493. uninstall-$[TARGET] :
  494. #foreach file $[sort $[installed_files]]
  495. -del /f $[file]
  496. #end file
  497. $[install_bin_dir]\$[TARGET].exe : $[st_dir]\$[TARGET].exe
  498. #define local $[TARGET].exe
  499. #define dest $[install_bin_dir]
  500. $[NT_COPYCMD] $[st_dir]\$[local] $[dest]
  501. #if $[build_pdbs]
  502. $[install_bin_dir]\$[TARGET].pdb : $[st_dir]\$[TARGET].pdb
  503. #define local $[TARGET].pdb
  504. #define dest $[install_bin_dir]
  505. $[NT_COPYCMD] $[st_dir]\$[local] $[dest]
  506. #endif
  507. #end bin_target
  508. /////////////////////////////////////////////////////////////////////
  509. // The noinst_bin_targets and the test_bin_targets share the property
  510. // of being built (when requested), but having no install rules.
  511. /////////////////////////////////////////////////////////////////////
  512. #forscopes noinst_bin_target test_bin_target
  513. $[TARGET] : $[st_dir]\$[TARGET].exe
  514. #define varname $[subst -,_,bin_$[TARGET]]
  515. $[varname] = $[osfilename $[unique $[patsubst %.cxx %.c %.yxx %.lxx,$[st_dir]\%.obj,%,,$[get_sources]]]]
  516. #define target $[st_dir]\$[TARGET].exe
  517. #define sources $($[varname])
  518. $[target] : $[sources]
  519. #if $[filter %.cxx %.yxx %.lxx,$[get_sources]]
  520. $[LINK_BIN_C++]
  521. #else
  522. $[LINK_BIN_C]
  523. #endif
  524. #end noinst_bin_target test_bin_target
  525. /////////////////////////////////////////////////////////////////////
  526. // Finally, we put in the rules to compile each source file into a .obj
  527. // file.
  528. /////////////////////////////////////////////////////////////////////
  529. // Rules to generate a C++ file from a Bison input file.
  530. #foreach file $[sort $[yxx_so_sources] $[yxx_st_sources]]
  531. #define target $[patsubst %.yxx,%.cxx,$[file]]
  532. #define source $[file]
  533. $[target] : $[source]
  534. $[BISON] $[YFLAGS] -y $[if $[YACC_PREFIX],-d --name-prefix=$[YACC_PREFIX]] $[source]
  535. move y.tab.c $[target]
  536. move y.tab.h $[patsubst %.yxx,%.h,$[source]]
  537. #end file
  538. // Rules to generate a C++ file from a Flex input file.
  539. #foreach file $[sort $[lxx_so_sources] $[lxx_st_sources]]
  540. #define target $[patsubst %.lxx,%.cxx,$[file]]
  541. #define source $[file]
  542. $[target] : $[source]
  543. $[FLEX] $[LFLAGS] $[if $[YACC_PREFIX],-P$[YACC_PREFIX]] -olex.yy.c $[source]
  544. #define source lex.yy.c
  545. #define script /#include <unistd.h>/d
  546. $[SED]
  547. -del $[source]
  548. #end file
  549. // Rules to compile ordinary C files that appear on a shared library.
  550. #foreach file $[sort $[c_so_sources]]
  551. #define target $[patsubst %.c,$[so_dir]\%.obj,$[file]]
  552. #define source $[file]
  553. #define ipath $[file_ipath]
  554. #define flags $[cflags] $[CFLAGS_SHARED] $[all_sources $[building_var:%=/D%],$[file]]
  555. $[target] : $[source] $[dependencies $[source]]
  556. $[COMPILE_C]
  557. #end file
  558. // Rules to compile ordinary C files that appear on a static library
  559. // or in an executable.
  560. #foreach file $[sort $[c_st_sources]]
  561. #define target $[patsubst %.c,$[st_dir]\%.obj,$[file]]
  562. #define source $[file]
  563. #define ipath $[file_ipath]
  564. #define flags $[cflags] $[all_sources $[building_var:%=/D%],$[file]]
  565. $[target] : $[source] $[dependencies $[source]]
  566. $[COMPILE_C]
  567. #end file
  568. // Rules to compile C++ files that appear on a shared library.
  569. #foreach file $[sort $[cxx_so_sources]]
  570. #define target $[patsubst %.cxx,$[so_dir]\%.obj,$[file]]
  571. #define source $[file]
  572. #define ipath $[file_ipath]
  573. #define flags $[c++flags] $[CFLAGS_SHARED] $[all_sources $[building_var:%=/D%],$[file]]
  574. // Yacc must run before some files can be compiled, so all files
  575. // depend on yacc having run.
  576. $[target] : $[source] $[dependencies $[file]] $[yxx_so_sources:%.yxx=%.cxx]
  577. $[COMPILE_C++]
  578. #end file
  579. // Rules to compile C++ files that appear on a static library or in an
  580. // executable.
  581. #foreach file $[sort $[cxx_st_sources]]
  582. #define target $[patsubst %.cxx,$[st_dir]\%.obj,$[file]]
  583. #define source $[file]
  584. #define ipath $[file_ipath]
  585. #define flags $[c++flags] $[all_sources $[building_var:%=/D%],$[file]]
  586. $[target] : $[source] $[dependencies $[file]] $[yxx_st_sources:%.yxx=%.cxx]
  587. $[COMPILE_C++]
  588. #end file
  589. // Rules to compile generated C++ files that appear on a shared library.
  590. #foreach file $[sort $[yxx_so_sources] $[lxx_so_sources]]
  591. #define target $[patsubst %.lxx %.yxx,$[so_dir]\%.obj,$[file]]
  592. #define source $[patsubst %.lxx %.yxx,%.cxx,$[file]]
  593. #define ipath $[file_ipath]
  594. #define flags $[noopt_c++flags] $[CFLAGS_SHARED] $[all_sources $[building_var:%=/D%],$[file]]
  595. // Yacc must run before some files can be compiled, so all files
  596. // depend on yacc having run.
  597. $[target] : $[source] $[dependencies $[file]] $[yxx_so_sources:%.yxx=%.cxx]
  598. $[COMPILE_C++]
  599. #end file
  600. // Rules to compile generated C++ files that appear on a static
  601. // library or in an executable.
  602. #foreach file $[sort $[yxx_st_sources] $[lxx_st_sources]]
  603. #define target $[patsubst %.lxx %.yxx,$[st_dir]\%.obj,$[file]]
  604. #define source $[patsubst %.lxx %.yxx,%.cxx,$[file]]
  605. #define ipath $[file_ipath]
  606. #define flags $[noopt_c++flags] $[all_sources $[building_var:%=/D%],$[file]]
  607. $[target] : $[source] $[dependencies $[file]] $[yxx_st_sources:%.yxx=%.cxx]
  608. $[COMPILE_C++]
  609. #end file
  610. // And now the rules to install the auxiliary files, like headers and
  611. // data files.
  612. #foreach file $[install_scripts]
  613. $[install_bin_dir]\$[file] : $[file]
  614. #define local $[file]
  615. #define dest $[install_bin_dir]
  616. $[NT_COPYCMD] $[local] $[dest]
  617. #end file
  618. #foreach file $[install_headers]
  619. $[install_headers_dir]\$[file] : $[file]
  620. #define local $[file]
  621. #define dest $[install_headers_dir]
  622. $[NT_COPYCMD] $[local] $[dest]
  623. #end file
  624. #foreach file $[install_parser_inc]
  625. $[install_parser_inc_dir]\$[file] : $[file]
  626. #define local $[file]
  627. #define dest $[install_parser_inc_dir]
  628. $[NT_COPYCMD] $[local] $[dest]
  629. #end file
  630. #foreach file $[install_data]
  631. $[install_data_dir]\$[file] : $[file]
  632. #define local $[file]
  633. #define dest $[install_data_dir]
  634. $[NT_COPYCMD] $[local] $[dest]
  635. #end file
  636. #foreach file $[install_config]
  637. $[install_config_dir]\$[file] : $[file]
  638. #define local $[file]
  639. #define dest $[install_config_dir]
  640. $[NT_COPYCMD] $[local] $[dest]
  641. #end file
  642. // Finally, all the special targets. These are commands that just need
  643. // to be invoked; we don't pretend to know what they are.
  644. #forscopes special_target
  645. $[TARGET] :
  646. $[COMMAND]
  647. #end special_target
  648. // Finally, the rules to freshen the Makefile itself.
  649. Makefile : $[SOURCE_FILENAME]
  650. ppremake
  651. #if $[and $[DEPENDENCY_CACHE_FILENAME],$[dep_sources]]
  652. $[DEPENDENCY_CACHE_FILENAME] : $[dep_sources]
  653. @ppremake -D $[DEPENDENCY_CACHE_FILENAME]
  654. #endif
  655. #end Makefile
  656. //////////////////////////////////////////////////////////////////////
  657. #elif $[eq $[DIR_TYPE], group]
  658. //////////////////////////////////////////////////////////////////////
  659. // This is a group directory: a directory above a collection of source
  660. // directories, e.g. $DTOOL/src. We don't need to output anything in
  661. // this directory.
  662. //////////////////////////////////////////////////////////////////////
  663. #elif $[eq $[DIR_TYPE], toplevel]
  664. //////////////////////////////////////////////////////////////////////
  665. // This is the toplevel directory, e.g. $DTOOL. Here we build the
  666. // root makefile and also synthesize the dtool_config.h (or whichever
  667. // file) we need.
  668. #map subdirs
  669. // Iterate through all of our known source files. Each src and
  670. // metalib type file gets its corresponding Makefile listed
  671. // here. However, we test for $[DIR_TYPE] of toplevel, because the
  672. // source directories typically don't define their own DIR_TYPE
  673. // variable, and they end up inheriting this one dynamically.
  674. #forscopes */
  675. #if $[or $[eq $[DIR_TYPE], src],$[eq $[DIR_TYPE], metalib],$[and $[eq $[DIR_TYPE], toplevel],$[ne $[DIRNAME],top]]]
  676. #if $[build_directory]
  677. #addmap subdirs $[DIRNAME]
  678. #endif
  679. #endif
  680. #end */
  681. #output Makefile
  682. #format makefile
  683. #### Generated automatically by $[PPREMAKE] $[PPREMAKE_VERSION] from $[SOURCEFILE].
  684. ################################# DO NOT EDIT ###########################
  685. all : $[subdirs]
  686. test : $[subdirs:%=test-%]
  687. clean : $[subdirs:%=clean-%]
  688. cleanall : $[subdirs:%=cleanall-%]
  689. install : $[if $[CONFIG_HEADER],$[install_headers_dir] $[install_headers_dir]\$[CONFIG_HEADER]] $[subdirs:%=install-%]
  690. uninstall : $[subdirs:%=uninstall-%]
  691. #if $[CONFIG_HEADER]
  692. -del /f $[install_headers_dir]\$[CONFIG_HEADER]
  693. #endif
  694. #formap dirname subdirs
  695. #define depends
  696. $[dirname] : $[dirnames $[if $[build_directory],$[DIRNAME]],$[DEPEND_DIRS]]
  697. cd $[osfilename $[PATH]] && $(MAKE) /nologo all
  698. #end dirname
  699. #formap dirname subdirs
  700. test-$[dirname] :
  701. cd $[osfilename $[PATH]] && $(MAKE) /nologo test
  702. #end dirname
  703. #formap dirname subdirs
  704. clean-$[dirname] :
  705. cd $[osfilename $[PATH]] && $(MAKE) /nologo clean
  706. #end dirname
  707. #formap dirname subdirs
  708. cleanall-$[dirname] : $[patsubst %,cleanall-%,$[dirnames $[if $[build_directory],$[DIRNAME]],$[DEPEND_DIRS]]]
  709. cd $[osfilename $[PATH]] && $(MAKE) /nologo cleanall
  710. #end dirname
  711. #formap dirname subdirs
  712. install-$[dirname] : $[patsubst %,install-%,$[dirnames $[if $[build_directory],$[DIRNAME]],$[DEPEND_DIRS]]]
  713. cd $[osfilename $[PATH]] && $(MAKE) /nologo install
  714. #end dirname
  715. #formap dirname subdirs
  716. uninstall-$[dirname] :
  717. cd $[osfilename $[PATH]] && $(MAKE) /nologo uninstall
  718. #end dirname
  719. #if $[ne $[CONFIG_HEADER],]
  720. $[install_headers_dir] :
  721. mkdir $[install_headers_dir]
  722. $[install_headers_dir]\$[CONFIG_HEADER] : $[CONFIG_HEADER]
  723. #define local $[CONFIG_HEADER]
  724. #define dest $[install_headers_dir]
  725. $[NT_COPYCMD] $[local] $[dest]
  726. #endif
  727. #end Makefile
  728. // If there is a file called LocalSetup.pp in the package's top
  729. // directory, then invoke that. It might contain some further setup
  730. // instructions.
  731. #sinclude $[TOPDIRPREFIX]LocalSetup.msvc.pp
  732. #sinclude $[TOPDIRPREFIX]LocalSetup.pp
  733. //////////////////////////////////////////////////////////////////////
  734. #endif // DIR_TYPE