Template.unix.pp 33 KB

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