Template.models.pp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. //
  2. // Template.models.pp
  3. //
  4. // This file defines the Makefiles that will be built to generate
  5. // models (egg, bam models computed from flt, soft, alias,
  6. // etc. sources). Unlike the other Template files, this is not based
  7. // directly on the BUILD_TYPE, but is specifically included when a
  8. // directory speficies a DIR_TYPE of "models". It uses some
  9. // Unix-specific conventions (like forward slashes as a directory
  10. // separator), so it requires either a Unix platform or a Cygwin
  11. // environment.
  12. //
  13. #if $[< $[PPREMAKE_VERSION],0.57]
  14. #error You need at least ppremake version 0.58 to build models.
  15. #endif
  16. #define texattrib_dir $[TOPDIR]/src/maps
  17. #define texattrib_file $[texattrib_dir]/textures.txa
  18. //////////////////////////////////////////////////////////////////////
  19. #if $[eq $[DIR_TYPE], models]
  20. //////////////////////////////////////////////////////////////////////
  21. #define pal_egg_dir pal_egg
  22. #define bam_dir bams
  23. #define soft_maps_dir soft_maps
  24. #defer phase_prefix $[if $[PHASE],phase_$[PHASE]/]
  25. #defer install_model_dir $[install_dir]/$[phase_prefix]$[INSTALL_TO]
  26. #define filter_dirs $[TARGET_DIR(filter_egg optchar_egg)]
  27. #defer source_prefix $[SOURCE_DIR:%=%/]
  28. #define build_models \
  29. $[SOURCES(flt_egg):%.flt=%.egg]
  30. #define build_chars \
  31. $[forscopes soft_char_egg,$[POLY_MODEL:%=$[EGG_PREFIX]%.egg] $[NURBS_MODEL:%=$[EGG_PREFIX]%.egg]]
  32. #define build_anims \
  33. $[forscopes soft_char_egg,$[ANIMS:%=$[EGG_PREFIX]%.egg]]
  34. #define build_eggs $[sort $[build_models] $[build_chars] $[build_anims]]
  35. #define install_eggs $[sort $[SOURCES(install_egg)] $[UNPAL_SOURCES(install_egg)]]
  36. #define install_other $[sort $[SOURCES(install_audio install_dna install_icons install_misc)]]
  37. #define install_egg_dirs $[sort $[forscopes install_egg,$[install_model_dir]]]
  38. #define installed_eggs $[sort $[forscopes install_egg,$[SOURCES:%=$[install_model_dir]/%] $[UNPAL_SOURCES:%=$[install_model_dir]/%]]]
  39. #define installed_bams $[sort $[forscopes install_egg,$[SOURCES:%.egg=$[install_model_dir]/%.bam] $[UNPAL_SOURCES:%.egg=$[install_model_dir]/%.bam]]]
  40. #define install_other_dirs $[sort $[forscopes install_audio install_dna install_icons install_misc,$[install_model_dir]]]
  41. #define installed_other $[sort $[forscopes install_audio install_dna install_icons install_misc,$[SOURCES:%=$[install_model_dir]/%]]]
  42. #define pal_egg_targets $[sort $[SOURCES(install_egg):%=$[pal_egg_dir]/%]]
  43. #define bam_targets $[install_eggs:%.egg=$[bam_dir]/%.bam]
  44. #output Makefile
  45. #format makefile
  46. #### Generated automatically by $[PPREMAKE] $[PPREMAKE_VERSION] from $[SOURCEFILE].
  47. ################################# DO NOT EDIT ###########################
  48. #define all_targets \
  49. Makefile \
  50. $[texattrib_dir] \
  51. $[filter_dirs] \
  52. $[optchar_dirs] \
  53. egg bam
  54. all : $[all_targets]
  55. #define egg_targets \
  56. $[if $[POLY_MODEL(soft_char_egg)] $[NURBS_MODEL(soft_char_egg)],$[soft_maps_dir]] \
  57. $[build_eggs]
  58. egg : $[egg_targets]
  59. #define filter_targets \
  60. $[filter_dirs] \
  61. $[forscopes install_egg,$[patsubst %,$[source_prefix]%,$[SOURCES] $[UNPAL_SOURCES]]]
  62. filter : egg $[filter_targets]
  63. pal : filter $[if $[pal_egg_targets],$[pal_egg_dir]] $[pal_egg_targets]
  64. bam : pal $[if $[bam_targets],$[bam_dir]] $[bam_targets]
  65. #define install_egg_targets \
  66. $[install_egg_dirs] \
  67. $[installed_eggs]
  68. install-egg : $[install_egg_targets]
  69. #define install_bam_targets \
  70. $[install_egg_dirs] \
  71. $[installed_bams]
  72. install-bam : $[install_bam_targets]
  73. #define install_other_targets \
  74. $[install_other_dirs] \
  75. $[installed_other]
  76. install-other : $[install_other_targets]
  77. install : install-other install-bam
  78. clean-bam :
  79. #if $[bam_targets]
  80. rm -rf $[bam_dir]
  81. #endif
  82. clean-pal : clean-bam
  83. #if $[pal_egg_targets]
  84. rm -rf $[pal_egg_dir]
  85. #endif
  86. clean : clean-pal
  87. #if $[build_eggs]
  88. rm -f $[build_eggs] $[install_eggs:%.egg=%.pt]
  89. #endif
  90. #if $[POLY_MODEL(soft_char_egg)] $[NURBS_MODEL(soft_char_egg)]
  91. rm -rf $[soft_maps_dir]
  92. #endif
  93. #if $[filter_dirs]
  94. rm -rf $[filter_dirs]
  95. #endif
  96. // We need a rule for each directory we might need to make. This
  97. // loops through the full set of directories and creates a rule to
  98. // make each one, as needed.
  99. #foreach directory $[sort \
  100. $[filter_dirs] \
  101. $[if $[pal_egg_targets],$[pal_egg_dir]] \
  102. $[if $[bam_targets],$[bam_dir]] \
  103. $[if $[POLY_MODEL(soft_char_egg)] $[NURBS_MODEL(soft_char_egg)],$[soft_maps_dir]] \
  104. $[texattrib_dir] \
  105. $[install_egg_dirs] \
  106. $[install_other_dirs] \
  107. ]
  108. $[directory] :
  109. @test -d $[directory] || echo mkdir -p $[directory]
  110. @test -d $[directory] || mkdir -p $[directory]
  111. // Sometimes we need a target to depend on the directory existing, without
  112. // being fooled by the directory's modification times. We use this
  113. // phony timestamp file to achieve that.
  114. $[directory]/stamp :
  115. @test -d $[directory] || echo mkdir -p $[directory]
  116. @test -d $[directory] || mkdir -p $[directory]
  117. @touch $[directory]/stamp
  118. #end directory
  119. // Egg file generation from Flt files.
  120. #forscopes flt_egg
  121. #foreach flt $[SOURCES]
  122. #define target $[flt:%.flt=%.egg]
  123. #define source $[flt]
  124. $[target] : $[source]
  125. flt2egg -no -uo ft -rt $[FLT2EGG_OPTS] -o $[target] $[source]
  126. #end flt
  127. #end flt_egg
  128. // Egg character model generation from Soft databases.
  129. #forscopes soft_char_egg
  130. #if $[POLY_MODEL]
  131. #define target $[EGG_PREFIX]$[POLY_MODEL].egg
  132. #define scene $[SCENE_PREFIX]$[MODEL].1-0.dsc
  133. #define source $[DATABASE]/SCENES/$[scene]
  134. $[target] : $[source]
  135. soft2egg $[SOFT2EGG_OPTS] -p -M $[target] -N $[CHAR_NAME] -d $[DATABASE] -s $[scene] -t $[soft_maps_dir]
  136. #endif
  137. #if $[NURBS_MODEL]
  138. #define target $[EGG_PREFIX]$[NURBS_MODEL].egg
  139. #define scene $[SCENE_PREFIX]$[MODEL].1-0.dsc
  140. #define source $[DATABASE]/SCENES/$[scene]
  141. $[target] : $[source]
  142. soft2egg $[SOFT2EGG_OPTS] -n -M $[target] -N $[CHAR_NAME] -d $[DATABASE] -s $[scene] -t $[soft_maps_dir]
  143. #endif
  144. #end soft_char_egg
  145. // Egg animation generation from Soft database.
  146. #forscopes soft_char_egg
  147. #foreach anim $[ANIMS]
  148. #define target $[EGG_PREFIX]$[anim].egg
  149. #define scene $[SCENE_PREFIX]$[anim].1-0.dsc
  150. #define source $[DATABASE]/SCENES/$[scene]
  151. #define begin 1
  152. #define end
  153. #if $[$[anim]_frames]
  154. #set begin $[word 1,$[$[anim]_frames]]
  155. #set end $[word 2,$[$[anim]_frames]]
  156. #endif
  157. $[target] : $[source]
  158. soft2egg $[SOFT2EGG_OPTS] -a -A $[target] -N $[CHAR_NAME] -d $[DATABASE] -s $[scene] $[begin:%=-b%] $[end:%=-e%]
  159. #end anim
  160. #end soft_char_egg
  161. // Generic egg filters.
  162. #forscopes filter_egg
  163. #foreach egg $[SOURCES]
  164. #define source $[source_prefix]$[egg]
  165. #define target $[TARGET_DIR]/$[egg]
  166. $[target] : $[source] $[pt] $[TARGET_DIR]/stamp
  167. $[COMMAND]
  168. #end egg
  169. #end filter_egg
  170. // Character optimization.
  171. #forscopes optchar_egg
  172. #define sources $[SOURCES:%=$[source_prefix]%]
  173. #define target $[TARGET_DIR]/$[notdir $[firstword $[SOURCES]]]
  174. // A bunch of rules to make each generated egg file depend on the
  175. // first one.
  176. #foreach egg $[notdir $[wordlist 2,9999,$[SOURCES]]]
  177. $[TARGET_DIR]/$[egg] : $[target] $[TARGET_DIR]/stamp
  178. touch $[TARGET_DIR]/$[egg]
  179. #end egg
  180. // And this is the actual optchar pass.
  181. $[target] : $[sources] $[TARGET_DIR]/stamp
  182. egg-optchar $[OPTCHAR_OPTS] -d $[TARGET_DIR] $[sources]
  183. #end optchar_egg
  184. // Palettization rules.
  185. #forscopes install_egg
  186. #foreach egg $[SOURCES]
  187. #define pt $[egg:%.egg=$[source_prefix]%.pt]
  188. #define source $[source_prefix]$[egg]
  189. #define target $[pal_egg_dir]/$[egg]
  190. $[target] : $[source] $[pt] $[pal_egg_dir]/stamp
  191. #if $[PHASE]
  192. egg-palettize $[PALETTIZE_OPTS] -a $[texattrib_file] -dr $[install_dir] -dm $[install_dir]/%g/maps -ds $[install_dir]/shadow_pal -g phase_$[PHASE] -gdir phase_$[PHASE] -o $[target] $[source]
  193. #else
  194. egg-palettize $[PALETTIZE_OPTS] -a $[texattrib_file] -dr $[install_dir] -dm $[install_dir]/%g/maps -ds $[install_dir]/shadow_pal -o $[target] $[source]
  195. #endif
  196. $[pt] :
  197. touch $[pt]
  198. #end egg
  199. #end install_egg
  200. // Bam file creation.
  201. #forscopes install_egg
  202. #foreach egg $[SOURCES]
  203. #define source $[pal_egg_dir]/$[egg]
  204. #define target $[bam_dir]/$[egg:%.egg=%.bam]
  205. $[target] : $[source] $[bam_dir]/stamp
  206. egg2bam -kp -tp $[install_dir] $[EGG2BAM_OPTS] -o $[target] $[source]
  207. #end egg
  208. #foreach egg $[UNPAL_SOURCES]
  209. #define source $[source_prefix]$[egg]
  210. #define target $[bam_dir]/$[egg:%.egg=%.bam]
  211. $[target] : $[source] $[bam_dir]/stamp
  212. egg2bam -kp -tp $[install_dir] $[EGG2BAM_OPTS] -o $[target] $[source]
  213. #end egg
  214. #end install_egg
  215. // Egg file installation.
  216. #forscopes install_egg
  217. #foreach egg $[SOURCES]
  218. #define local $[egg]
  219. #define sourcedir $[pal_egg_dir]
  220. #define dest $[install_model_dir]
  221. $[dest]/$[local] : $[sourcedir]/$[local]
  222. // cd ./$[sourcedir] && $[INSTALL]
  223. rm -f $[dest]/$[local]
  224. cp $[sourcedir]/$[local] $[dest]
  225. #end egg
  226. #foreach egg $[UNPAL_SOURCES]
  227. #define local $[egg]
  228. #define sourcedir $[SOURCE_DIR]
  229. #define dest $[install_model_dir]
  230. $[dest]/$[local] : $[sourcedir]/$[local]
  231. // cd ./$[sourcedir] && $[INSTALL]
  232. rm -f $[dest]/$[local]
  233. cp $[sourcedir]/$[local] $[dest]
  234. #end egg
  235. #end install_egg
  236. // Bam file installation.
  237. #forscopes install_egg
  238. #foreach egg $[SOURCES] $[UNPAL_SOURCES]
  239. #define local $[egg:%.egg=%.bam]
  240. #define sourcedir $[bam_dir]
  241. #define dest $[install_model_dir]
  242. $[dest]/$[local] : $[sourcedir]/$[local]
  243. // cd ./$[sourcedir] && $[INSTALL]
  244. rm -f $[dest]/$[local]
  245. cp $[sourcedir]/$[local] $[dest]
  246. #end egg
  247. #end install_egg
  248. // Miscellaneous file installation.
  249. #forscopes install_audio install_dna install_icons install_misc
  250. #foreach file $[SOURCES]
  251. #define local $[file]
  252. #define dest $[install_model_dir]
  253. $[dest]/$[local] : $[local]
  254. // $[INSTALL]
  255. rm -f $[dest]/$[local]
  256. cp $[local] $[dest]
  257. #end file
  258. #end install_audio install_dna install_icons install_misc
  259. #end Makefile
  260. //////////////////////////////////////////////////////////////////////
  261. #elif $[eq $[DIR_TYPE], models_group]
  262. //////////////////////////////////////////////////////////////////////
  263. // This is a group directory: a directory above a collection of source
  264. // directories, e.g. $DTOOL/src. We don't need to output anything in
  265. // this directory.
  266. //////////////////////////////////////////////////////////////////////
  267. #elif $[eq $[DIR_TYPE], models_toplevel]
  268. //////////////////////////////////////////////////////////////////////
  269. // This is the toplevel directory for a models tree, e.g. $TTMODELS.
  270. // Here we build the root makefile.
  271. #map subdirs
  272. // Iterate through all of our known source files. Each models type
  273. // file gets its corresponding Makefile listed here.
  274. #forscopes */
  275. #if $[eq $[DIR_TYPE], models]
  276. #if $[build_directory]
  277. #addmap subdirs $[DIRNAME]
  278. #endif
  279. #endif
  280. #end */
  281. #output Makefile
  282. #format makefile
  283. #### Generated automatically by $[PPREMAKE] $[PPREMAKE_VERSION] from $[SOURCEFILE].
  284. ################################# DO NOT EDIT ###########################
  285. all : egg pal repal $[subdirs]
  286. egg : $[subdirs:%=egg-%]
  287. pal : $[subdirs:%=pal-%]
  288. bam : $[subdirs:%=bam-%]
  289. clean-bam : $[subdirs:%=clean-bam-%]
  290. clean-pal : $[subdirs:%=clean-pal-%]
  291. clean : $[subdirs:%=clean-%]
  292. cleanall : $[subdirs:%=cleanall-%]
  293. install-egg : egg pal repal $[subdirs:%=install-egg-%]
  294. install-bam : egg pal repal $[subdirs:%=install-bam-%]
  295. install-other : $[subdirs:%=install-other-%]
  296. install : egg pal repal $[subdirs:%=install-%]
  297. uninstall : $[subdirs:%=uninstall-%]
  298. #
  299. # opt-pal : reorder and resize the palettes to be as optimal as
  300. # possible. This forces a rebuild of all the egg files.
  301. #
  302. opt-pal : pal do-opt-pal install
  303. optimize-palettes : opt-pal
  304. do-opt-pal :
  305. egg-palettize $[PALETTIZE_OPTS] -a $[texattrib_file] -opt -egg
  306. #
  307. # repal : reexamine the textures.txa file and do whatever needs to be
  308. # done to bring everything up to sync with it. Also make sure all egg
  309. # files are up-to-date.
  310. #
  311. repal :
  312. egg-palettize $[PALETTIZE_OPTS] -a $[texattrib_file] -all -egg
  313. re-pal : repal
  314. #
  315. # fix-pal : something has gone wrong with the palettes; rebuild all
  316. # palette images to fix it.
  317. #
  318. fix-pal :
  319. egg-palettize $[PALETTIZE_OPTS] -a $[texattrib_file] -redo -all -egg
  320. #
  321. # pi : report the palettization information to standard output for the
  322. # user's perusal.
  323. #
  324. pi :
  325. egg-palettize $[PALETTIZE_OPTS] -a $[texattrib_file] -pi
  326. #
  327. # pal-stats : report palettization statistics to standard output for the
  328. # user's perusal.
  329. #
  330. pal-stats :
  331. egg-palettize $[PALETTIZE_OPTS] -a $[texattrib_file] -s
  332. stats-pal : pal-stats
  333. // Somehow, something in the cttools confuses some shells, so that
  334. // when we are attached, 'cd foo' doesn't work, but 'cd ./foo' does.
  335. // Weird. We get around this by putting a ./ in front of each cd
  336. // target below.
  337. #formap dirname subdirs
  338. $[dirname] : $[dirnames $[if $[build_directory],$[DIRNAME]],$[DEPEND_DIRS]]
  339. cd ./$[PATH] && $(MAKE) all
  340. #end dirname
  341. #formap dirname subdirs
  342. egg-$[dirname] :
  343. cd ./$[PATH] && $(MAKE) egg
  344. #end dirname
  345. #formap dirname subdirs
  346. bam-$[dirname] :
  347. cd ./$[PATH] && $(MAKE) bam
  348. #end dirname
  349. #formap dirname subdirs
  350. pal-$[dirname] :
  351. cd ./$[PATH] && $(MAKE) pal
  352. #end dirname
  353. #formap dirname subdirs
  354. clean-bam-$[dirname] :
  355. cd ./$[PATH] && $(MAKE) clean-bam
  356. #end dirname
  357. #formap dirname subdirs
  358. clean-pal-$[dirname] :
  359. cd ./$[PATH] && $(MAKE) clean-pal
  360. #end dirname
  361. #formap dirname subdirs
  362. clean-$[dirname] :
  363. cd ./$[PATH] && $(MAKE) clean
  364. #end dirname
  365. #formap dirname subdirs
  366. cleanall-$[dirname] :
  367. cd ./$[PATH] && $(MAKE) cleanall
  368. #end dirname
  369. #formap dirname subdirs
  370. install-egg-$[dirname] :
  371. cd ./$[PATH] && $(MAKE) install-egg
  372. #end dirname
  373. #formap dirname subdirs
  374. install-bam-$[dirname] :
  375. cd ./$[PATH] && $(MAKE) install-bam
  376. #end dirname
  377. #formap dirname subdirs
  378. install-other-$[dirname] :
  379. cd ./$[PATH] && $(MAKE) install-other
  380. #end dirname
  381. #formap dirname subdirs
  382. install-$[dirname] :
  383. cd ./$[PATH] && $(MAKE) install
  384. #end dirname
  385. #formap dirname subdirs
  386. uninstall-$[dirname] :
  387. cd ./$[PATH] && $(MAKE) uninstall
  388. #end dirname
  389. #end Makefile
  390. //////////////////////////////////////////////////////////////////////
  391. #endif // DIR_TYPE