Template.models.pp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  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 specifies 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. $[SOURCES(lwo_egg):%.lwo=%.egg] \
  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_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. uninstall : uninstall-other uninstall-bam uninstall-egg
  79. clean-bam :
  80. #if $[bam_targets]
  81. rm -rf $[bam_dir]
  82. #endif
  83. clean-pal : clean-bam
  84. #if $[pal_egg_targets]
  85. rm -rf $[pal_egg_dir]
  86. #endif
  87. clean : clean-pal
  88. #if $[build_eggs]
  89. rm -f $[build_eggs] $[install_eggs:%.egg=%.pt]
  90. #endif
  91. #if $[POLY_MODEL(soft_char_egg)] $[NURBS_MODEL(soft_char_egg)]
  92. rm -rf $[soft_maps_dir]
  93. #endif
  94. #if $[filter_dirs]
  95. rm -rf $[filter_dirs]
  96. #endif
  97. // We need a rule for each directory we might need to make. This
  98. // loops through the full set of directories and creates a rule to
  99. // make each one, as needed.
  100. #foreach directory $[sort \
  101. $[filter_dirs] \
  102. $[if $[pal_egg_targets],$[pal_egg_dir]] \
  103. $[if $[bam_targets],$[bam_dir]] \
  104. $[if $[POLY_MODEL(soft_char_egg)] $[NURBS_MODEL(soft_char_egg)],$[soft_maps_dir]] \
  105. $[texattrib_dir] \
  106. $[install_egg_dirs] \
  107. $[install_other_dirs] \
  108. ]
  109. $[directory] :
  110. @test -d $[directory] || echo mkdir -p $[directory]
  111. @test -d $[directory] || mkdir -p $[directory]
  112. // Sometimes we need a target to depend on the directory existing, without
  113. // being fooled by the directory's modification times. We use this
  114. // phony timestamp file to achieve that.
  115. $[directory]/stamp :
  116. @test -d $[directory] || echo mkdir -p $[directory]
  117. @test -d $[directory] || mkdir -p $[directory]
  118. @touch $[directory]/stamp
  119. #end directory
  120. // Egg file generation from Flt files.
  121. #forscopes flt_egg
  122. #foreach flt $[SOURCES]
  123. #define target $[flt:%.flt=%.egg]
  124. #define source $[flt]
  125. $[target] : $[source]
  126. flt2egg $[FLT2EGG_OPTS] -o $[target] $[source]
  127. #end flt
  128. #end flt_egg
  129. // Egg file generation from Lightwave files.
  130. #forscopes lwo_egg
  131. #foreach lwo $[SOURCES]
  132. #define target $[lwo:%.lwo=%.egg]
  133. #define source $[lwo]
  134. $[target] : $[source]
  135. lwo2egg $[LWO2EGG_OPTS] -o $[target] $[source]
  136. #end lwo
  137. #end lwo_egg
  138. // Egg character model generation from Soft databases.
  139. #forscopes soft_char_egg
  140. #if $[POLY_MODEL]
  141. #define target $[EGG_PREFIX]$[POLY_MODEL].egg
  142. #define scene $[SCENE_PREFIX]$[MODEL].1-0.dsc
  143. #define source $[DATABASE]/SCENES/$[scene]
  144. $[target] : $[source]
  145. soft2egg $[SOFT2EGG_OPTS] -p -M $[target] -N $[CHAR_NAME] -d $[DATABASE] -s $[scene] -t $[soft_maps_dir]
  146. #endif
  147. #if $[NURBS_MODEL]
  148. #define target $[EGG_PREFIX]$[NURBS_MODEL].egg
  149. #define scene $[SCENE_PREFIX]$[MODEL].1-0.dsc
  150. #define source $[DATABASE]/SCENES/$[scene]
  151. $[target] : $[source]
  152. soft2egg $[SOFT2EGG_OPTS] -n -M $[target] -N $[CHAR_NAME] -d $[DATABASE] -s $[scene] -t $[soft_maps_dir]
  153. #endif
  154. #end soft_char_egg
  155. // Egg animation generation from Soft database.
  156. #forscopes soft_char_egg
  157. #foreach anim $[ANIMS]
  158. #define target $[EGG_PREFIX]$[anim].egg
  159. #define scene $[SCENE_PREFIX]$[anim].1-0.dsc
  160. #define source $[DATABASE]/SCENES/$[scene]
  161. #define begin 1
  162. #define end
  163. #if $[$[anim]_frames]
  164. #set begin $[word 1,$[$[anim]_frames]]
  165. #set end $[word 2,$[$[anim]_frames]]
  166. #endif
  167. $[target] : $[source]
  168. soft2egg $[SOFT2EGG_OPTS] -a -A $[target] -N $[CHAR_NAME] -d $[DATABASE] -s $[scene] $[begin:%=-b%] $[end:%=-e%]
  169. #end anim
  170. #end soft_char_egg
  171. // Generic egg filters.
  172. #forscopes filter_egg
  173. #foreach egg $[SOURCES]
  174. #define source $[source_prefix]$[egg]
  175. #define target $[TARGET_DIR]/$[notdir $[egg]]
  176. $[target] : $[source] $[pt] $[TARGET_DIR]/stamp
  177. $[COMMAND]
  178. #end egg
  179. #end filter_egg
  180. // Character optimization.
  181. #forscopes optchar_egg
  182. #define sources $[SOURCES:%=$[source_prefix]%]
  183. #define target $[TARGET_DIR]/$[notdir $[firstword $[SOURCES]]]
  184. // A bunch of rules to make each generated egg file depend on the
  185. // first one.
  186. #foreach egg $[notdir $[wordlist 2,9999,$[SOURCES]]]
  187. $[TARGET_DIR]/$[egg] : $[target] $[TARGET_DIR]/stamp
  188. touch $[TARGET_DIR]/$[egg]
  189. #end egg
  190. // And this is the actual optchar pass.
  191. $[target] : $[sources] $[TARGET_DIR]/stamp
  192. egg-optchar $[OPTCHAR_OPTS] -d $[TARGET_DIR] $[sources]
  193. #end optchar_egg
  194. // Palettization rules.
  195. #forscopes install_egg
  196. #foreach egg $[SOURCES]
  197. #define pt $[egg:%.egg=$[source_prefix]%.pt]
  198. #define source $[source_prefix]$[egg]
  199. #define target $[pal_egg_dir]/$[egg]
  200. $[target] : $[source] $[pt] $[pal_egg_dir]/stamp
  201. #if $[PHASE]
  202. 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]
  203. #else
  204. egg-palettize $[PALETTIZE_OPTS] -a $[texattrib_file] -dr $[install_dir] -dm $[install_dir]/%g/maps -ds $[install_dir]/shadow_pal -o $[target] $[source]
  205. #endif
  206. $[pt] :
  207. touch $[pt]
  208. #end egg
  209. #end install_egg
  210. // Bam file creation.
  211. #forscopes install_egg
  212. #foreach egg $[SOURCES]
  213. #define source $[pal_egg_dir]/$[egg]
  214. #define target $[bam_dir]/$[egg:%.egg=%.bam]
  215. $[target] : $[source] $[bam_dir]/stamp
  216. egg2bam -kp -tp $[install_dir] $[EGG2BAM_OPTS] -o $[target] $[source]
  217. #end egg
  218. #foreach egg $[UNPAL_SOURCES]
  219. #define source $[source_prefix]$[egg]
  220. #define target $[bam_dir]/$[egg:%.egg=%.bam]
  221. $[target] : $[source] $[bam_dir]/stamp
  222. egg2bam -kp -tp $[install_dir] $[EGG2BAM_OPTS] -o $[target] $[source]
  223. #end egg
  224. #end install_egg
  225. // Egg file installation.
  226. #forscopes install_egg
  227. #foreach egg $[SOURCES]
  228. #define local $[egg]
  229. #define sourcedir $[pal_egg_dir]
  230. #define dest $[install_model_dir]
  231. $[dest]/$[local] : $[sourcedir]/$[local]
  232. // cd ./$[sourcedir] && $[INSTALL]
  233. rm -f $[dest]/$[local]
  234. cp $[sourcedir]/$[local] $[dest]
  235. #end egg
  236. #foreach egg $[UNPAL_SOURCES]
  237. #define local $[egg]
  238. #define dest $[install_model_dir]
  239. $[dest]/$[local] : $[source_prefix]$[local]
  240. // $[INSTALL]
  241. rm -f $[dest]/$[local]
  242. cp $[source_prefix]$[local] $[dest]
  243. #end egg
  244. #end install_egg
  245. // Egg file uninstallation.
  246. uninstall-egg :
  247. #forscopes install_egg
  248. #define files $[patsubst %,$[install_model_dir]/%,$[SOURCES] $[UNPAL_SOURCES]]
  249. #if $[files]
  250. rm -f $[files]
  251. #endif
  252. #end install_egg
  253. // Bam file installation.
  254. #forscopes install_egg
  255. #foreach egg $[SOURCES] $[UNPAL_SOURCES]
  256. #define local $[egg:%.egg=%.bam]
  257. #define sourcedir $[bam_dir]
  258. #define dest $[install_model_dir]
  259. $[dest]/$[local] : $[sourcedir]/$[local]
  260. // cd ./$[sourcedir] && $[INSTALL]
  261. rm -f $[dest]/$[local]
  262. cp $[sourcedir]/$[local] $[dest]
  263. #end egg
  264. #end install_egg
  265. // Bam file uninstallation.
  266. uninstall-bam :
  267. #forscopes install_egg
  268. #define files $[patsubst %.egg,$[install_model_dir]/%.bam,$[SOURCES] $[UNPAL_SOURCES]]
  269. #if $[files]
  270. rm -f $[files]
  271. #endif
  272. #end install_egg
  273. // Miscellaneous file installation.
  274. #forscopes install_audio install_dna install_icons install_misc
  275. #foreach file $[SOURCES]
  276. #define local $[file]
  277. #define dest $[install_model_dir]
  278. $[dest]/$[local] : $[local]
  279. // $[INSTALL]
  280. rm -f $[dest]/$[local]
  281. cp $[local] $[dest]
  282. #end file
  283. #end install_audio install_dna install_icons install_misc
  284. // Miscellaneous file uninstallation.
  285. uninstall-other:
  286. #forscopes install_audio install_dna install_icons install_misc
  287. #define files $[patsubst %,$[install_model_dir]/%,$[SOURCES]]
  288. #if $[files]
  289. rm -f $[files]
  290. #endif
  291. #end install_audio install_dna install_icons install_misc
  292. #end Makefile
  293. //////////////////////////////////////////////////////////////////////
  294. #elif $[eq $[DIR_TYPE], models_group]
  295. //////////////////////////////////////////////////////////////////////
  296. // This is a group directory: a directory above a collection of source
  297. // directories, e.g. $DTOOL/src. We don't need to output anything in
  298. // this directory.
  299. //////////////////////////////////////////////////////////////////////
  300. #elif $[eq $[DIR_TYPE], models_toplevel]
  301. //////////////////////////////////////////////////////////////////////
  302. // This is the toplevel directory for a models tree, e.g. $TTMODELS.
  303. // Here we build the root makefile.
  304. #map subdirs
  305. // Iterate through all of our known source files. Each models type
  306. // file gets its corresponding Makefile listed here.
  307. #forscopes */
  308. #if $[eq $[DIR_TYPE], models]
  309. #if $[build_directory]
  310. #addmap subdirs $[DIRNAME]
  311. #endif
  312. #endif
  313. #end */
  314. #output Makefile
  315. #format makefile
  316. #### Generated automatically by $[PPREMAKE] $[PPREMAKE_VERSION] from $[SOURCEFILE].
  317. ################################# DO NOT EDIT ###########################
  318. all : egg pal repal $[subdirs]
  319. egg : $[subdirs:%=egg-%]
  320. pal : $[subdirs:%=pal-%]
  321. bam : $[subdirs:%=bam-%]
  322. clean-bam : $[subdirs:%=clean-bam-%]
  323. clean-pal : $[subdirs:%=clean-pal-%]
  324. clean : $[subdirs:%=clean-%]
  325. cleanall : $[subdirs:%=cleanall-%]
  326. install-egg : egg pal repal $[subdirs:%=install-egg-%]
  327. install-bam : egg pal repal $[subdirs:%=install-bam-%]
  328. install-other : $[subdirs:%=install-other-%]
  329. install : egg pal repal $[subdirs:%=install-%]
  330. uninstall-egg : $[subdirs:%=uninstall-egg-%]
  331. uninstall-bam : $[subdirs:%=uninstall-bam-%]
  332. uninstall-other : $[subdirs:%=uninstall-other-%]
  333. uninstall : $[subdirs:%=uninstall-%]
  334. #
  335. # opt-pal : reorder and resize the palettes to be as optimal as
  336. # possible. This forces a rebuild of all the egg files.
  337. #
  338. opt-pal : pal do-opt-pal install
  339. optimize-palettes : opt-pal
  340. do-opt-pal :
  341. egg-palettize $[PALETTIZE_OPTS] -a $[texattrib_file] -opt -egg
  342. #
  343. # repal : reexamine the textures.txa file and do whatever needs to be
  344. # done to bring everything up to sync with it. Also make sure all egg
  345. # files are up-to-date.
  346. #
  347. repal :
  348. egg-palettize $[PALETTIZE_OPTS] -a $[texattrib_file] -all -egg
  349. re-pal : repal
  350. #
  351. # fix-pal : something has gone wrong with the palettes; rebuild all
  352. # palette images to fix it.
  353. #
  354. fix-pal :
  355. egg-palettize $[PALETTIZE_OPTS] -a $[texattrib_file] -redo -all -egg
  356. #
  357. # pi : report the palettization information to standard output for the
  358. # user's perusal.
  359. #
  360. pi :
  361. egg-palettize $[PALETTIZE_OPTS] -a $[texattrib_file] -pi
  362. #
  363. # pal-stats : report palettization statistics to standard output for the
  364. # user's perusal.
  365. #
  366. pal-stats :
  367. egg-palettize $[PALETTIZE_OPTS] -a $[texattrib_file] -s
  368. stats-pal : pal-stats
  369. // Somehow, something in the cttools confuses some shells, so that
  370. // when we are attached, 'cd foo' doesn't work, but 'cd ./foo' does.
  371. // Weird. We get around this by putting a ./ in front of each cd
  372. // target below.
  373. #formap dirname subdirs
  374. $[dirname] : $[dirnames $[if $[build_directory],$[DIRNAME]],$[DEPEND_DIRS]]
  375. cd ./$[PATH] && $(MAKE) all
  376. #end dirname
  377. #formap dirname subdirs
  378. egg-$[dirname] :
  379. cd ./$[PATH] && $(MAKE) egg
  380. #end dirname
  381. #formap dirname subdirs
  382. bam-$[dirname] :
  383. cd ./$[PATH] && $(MAKE) bam
  384. #end dirname
  385. #formap dirname subdirs
  386. pal-$[dirname] :
  387. cd ./$[PATH] && $(MAKE) pal
  388. #end dirname
  389. #formap dirname subdirs
  390. clean-bam-$[dirname] :
  391. cd ./$[PATH] && $(MAKE) clean-bam
  392. #end dirname
  393. #formap dirname subdirs
  394. clean-pal-$[dirname] :
  395. cd ./$[PATH] && $(MAKE) clean-pal
  396. #end dirname
  397. #formap dirname subdirs
  398. clean-$[dirname] :
  399. cd ./$[PATH] && $(MAKE) clean
  400. #end dirname
  401. #formap dirname subdirs
  402. cleanall-$[dirname] :
  403. cd ./$[PATH] && $(MAKE) cleanall
  404. #end dirname
  405. #formap dirname subdirs
  406. install-egg-$[dirname] :
  407. cd ./$[PATH] && $(MAKE) install-egg
  408. #end dirname
  409. #formap dirname subdirs
  410. install-bam-$[dirname] :
  411. cd ./$[PATH] && $(MAKE) install-bam
  412. #end dirname
  413. #formap dirname subdirs
  414. install-other-$[dirname] :
  415. cd ./$[PATH] && $(MAKE) install-other
  416. #end dirname
  417. #formap dirname subdirs
  418. install-$[dirname] :
  419. cd ./$[PATH] && $(MAKE) install
  420. #end dirname
  421. #formap dirname subdirs
  422. uninstall-egg-$[dirname] :
  423. cd ./$[PATH] && $(MAKE) uninstall-egg
  424. #end dirname
  425. #formap dirname subdirs
  426. uninstall-bam-$[dirname] :
  427. cd ./$[PATH] && $(MAKE) uninstall-bam
  428. #end dirname
  429. #formap dirname subdirs
  430. uninstall-other-$[dirname] :
  431. cd ./$[PATH] && $(MAKE) uninstall-other
  432. #end dirname
  433. #formap dirname subdirs
  434. uninstall-$[dirname] :
  435. cd ./$[PATH] && $(MAKE) uninstall
  436. #end dirname
  437. #end Makefile
  438. //////////////////////////////////////////////////////////////////////
  439. #endif // DIR_TYPE