Template.unix.pp 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969
  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 $[get_metalibs $[TARGET],$[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 $[and $[lib_is_static],$[build_lib]],$[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 $[unique $[actual_local_libs:%=%$[dllext]] $[patsubst %:c,,%:m %,%$[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 $[or $[BUILDING_DLL],$[module $[BUILDING_DLL],$[TARGET]]]
  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. #if $[not $[BUILD_COMPONENTS]]
  289. // Also link in all of the component files directly into the metalib.
  290. #define sources $[sources] \
  291. $[components $[patsubst %,$[RELDIR]/$[%_obj],$[c_sources] $[mm_sources] $[cxx_sources]],$[active_component_libs]]
  292. #endif
  293. #define interrogate_sources \
  294. $[patsubst %,$[%_obj],$[cxx_interrogate_sources]]
  295. #define cc_ld $[or $[get_ld],$[CC]]
  296. #define cxx_ld $[or $[get_ld],$[CXX]]
  297. #define varname $[subst -,_,.,_,$[lib_prefix]$[TARGET]$[lib_ext]]
  298. $[varname] = $[sources] $[if $[not $[link_extra_bundle]],$[interrogate_sources]]
  299. #define target $[ODIR]/$[lib_prefix]$[TARGET]$[lib_ext]
  300. #define sources $($[varname])
  301. $[target] : $[sources] $[static_lib_dependencies]
  302. #if $[build_lib]
  303. #if $[filter %.mm %.cxx %.yxx %.lxx,$[get_sources]]
  304. $[TAB] $[link_lib_c++]
  305. #else
  306. $[TAB] $[link_lib_c]
  307. #endif
  308. #endif // BUILD_LIB
  309. #if $[link_extra_bundle]
  310. // Also generate the bundles (on OSX only).
  311. #define target $[ODIR]/$[lib_prefix]$[TARGET]$[bundle_ext]
  312. #define sources $[interrogate_sources] $[ODIR]/$[lib_prefix]$[TARGET]$[lib_ext]
  313. $[target] : $[sources] $[static_lib_dependencies]
  314. $[TAB] $[BUNDLE_LIB_C++]
  315. #endif // BUNDLE_EXT
  316. #endif
  317. // Here are the rules to install and uninstall the library and
  318. // everything that goes along with it.
  319. #define installed_files \
  320. $[if $[build_lib],$[install_lib_dir]/$[lib_prefix]$[TARGET]$[lib_ext]] \
  321. $[if $[link_extra_bundle],$[install_lib_dir]/$[lib_prefix]$[TARGET]$[bundle_ext]] \
  322. $[INSTALL_SCRIPTS:%=$[install_bin_dir]/%] \
  323. $[INSTALL_MODULES:%=$[install_lib_dir]/%] \
  324. $[INSTALL_HEADERS:%=$[install_headers_dir]/%] \
  325. $[INSTALL_DATA:%=$[install_data_dir]/%] \
  326. $[INSTALL_CONFIG:%=$[install_config_dir]/%] \
  327. $[igatedb:$[ODIR]/%=$[install_igatedb_dir]/%]
  328. install-lib$[TARGET] : $[installed_files]
  329. uninstall-lib$[TARGET] :
  330. #if $[installed_files]
  331. $[TAB] rm -f $[sort $[installed_files]]
  332. #endif
  333. $[install_lib_dir]/$[lib_prefix]$[TARGET]$[lib_ext] : $[ODIR]/$[lib_prefix]$[TARGET]$[lib_ext]
  334. #define local $[ODIR]/$[lib_prefix]$[TARGET]$[lib_ext]
  335. #define dest $[install_lib_dir]
  336. $[TAB] $[INSTALL_PROG]
  337. #if $[link_extra_bundle]
  338. $[install_lib_dir]/$[lib_prefix]$[TARGET]$[bundle_ext] : $[ODIR]/$[lib_prefix]$[TARGET]$[bundle_ext]
  339. #define local $[ODIR]/$[lib_prefix]$[TARGET]$[bundle_ext]
  340. #define dest $[install_lib_dir]
  341. $[TAB] $[INSTALL_PROG]
  342. #endif // link_extra_bundle
  343. #if $[igatescan]
  344. // Now, some additional rules to generate and compile the interrogate
  345. // data, if needed.
  346. // The library name is based on this library.
  347. #define igatelib $[lib_prefix]$[TARGET]
  348. // The module name comes from the metalib that includes this library.
  349. #define igatemod $[module $[TARGET],$[TARGET]]
  350. #if $[eq $[igatemod],]
  351. // Unless no metalib includes this library.
  352. #define igatemod $[TARGET]
  353. #endif
  354. $[igatedb:$[ODIR]/%=$[install_igatedb_dir]/%] : $[igatedb]
  355. #define local $[igatedb]
  356. #define dest $[install_igatedb_dir]
  357. $[TAB] $[INSTALL]
  358. // We have to split this out as a separate rule to properly support
  359. // parallel make.
  360. $[igatedb] : $[igateoutput]
  361. $[lib_prefix]$[TARGET]_igatescan = $[igatescan]
  362. $[igateoutput] : $[sort $[patsubst %.h,%.h,%.I,%.I,%.T,%.T,%,,$[dependencies $[igatescan]] $[igatescan:%=./%]]]
  363. $[TAB] $[INTERROGATE] -od $[igatedb] -oc $[igateoutput] $[interrogate_options] -module "$[igatemod]" -library "$[igatelib]" $($[lib_prefix]$[TARGET]_igatescan)
  364. #endif // igatescan
  365. #if $[igatemout]
  366. // And finally, some additional rules to build the interrogate module
  367. // file into the library, if this is a metalib that includes
  368. // interrogated components.
  369. #define igatelib $[lib_prefix]$[TARGET]
  370. #define igatemod $[TARGET]
  371. $[lib_prefix]$[TARGET]_igatemscan = $[igatemscan]
  372. #define target $[igatemout]
  373. #define sources $($[lib_prefix]$[TARGET]_igatemscan)
  374. $[target] : $[sources]
  375. $[TAB] $[INTERROGATE_MODULE] -oc $[target] -module "$[igatemod]" -library "$[igatelib]" $[interrogate_module_options] $[sources]
  376. #endif // igatemout
  377. #end metalib_target lib_target ss_lib_target static_lib_target dynamic_lib_target
  378. /////////////////////////////////////////////////////////////////////
  379. // Now, the noninstalled dynamic libraries. These are presumably used
  380. // only within this directory, or at the most within this tree, and
  381. // also presumably will never include interrogate data. That, plus
  382. // the fact that we don't need to generate install rules, makes it a
  383. // lot simpler.
  384. /////////////////////////////////////////////////////////////////////
  385. #forscopes noinst_lib_target
  386. #define varname $[subst -,_,$[lib_prefix]$[TARGET]_so]
  387. $[varname] = $[patsubst %,$[%_obj],$[compile_sources]]
  388. #define target $[ODIR]/$[lib_prefix]$[TARGET]$[lib_ext]
  389. #define sources $($[varname])
  390. $[target] : $[sources] $[static_lib_dependencies]
  391. #if $[filter %.mm %.cxx %.yxx %.lxx,$[get_sources]]
  392. $[TAB] $[link_lib_c++]
  393. #else
  394. $[TAB] $[link_lib_c]
  395. #endif
  396. #end noinst_lib_target
  397. /////////////////////////////////////////////////////////////////////
  398. // The sed_bin_targets are a special bunch. These are scripts that
  399. // are to be preprocessed with sed before being installed, for
  400. // instance to insert a path or something in an appropriate place.
  401. /////////////////////////////////////////////////////////////////////
  402. #forscopes sed_bin_target
  403. $[TARGET] : $[ODIR]/$[TARGET]
  404. #define target $[ODIR]/$[TARGET]
  405. #define source $[SOURCE]
  406. #define script $[COMMAND]
  407. $[target] : $[source]
  408. $[TAB] $[SED]
  409. $[TAB] chmod +x $[target]
  410. #define installed_files \
  411. $[install_bin_dir]/$[TARGET]
  412. install-$[TARGET] : $[installed_files]
  413. uninstall-$[TARGET] :
  414. #if $[installed_files]
  415. $[TAB] rm -f $[sort $[installed_files]]
  416. #endif
  417. #define local $[ODIR]/$[TARGET]
  418. #define dest $[install_bin_dir]
  419. $[install_bin_dir]/$[TARGET] : $[ODIR]/$[TARGET]
  420. $[TAB] $[INSTALL_PROG]
  421. #end sed_bin_target
  422. /////////////////////////////////////////////////////////////////////
  423. // And now, the bin_targets. These are normal C++ executables. No
  424. // interrogate, metalibs, or any such nonsense here.
  425. /////////////////////////////////////////////////////////////////////
  426. #forscopes bin_target
  427. $[TARGET] : $[ODIR]/$[TARGET]
  428. #define varname $[subst -,_,bin_$[TARGET]]
  429. $[varname] = $[patsubst %,$[%_obj],$[compile_sources]]
  430. #define target $[ODIR]/$[TARGET]
  431. #define sources $($[varname])
  432. #define cc_ld $[or $[get_ld],$[CC]]
  433. #define cxx_ld $[or $[get_ld],$[CXX]]
  434. #define flags $[lflags]
  435. $[target] : $[sources] $[static_lib_dependencies]
  436. #if $[filter %.mm %.cxx %.yxx %.lxx,$[get_sources]]
  437. $[TAB] $[link_bin_c++]
  438. #else
  439. $[TAB] $[link_bin_c]
  440. #endif
  441. #define installed_files \
  442. $[install_bin_dir]/$[TARGET] \
  443. $[INSTALL_SCRIPTS:%=$[install_bin_dir]/%] \
  444. $[INSTALL_MODULES:%=$[install_lib_dir]/%] \
  445. $[INSTALL_HEADERS:%=$[install_headers_dir]/%] \
  446. $[INSTALL_DATA:%=$[install_data_dir]/%] \
  447. $[INSTALL_CONFIG:%=$[install_config_dir]/%]
  448. install-$[TARGET] : $[installed_files]
  449. uninstall-$[TARGET] :
  450. #if $[installed_files]
  451. $[TAB] rm -f $[sort $[installed_files]]
  452. #endif
  453. $[install_bin_dir]/$[TARGET] : $[ODIR]/$[TARGET]
  454. #define local $[ODIR]/$[TARGET]
  455. #define dest $[install_bin_dir]
  456. $[TAB] $[INSTALL_PROG]
  457. #end bin_target
  458. /////////////////////////////////////////////////////////////////////
  459. // The noinst_bin_targets and the test_bin_targets share the property
  460. // of being built (when requested), but having no install rules.
  461. /////////////////////////////////////////////////////////////////////
  462. #forscopes noinst_bin_target test_bin_target
  463. $[TARGET] : $[ODIR]/$[TARGET]
  464. #define varname $[subst -,_,bin_$[TARGET]]
  465. $[varname] = $[patsubst %,$[%_obj],$[compile_sources]]
  466. #define target $[ODIR]/$[TARGET]
  467. #define sources $($[varname])
  468. #define cc_ld $[or $[get_ld],$[CC]]
  469. #define cxx_ld $[or $[get_ld],$[CXX]]
  470. #define flags $[lflags]
  471. $[target] : $[sources] $[static_lib_dependencies]
  472. #if $[filter %.mm %.cxx %.yxx %.lxx,$[get_sources]]
  473. $[TAB] $[link_bin_c++]
  474. #else
  475. $[TAB] $[link_bin_c]
  476. #endif
  477. #end noinst_bin_target test_bin_target
  478. /////////////////////////////////////////////////////////////////////
  479. // Rules to run bison and/or flex as needed.
  480. /////////////////////////////////////////////////////////////////////
  481. // Rules to generate a C++ file from a Bison input file.
  482. #foreach file $[sort $[yxx_st_sources]]
  483. #define target $[patsubst %.yxx,%.cxx,$[file]]
  484. #define target_header $[patsubst %.yxx,%.h,$[file]]
  485. #define target_prebuilt $[target].prebuilt
  486. #define target_header_prebuilt $[target_header].prebuilt
  487. #if $[HAVE_BISON]
  488. $[target] : $[file]
  489. $[TAB] $[BISON] $[YFLAGS] -y $[if $[YACC_PREFIX],-d --name-prefix=$[YACC_PREFIX]] $[file]
  490. $[TAB] mv y.tab.c $[target]
  491. $[TAB] mv y.tab.h $[target_header]
  492. $[target_header] : $[target]
  493. $[target_prebuilt] : $[target]
  494. $[TAB] cp $[target] $[target_prebuilt]
  495. $[target_header_prebuilt] : $[target_header]
  496. $[TAB] cp $[target_header] $[target_header_prebuilt]
  497. #else // HAVE_BISON
  498. $[target] : $[target_prebuilt]
  499. $[TAB] cp $[target_prebuilt] $[target]
  500. $[target_header] : $[target_header_prebuilt]
  501. $[TAB] cp $[target_header_prebuilt] $[target_header]
  502. #endif // HAVE_BISON
  503. #end file
  504. // Rules to generate a C++ file from a Flex input file.
  505. #foreach file $[sort $[lxx_st_sources]]
  506. #define target $[patsubst %.lxx,%.cxx,$[file]]
  507. #define target_prebuilt $[target].prebuilt
  508. #if $[HAVE_BISON]
  509. #define source $[file]
  510. $[target] : $[file]
  511. $[TAB] $[FLEX] $[FLEXFLAGS] $[if $[YACC_PREFIX],-P$[YACC_PREFIX]] -olex.yy.c $[file]
  512. #define source lex.yy.c
  513. #define script /#include <unistd.h>/d
  514. $[TAB] $[SED]
  515. $[TAB] rm lex.yy.c
  516. $[target_prebuilt] : $[target]
  517. $[TAB] cp $[target] $[target_prebuilt]
  518. #else // HAVE_BISON
  519. $[target] : $[target_prebuilt]
  520. $[TAB] cp $[target_prebuilt] $[target]
  521. #endif // HAVE_BISON
  522. #end file
  523. /////////////////////////////////////////////////////////////////////
  524. // Finally, we put in the rules to compile each source file into a .obj
  525. // file.
  526. /////////////////////////////////////////////////////////////////////
  527. #forscopes static_lib_target bin_target noinst_bin_target test_bin_target
  528. // Rules to compile ordinary C files (static objects).
  529. #foreach file $[sort $[c_sources]]
  530. #define target $[$[file]_obj]
  531. #define source $[file]
  532. #define ipath $[target_ipath]
  533. #define flags $[cflags]
  534. #if $[ne $[file], $[notdir $file]]
  535. // If the source file is not in the current directory, tack on "."
  536. // to front of the ipath.
  537. #set ipath . $[ipath]
  538. #endif
  539. $[target] : $[source] $[get_depends $[source]]
  540. $[TAB] $[compile_c]
  541. #end file
  542. // Rules to compile C++ files (static objects).
  543. #foreach file $[sort $[mm_sources] $[cxx_sources] $[cxx_interrogate_sources]]
  544. #define target $[$[file]_obj]
  545. #define source $[file]
  546. #define ipath $[target_ipath]
  547. #define flags $[c++flags]
  548. #if $[ne $[file], $[notdir $file]]
  549. // If the source file is not in the current directory, tack on "."
  550. // to front of the ipath.
  551. #set ipath . $[ipath]
  552. #endif
  553. // Yacc must run before some files can be compiled, so all files
  554. // depend on yacc having run.
  555. $[target] : $[source] $[get_depends $[source]] $[yxx_sources:%.yxx=%.h]
  556. $[TAB] $[compile_c++]
  557. #end file
  558. #end static_lib_target bin_target noinst_bin_target test_bin_target
  559. #forscopes metalib_target lib_target noinst_lib_target ss_lib_target
  560. // Rules to compile ordinary C files (shared objects).
  561. #foreach file $[sort $[c_sources]]
  562. #define target $[$[file]_obj]
  563. #define source $[file]
  564. #define ipath $[target_ipath]
  565. #define flags $[cflags] $[CFLAGS_SHARED] $[building_var:%=-D%]
  566. #if $[ne $[file], $[notdir $file]]
  567. // If the source file is not in the current directory, tack on "."
  568. // to front of the ipath.
  569. #set ipath . $[ipath]
  570. #endif
  571. $[target] : $[source] $[get_depends $[source]]
  572. $[TAB] $[compile_c]
  573. #end file
  574. // Rules to compile C++ files (shared objects).
  575. #foreach file $[sort $[mm_sources] $[cxx_sources] $[cxx_interrogate_sources]]
  576. #define target $[$[file]_obj]
  577. #define source $[file]
  578. #define ipath $[target_ipath]
  579. #define flags $[c++flags] $[CFLAGS_SHARED] $[building_var:%=-D%]
  580. #if $[ne $[file], $[notdir $file]]
  581. // If the source file is not in the current directory, tack on "."
  582. // to front of the ipath.
  583. #set ipath . $[ipath]
  584. #endif
  585. // Yacc must run before some files can be compiled, so all files
  586. // depend on yacc having run.
  587. $[target] : $[source] $[get_depends $[source]] $[yxx_sources:%.yxx=%.h]
  588. $[TAB] $[compile_c++]
  589. #end file
  590. #end metalib_target lib_target noinst_lib_target ss_lib_target
  591. // And now the rules to install the auxiliary files, like headers and
  592. // data files.
  593. #foreach file $[install_scripts]
  594. $[install_bin_dir]/$[file] : $[file]
  595. #define local $[file]
  596. #define dest $[install_bin_dir]
  597. $[TAB] $[INSTALL_PROG]
  598. #end file
  599. #foreach file $[install_modules]
  600. $[install_lib_dir]/$[file] : $[file]
  601. #define local $[file]
  602. #define dest $[install_lib_dir]
  603. $[TAB] $[INSTALL_PROG]
  604. #end file
  605. #foreach file $[install_headers]
  606. $[install_headers_dir]/$[file] : $[file]
  607. #define local $[file]
  608. #define dest $[install_headers_dir]
  609. $[TAB] $[INSTALL]
  610. #end file
  611. #foreach file $[install_parser_inc]
  612. #if $[ne $[dir $[file]], ./]
  613. $[install_parser_inc_dir]/$[file] : $[notdir $[file]]
  614. #define local $[notdir $[file]]
  615. #define dest $[install_parser_inc_dir]/$[dir $[file]]
  616. $[TAB] mkdir -p $[install_parser_inc_dir]/$[dir $[file]] || echo
  617. $[TAB] $[INSTALL]
  618. #else
  619. $[install_parser_inc_dir]/$[file] : $[file]
  620. #define local $[file]
  621. #define dest $[install_parser_inc_dir]
  622. $[TAB] $[INSTALL]
  623. #endif
  624. #end file
  625. #foreach file $[install_data]
  626. $[install_data_dir]/$[file] : $[file]
  627. #define local $[file]
  628. #define dest $[install_data_dir]
  629. $[TAB] $[INSTALL]
  630. #end file
  631. #foreach file $[install_config]
  632. $[install_config_dir]/$[file] : $[file]
  633. #define local $[file]
  634. #define dest $[install_config_dir]
  635. $[TAB] $[INSTALL]
  636. #end file
  637. #foreach file $[install_py]
  638. $[install_py_dir]/$[file] : $[file]
  639. #define local $[file]
  640. #define dest $[install_py_dir]
  641. $[TAB] $[INSTALL]
  642. #end file
  643. #if $[install_py]
  644. $[install_py_package_dir]/__init__.py :
  645. $[TAB] touch $[install_py_package_dir]/__init__.py
  646. #endif
  647. // Finally, all the special targets. These are commands that just need
  648. // to be invoked; we don't pretend to know what they are.
  649. #forscopes special_target
  650. $[TARGET] :
  651. $[TAB] $[COMMAND]
  652. #end special_target
  653. // Finally, the rules to freshen the Makefile itself.
  654. Makefile : $[SOURCE_FILENAME] $[EXTRA_PPREMAKE_SOURCE]
  655. $[TAB] ppremake
  656. #if $[USE_TAU]
  657. #foreach composite_file $[composite_list]
  658. $[composite_file] : $[$[composite_file]_sources]
  659. $[TAB] ppremake
  660. #end composite_file
  661. #endif // USE_TAU
  662. #if $[and $[DEPENDENCY_CACHE_FILENAME],$[dep_sources]]
  663. $[DEPENDENCY_CACHE_FILENAME] : $[dep_sources]
  664. $[TAB] @ppremake -D $[DEPENDENCY_CACHE_FILENAME]
  665. #endif
  666. #end Makefile
  667. //////////////////////////////////////////////////////////////////////
  668. #elif $[eq $[DIR_TYPE], group]
  669. //////////////////////////////////////////////////////////////////////
  670. // This is a group directory: a directory above a collection of source
  671. // directories, e.g. $DTOOL/src. We don't need to output anything in
  672. // this directory.
  673. //////////////////////////////////////////////////////////////////////
  674. #elif $[eq $[DIR_TYPE], toplevel]
  675. //////////////////////////////////////////////////////////////////////
  676. // This is the toplevel directory, e.g. $DTOOL. Here we build the
  677. // root makefile and also synthesize the dtool_config.h (or whichever
  678. // file) we need.
  679. #map subdirs
  680. // Iterate through all of our known source files. Each src and
  681. // metalib type file gets its corresponding Makefile listed
  682. // here. However, we test for $[DIR_TYPE] of toplevel, because the
  683. // source directories typically don't define their own DIR_TYPE
  684. // variable, and they end up inheriting this one dynamically.
  685. #forscopes */
  686. #if $[or $[eq $[DIR_TYPE], src],$[eq $[DIR_TYPE], metalib],$[and $[eq $[DIR_TYPE], toplevel],$[ne $[DIRNAME],top]]]
  687. #if $[build_directory]
  688. #addmap subdirs $[DIRNAME]
  689. #endif
  690. #endif
  691. #end */
  692. #if $[PYTHON_PACKAGE]
  693. #include $[THISDIRPREFIX]PythonPackageInit.pp
  694. #endif
  695. #output Makefile
  696. #format makefile
  697. #### Generated automatically by $[PPREMAKE] $[PPREMAKE_VERSION] from $[SOURCEFILE].
  698. ################################# DO NOT EDIT ###########################
  699. all : $[subdirs]
  700. test : $[subdirs:%=test-%]
  701. igate : $[subdirs:%=igate-%]
  702. clean : $[subdirs:%=clean-%]
  703. clean-igate : $[subdirs:%=clean-igate-%]
  704. cleanall : $[subdirs:%=cleanall-%]
  705. install : $[if $[CONFIG_HEADER],$[install_headers_dir] $[install_headers_dir]/$[CONFIG_HEADER]] $[subdirs:%=install-%]
  706. install-igate : $[subdirs:%=install-igate-%]
  707. uninstall : $[subdirs:%=uninstall-%]
  708. #if $[CONFIG_HEADER]
  709. $[TAB] rm -f $[install_headers_dir]/$[CONFIG_HEADER]
  710. #endif
  711. uninstall-igate : $[subdirs:%=uninstall-igate-%]
  712. #if $[HAVE_BISON]
  713. prebuild-bison : $[subdirs:%=prebuild-bison-%]
  714. clean-prebuild-bison : $[subdirs:%=clean-prebuild-bison-%]
  715. #endif
  716. #formap dirname subdirs
  717. #define depends
  718. $[dirname] : $[dirnames $[if $[build_directory],$[DIRNAME]],$[DEPEND_DIRS]]
  719. $[TAB] cd ./$[PATH] && $(MAKE) all
  720. #end dirname
  721. #formap dirname subdirs
  722. test-$[dirname] :
  723. $[TAB] cd ./$[PATH] && $(MAKE) test
  724. #end dirname
  725. #formap dirname subdirs
  726. igate-$[dirname] :
  727. $[TAB]cd ./$[PATH] && $(MAKE) igate
  728. #end dirname
  729. #formap dirname subdirs
  730. clean-$[dirname] :
  731. $[TAB] cd ./$[PATH] && $(MAKE) clean
  732. #end dirname
  733. #formap dirname subdirs
  734. clean-igate-$[dirname] :
  735. $[TAB] cd ./$[PATH] && $(MAKE) clean-igate
  736. #end dirname
  737. #formap dirname subdirs
  738. cleanall-$[dirname] : $[patsubst %,cleanall-%,$[dirnames $[if $[build_directory],$[DIRNAME]],$[DEPEND_DIRS]]]
  739. $[TAB] cd ./$[PATH] && $(MAKE) cleanall
  740. #end dirname
  741. #formap dirname subdirs
  742. install-$[dirname] : $[patsubst %,install-%,$[dirnames $[if $[build_directory],$[DIRNAME]],$[DEPEND_DIRS]]]
  743. $[TAB] cd ./$[PATH] && $(MAKE) install
  744. #end dirname
  745. #formap dirname subdirs
  746. install-igate-$[dirname] :
  747. $[TAB] cd ./$[PATH] && $(MAKE) install-igate
  748. #end dirname
  749. #formap dirname subdirs
  750. uninstall-$[dirname] :
  751. $[TAB] cd ./$[PATH] && $(MAKE) uninstall
  752. #end dirname
  753. #formap dirname subdirs
  754. uninstall-igate-$[dirname] :
  755. $[TAB] cd ./$[PATH] && $(MAKE) uninstall-igate
  756. #end dirname
  757. #if $[HAVE_BISON]
  758. #formap dirname subdirs
  759. prebuild-bison-$[dirname] :
  760. $[TAB]cd ./$[PATH] && $(MAKE) prebuild-bison
  761. clean-prebuild-bison-$[dirname] :
  762. $[TAB]cd ./$[PATH] && $(MAKE) clean-prebuild-bison
  763. #end dirname
  764. #endif
  765. #if $[ne $[CONFIG_HEADER],]
  766. $[install_headers_dir] :
  767. $[TAB] @test -d $[install_headers_dir] || echo mkdir -p $[install_headers_dir]
  768. $[TAB] @test -d $[install_headers_dir] || mkdir -p $[install_headers_dir]
  769. $[install_headers_dir]/$[CONFIG_HEADER] : $[CONFIG_HEADER]
  770. #define local $[CONFIG_HEADER]
  771. #define dest $[install_headers_dir]
  772. $[TAB] $[INSTALL]
  773. #endif
  774. // Finally, the rules to freshen the Makefile itself.
  775. Makefile : $[SOURCE_FILENAME] $[EXTRA_PPREMAKE_SOURCE]
  776. $[TAB] ppremake
  777. #end Makefile
  778. // If there is a file called LocalSetup.pp in the package's top
  779. // directory, then invoke that. It might contain some further setup
  780. // instructions.
  781. #sinclude $[TOPDIRPREFIX]LocalSetup.unix.pp
  782. #sinclude $[TOPDIRPREFIX]LocalSetup.pp
  783. //////////////////////////////////////////////////////////////////////
  784. #elif $[or $[eq $[DIR_TYPE], models],$[eq $[DIR_TYPE], models_toplevel],$[eq $[DIR_TYPE], models_group]]
  785. //////////////////////////////////////////////////////////////////////
  786. #include $[THISDIRPREFIX]Template.models.pp
  787. //////////////////////////////////////////////////////////////////////
  788. #endif // DIR_TYPE