Template.gmsvc.pp 34 KB

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