Template.unix.pp 29 KB

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