Template.unix.pp 34 KB

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