Template.unix.pp 31 KB

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