Template.gmsvc.pp 34 KB

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