Template.unix.pp 30 KB

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