Template.models.pp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  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. // Search for the texattrib dir definition. This will be in the
  17. // models_topdir directory.
  18. #define texattrib_dir $[dir_type $[TEXATTRIB_DIR],models_toplevel]
  19. // Prefix $[TOPDIR]. If it wasn't defined, make a default.
  20. #if $[texattrib_dir]
  21. #define texattrib_dir $[TOPDIR]/$[texattrib_dir]
  22. #else
  23. #define texattrib_dir $[TOPDIR]/src/maps
  24. #endif
  25. #define texattrib_file $[texattrib_dir]/textures.txa
  26. //////////////////////////////////////////////////////////////////////
  27. #if $[eq $[DIR_TYPE], models]
  28. //////////////////////////////////////////////////////////////////////
  29. #define pal_egg_dir pal_egg
  30. #define bam_dir bams
  31. #defer phase_prefix $[if $[PHASE],phase_$[PHASE]/]
  32. #defer install_model_dir $[install_dir]/$[phase_prefix]$[INSTALL_TO]
  33. #define filter_dirs $[sort $[TARGET_DIR(filter_egg filter_char_egg optchar_egg)]]
  34. #defer source_prefix $[SOURCE_DIR:%=%/]
  35. #if $[LANGUAGES]
  36. #define exlanguage_sources $[notdir $[filter %.flt %.mb %.ma %.lwo %.LWO %.egg,$[wildcard $[TOPDIR]/$[DIRPREFIX]*_$[LANGUAGE].*]]]
  37. #defun lang_add_files sources, src_ext, local_extra
  38. #define default_filter
  39. #define local_filter
  40. #foreach ext $[src_ext]
  41. #set default_filter $[default_filter] %_$[DEFAULT_LANGUAGE].$[ext]
  42. #set local_filter $[local_filter] %_$[LANGUAGE].$[ext]
  43. #end ext
  44. #define default_langlist $[filter $[default_filter],$[sources]]
  45. #define locallist $[filter $[local_filter],$[local_extra] $[exlanguage_sources]]
  46. #define havelist
  47. #foreach file $[default_langlist]
  48. #foreach ext $[src_ext]
  49. #define wantfile $[file:%_$[DEFAULT_LANGUAGE].$[ext]=%_$[LANGUAGE].$[ext]]
  50. #set havelist $[havelist] $[filter $[wantfile],$[locallist]]
  51. #end ext
  52. #end file
  53. $[havelist]
  54. #end lang_add_files
  55. #forscopes flt_egg
  56. #if $[SOURCES]
  57. #set SOURCES $[sort $[SOURCES] $[lang_add_files $[SOURCES], flt, ]]
  58. #endif
  59. #end flt_egg
  60. #forscopes lwo_egg
  61. #if $[SOURCES]
  62. #set SOURCES $[sort $[SOURCES] $[lang_add_files $[SOURCES], lwo LWO, ]]
  63. #endif
  64. #end lwo_egg
  65. #forscopes maya_egg
  66. #if $[SOURCES]
  67. #set SOURCES $[sort $[SOURCES] $[lang_add_files $[SOURCES], lwo LWO, ]]
  68. #endif
  69. #end maya_egg
  70. #endif
  71. #define build_flt_eggs \
  72. $[forscopes flt_egg,$[patsubst %.flt,%$[EGG_SUFFIX].egg,$[SOURCES]]]
  73. #define build_lwo_eggs \
  74. $[forscopes lwo_egg,$[patsubst %.lwo %.LWO,%$[EGG_SUFFIX].egg,$[SOURCES]]]
  75. #define build_maya_eggs \
  76. $[forscopes maya_egg,$[patsubst %$[MODEL].ma %$[MODEL].mb ,$[EGG_PREFIX]%$[EGG_SUFFIX].egg,$[SOURCES]]] \
  77. $[forscopes maya_char_egg,$[POLY_MODEL:%=$[EGG_PREFIX]%$[EGG_SUFFIX].egg] $[NURBS_MODEL:%=$[EGG_PREFIX]%$[EGG_SUFFIX].egg]] \
  78. $[forscopes maya_char_egg,$[ANIMS:%=$[EGG_PREFIX]%$[CHAN_SUFFIX].egg]]
  79. #define build_soft_eggs \
  80. $[forscopes soft_char_egg,$[POLY_MODEL:%=$[EGG_PREFIX]%$[EGG_SUFFIX].egg] $[NURBS_MODEL:%=$[EGG_PREFIX]%$[EGG_SUFFIX].egg]] \
  81. $[forscopes soft_char_egg,$[ANIMS:%=$[EGG_PREFIX]%$[CHAN_SUFFIX].egg]]
  82. #define build_eggs \
  83. $[sort \
  84. $[build_flt_eggs] \
  85. $[build_lwo_eggs] \
  86. $[build_maya_eggs] \
  87. $[build_soft_eggs]]
  88. #if $[LANGUAGES]
  89. #forscopes install_egg filter_egg
  90. #if $[SOURCES]
  91. #set SOURCES $[sort $[SOURCES] $[lang_add_files $[SOURCES], egg, $[build_eggs]]]
  92. #endif
  93. #end install_egg filter_egg
  94. #endif
  95. // Get the list of egg files that are to be installed
  96. #define install_pal_eggs
  97. #define install_unpal_eggs
  98. #forscopes install_egg
  99. #define egglist $[notdir $[SOURCES]]
  100. #set install_pal_eggs $[install_pal_eggs] $[filter-out $[language_egg_filters],$[egglist]]
  101. #if $[LANGUAGES]
  102. // Now look for the eggs of the current language.
  103. #foreach egg $[filter %_$[DEFAULT_LANGUAGE].egg,$[egglist]]
  104. #define wantegg $[egg:%_$[DEFAULT_LANGUAGE].egg=%_$[LANGUAGE].egg]
  105. #if $[filter $[wantegg],$[egglist]]
  106. // The current language file exists.
  107. #set install_pal_eggs $[install_pal_eggs] $[wantegg]
  108. #else
  109. #set install_pal_eggs $[install_pal_eggs] $[egg]
  110. #endif
  111. #end egg
  112. #endif
  113. #define egglist $[notdir $[UNPAL_SOURCES] $[UNPAL_SOURCES_NC]]
  114. #set install_unpal_eggs $[install_unpal_eggs] $[filter-out $[language_egg_filters],$[egglist]]
  115. #if $[LANGUAGES]
  116. // Now look for the eggs of the current language.
  117. #foreach egg $[filter %_$[DEFAULT_LANGUAGE].egg,$[egglist]]
  118. #define wantegg $[egg:%_$[DEFAULT_LANGUAGE].egg=%_$[LANGUAGE].egg]
  119. #if $[filter $[wantegg],$[egglist]]
  120. // The current language file exists.
  121. #set install_unpal_eggs $[install_unpal_eggs] $[wantegg]
  122. #else
  123. #set install_unpal_eggs $[install_unpal_eggs] $[egg]
  124. #endif
  125. #end egg
  126. #endif
  127. #end install_egg
  128. #define install_eggs $[install_pal_eggs] $[install_unpal_eggs]
  129. // Get the list of bam files in the install directories
  130. #define install_egg_dirs $[sort $[forscopes install_egg,$[install_model_dir]]]
  131. #define installed_generic_bams $[sort $[forscopes install_egg,$[patsubst %.egg,$[install_model_dir]/%.bam,$[filter-out $[language_egg_filters],$[notdir $[SOURCES] $[UNPAL_SOURCES] $[UNPAL_SOURCES_NC]]]]]]
  132. #if $[LANGUAGES]
  133. #define installed_language_bams $[sort $[forscopes install_egg,$[patsubst %.egg,$[install_model_dir]/%.bam,$[patsubst %_$[DEFAULT_LANGUAGE].egg,%.egg,%,,$[notdir $[SOURCES] $[UNPAL_SOURCES] $[UNPAL_SOURCES_NC]]]]]]
  134. #endif
  135. // And the list of dna files in the install directories.
  136. #define install_dna_dirs $[sort $[forscopes install_dna,$[install_model_dir]]]
  137. #define installed_generic_dna $[sort $[forscopes install_dna,$[patsubst %,$[install_model_dir]/%,$[filter-out $[language_dna_filters],$[notdir $[SOURCES]]]]]]
  138. #if $[LANGUAGES]
  139. #define installed_language_dna $[sort $[forscopes install_dna,$[patsubst %,$[install_model_dir]/%,$[patsubst %_$[DEFAULT_LANGUAGE].dna,%.dna,%,,$[notdir $[SOURCES]]]]]]
  140. #endif
  141. #define install_other_dirs $[sort $[forscopes install_audio install_icons install_shader install_misc,$[install_model_dir]]]
  142. #define installed_other $[sort $[forscopes install_audio install_icons install_shader install_misc,$[SOURCES:%=$[install_model_dir]/%]]]
  143. #define pal_egg_targets $[sort $[patsubst %,$[pal_egg_dir]/%,$[notdir $[install_pal_eggs]]]]
  144. #define bam_targets $[install_eggs:%.egg=$[bam_dir]/%.bam]
  145. #output Makefile
  146. #format makefile
  147. #### Generated automatically by $[PPREMAKE] $[PPREMAKE_VERSION] from $[SOURCEFILE].
  148. ################################# DO NOT EDIT ###########################
  149. #define all_targets \
  150. Makefile \
  151. $[texattrib_dir] \
  152. $[filter_dirs] \
  153. $[optchar_dirs] \
  154. egg bam
  155. all : $[all_targets]
  156. egg : $[build_eggs]
  157. flt : $[build_flt_eggs]
  158. lwo : $[build_lwo_eggs]
  159. maya : $[build_maya_eggs]
  160. soft : $[build_soft_eggs]
  161. pal : $[if $[pal_egg_targets],$[pal_egg_dir]] $[pal_egg_targets]
  162. bam : pal $[if $[bam_targets],$[bam_dir]] $[bam_targets]
  163. #map soft_scenes soft_scene_files(soft_char_egg)
  164. unpack-soft : $[soft_scenes]
  165. #define install_bam_targets \
  166. $[install_egg_dirs] \
  167. $[installed_generic_bams] $[installed_language_bams]
  168. install-bam : $[install_bam_targets]
  169. #define install_other_targets \
  170. $[install_dna_dirs] \
  171. $[installed_generic_dna] $[installed_language_dna] \
  172. $[install_other_dirs] \
  173. $[installed_other]
  174. install-other : $[install_other_targets]
  175. install : all install-other install-bam
  176. uninstall : uninstall-other uninstall-bam
  177. clean-bam :
  178. #if $[bam_targets]
  179. $[TAB]rm -rf $[bam_dir]
  180. #endif
  181. clean-pal : clean-bam
  182. #if $[pal_egg_targets]
  183. $[TAB]rm -rf $[pal_egg_dir]
  184. #endif
  185. clean-flt :
  186. #if $[build_flt_eggs]
  187. $[TAB]rm -f $[build_flt_eggs]
  188. #endif
  189. clean-lwo :
  190. #if $[build_lwo_eggs]
  191. $[TAB]rm -f $[build_lwo_eggs]
  192. #endif
  193. clean-maya :
  194. #if $[build_maya_eggs]
  195. $[TAB]rm -f $[build_maya_eggs]
  196. #endif
  197. clean-soft :
  198. #if $[build_soft_eggs]
  199. $[TAB]rm -f $[build_soft_eggs]
  200. #endif
  201. clean : clean-pal
  202. #if $[build_eggs]
  203. $[TAB]rm -f $[build_eggs] *.pt
  204. #endif
  205. #if $[filter_dirs]
  206. $[TAB]rm -rf $[filter_dirs]
  207. #endif
  208. // We need a rule for each directory we might need to make. This
  209. // loops through the full set of directories and creates a rule to
  210. // make each one, as needed.
  211. #foreach directory $[sort \
  212. $[filter_dirs] \
  213. $[if $[pal_egg_targets],$[pal_egg_dir]] \
  214. $[if $[bam_targets],$[bam_dir]] \
  215. $[TARGET_DIR(filter_char_egg)] \
  216. $[texattrib_dir] \
  217. $[install_egg_dirs] \
  218. $[install_dna_dirs] \
  219. $[install_other_dirs] \
  220. ]
  221. $[directory] :
  222. $[TAB]@test -d $[directory] || echo mkdir -p $[directory]
  223. $[TAB]@test -d $[directory] || mkdir -p $[directory]
  224. // Sometimes we need a target to depend on the directory existing, without
  225. // being fooled by the directory's modification times. We use this
  226. // phony timestamp file to achieve that.
  227. $[directory]/stamp :
  228. $[TAB]@test -d $[directory] || echo mkdir -p $[directory]
  229. $[TAB]@test -d $[directory] || mkdir -p $[directory]
  230. $[TAB]@touch $[directory]/stamp
  231. #end directory
  232. // Decompressing compressed files.
  233. #forscopes gz
  234. #foreach gz $[SOURCES]
  235. #define target $[gz:%.gz=%]
  236. #define source $[gz]
  237. $[target] : $[source]
  238. $[TAB]rm -f $[target]
  239. $[TAB]gunzip $[GUNZIP_OPTS] < $[source] > $[target]
  240. #end gz
  241. #end gz
  242. // Egg file generation from Flt files.
  243. #forscopes flt_egg
  244. #foreach flt $[SOURCES]
  245. #define target $[or $[TARGET],$[patsubst %.flt %.FLT,$[EGG_PREFIX]%$[EGG_SUFFIX].egg,$[flt]]]
  246. #define source $[flt]
  247. $[target] : $[source]
  248. $[TAB]flt2egg $[FLT2EGG_OPTS] -o $[target] $[source]
  249. #end flt
  250. #end flt_egg
  251. // Egg file generation from Lightwave files.
  252. #forscopes lwo_egg
  253. #foreach lwo $[SOURCES]
  254. #define target $[or $[TARGET],$[patsubst %.lwo %.LWO,$[EGG_PREFIX]%$[EGG_SUFFIX].egg,$[lwo]]]
  255. #define source $[lwo]
  256. $[target] : $[source]
  257. $[TAB]lwo2egg $[LWO2EGG_OPTS] -o $[target] $[source]
  258. #end lwo
  259. #end lwo_egg
  260. // Egg file generation from Maya files (for unanimated models).
  261. #forscopes maya_egg
  262. #foreach maya $[SOURCES]
  263. #define target $[or $[TARGET],$[patsubst %$[MODEL].ma %$[MODEL].mb,$[EGG_PREFIX]%$[EGG_SUFFIX].egg,$[maya]]]
  264. #define source $[maya]
  265. $[target] : $[source]
  266. $[TAB]maya2egg $[MAYA2EGG_OPTS] -o $[target] $[source]
  267. #end maya
  268. #end maya_egg
  269. // Egg character model generation from Maya files.
  270. #forscopes maya_char_egg
  271. #if $[POLY_MODEL]
  272. #define target $[EGG_PREFIX]$[POLY_MODEL].egg
  273. #define source $[MAYA_PREFIX]$[or $[MODEL],$[POLY_MODEL]]$[MAYA_EXTENSION]
  274. $[target] : $[source]
  275. $[TAB]maya2egg $[MAYA2EGG_OPTS] -p -a model -cn "$[CHAR_NAME]" -o $[target] $[source]
  276. #endif
  277. #if $[NURBS_MODEL]
  278. #define target $[EGG_PREFIX]$[NURBS_MODEL].egg
  279. #define source $[MAYA_PREFIX]$[or $[MODEL],$[NURBS_MODEL]]$[MAYA_EXTENSION]
  280. $[target] : $[source]
  281. $[TAB]maya2egg $[MAYA2EGG_OPTS] -a model -cn "$[CHAR_NAME]" -o $[target] $[source]
  282. #endif
  283. #end maya_char_egg
  284. // Egg animation generation from Maya files.
  285. #forscopes maya_char_egg
  286. #foreach anim $[ANIMS]
  287. #define target $[EGG_PREFIX]$[anim]$[CHAN_SUFFIX].egg
  288. #define source $[MAYA_PREFIX]$[anim]$[MAYA_EXTENSION]
  289. #define begin 0
  290. #define end
  291. #if $[$[anim]_frames]
  292. #set begin $[word 1,$[$[anim]_frames]]
  293. #set end $[word 2,$[$[anim]_frames]]
  294. #endif
  295. $[target] : $[source]
  296. $[TAB]maya2egg $[MAYA2EGG_OPTS] -a chan -cn "$[CHAR_NAME]" -o $[target] -sf $[begin] $[if $[end],-ef $[end]] $[source]
  297. #end anim
  298. #end maya_char_egg
  299. // Unpack the Soft scene database from its multifile.
  300. #formap scene_file soft_scenes
  301. #define target $[scene_file]
  302. #define source $[scene_file:$[DATABASE]/SCENES/%.1-0.dsc=$[DATABASE]/%.mf]
  303. $[target] : $[source]
  304. $[TAB]multify xf $[source] -C $[DATABASE]
  305. #end scene_file
  306. // Egg character model generation from Soft databases.
  307. #forscopes soft_char_egg
  308. #if $[POLY_MODEL]
  309. #define target $[EGG_PREFIX]$[POLY_MODEL].egg
  310. #define scene $[SCENE_PREFIX]$[MODEL].1-0.dsc
  311. #define source $[DATABASE]/SCENES/$[scene]
  312. $[target] : $[source]
  313. $[TAB]$[SOFT2EGG] $[SOFT2EGG_OPTS] $[if $[SOFTIMAGE_RSRC],-r "$[osfilename $[SOFTIMAGE_RSRC]]"] -p -M $[target] -N $[CHAR_NAME] -d $[DATABASE] -t $[DATABASE]/PICTURES -s $[scene]
  314. #endif
  315. #if $[NURBS_MODEL]
  316. #define target $[EGG_PREFIX]$[NURBS_MODEL].egg
  317. #define scene $[SCENE_PREFIX]$[MODEL].1-0.dsc
  318. #define source $[DATABASE]/SCENES/$[scene]
  319. $[target] : $[source]
  320. $[TAB]$[SOFT2EGG] $[SOFT2EGG_OPTS] $[if $[SOFTIMAGE_RSRC],-r "$[osfilename $[SOFTIMAGE_RSRC]]"] -n -M $[target] -N $[CHAR_NAME] -d $[DATABASE] -t $[DATABASE]/PICTURES -s $[scene]
  321. #endif
  322. #end soft_char_egg
  323. // Egg animation generation from Soft database.
  324. #forscopes soft_char_egg
  325. #foreach anim $[ANIMS]
  326. #define target $[EGG_PREFIX]$[anim]$[CHAN_SUFFIX].egg
  327. #define scene $[SCENE_PREFIX]$[anim].1-0.dsc
  328. #define source $[DATABASE]/SCENES/$[scene]
  329. #define begin 1
  330. #define end
  331. #if $[$[anim]_frames]
  332. #set begin $[word 1,$[$[anim]_frames]]
  333. #set end $[word 2,$[$[anim]_frames]]
  334. #endif
  335. $[target] : $[source]
  336. $[TAB]$[SOFT2EGG] $[SOFT2EGG_OPTS] $[if $[SOFTIMAGE_RSRC],-r "$[osfilename $[SOFTIMAGE_RSRC]]"] -a -A $[target] -N $[CHAR_NAME] -d $[DATABASE] -s $[scene] $[begin:%=-b%] $[end:%=-e%]
  337. #end anim
  338. #end soft_char_egg
  339. // Copying egg files from A to B.
  340. #forscopes copy_egg
  341. #for i 1,$[words $[SOURCES]]
  342. #define source $[word $[i],$[SOURCES]]
  343. #define target $[word $[i],$[TARGETS]]
  344. $[target] : $[source]
  345. $[TAB]cp $[source] $[target]
  346. #end i
  347. #end copy_egg
  348. // Generic egg filters.
  349. #forscopes filter_egg
  350. #foreach egg $[SOURCES]
  351. #define source $[source_prefix]$[egg]
  352. #define target $[TARGET_DIR]/$[notdir $[egg]]
  353. $[target] : $[source] $[pt] $[TARGET_DIR]/stamp
  354. $[TAB]$[COMMAND]
  355. #end egg
  356. #end filter_egg
  357. // Generic character egg filter; applies an effect to all models and
  358. // animations of a particular character.
  359. #forscopes filter_char_egg
  360. #define sources $[SOURCES:%=$[source_prefix]%]
  361. #define target $[TARGET_DIR]/$[notdir $[firstword $[SOURCES]]]
  362. // A bunch of rules to make each generated egg file depend on the
  363. // first one.
  364. #foreach egg $[notdir $[wordlist 2,9999,$[SOURCES]]]
  365. $[TARGET_DIR]/$[egg] : $[target] $[TARGET_DIR]/stamp
  366. $[TAB]touch $[TARGET_DIR]/$[egg]
  367. #end egg
  368. // And this is the actual optchar pass.
  369. $[target] : $[sources] $[TARGET_DIR]/stamp
  370. $[TAB]$[COMMAND]
  371. #end filter_char_egg
  372. // Character optimization.
  373. #forscopes optchar_egg
  374. #define sources $[SOURCES:%=$[source_prefix]%]
  375. #define target $[TARGET_DIR]/$[notdir $[firstword $[SOURCES]]]
  376. // A bunch of rules to make each generated egg file depend on the
  377. // first one.
  378. #foreach egg $[notdir $[wordlist 2,9999,$[SOURCES]]]
  379. $[TARGET_DIR]/$[egg] : $[target] $[TARGET_DIR]/stamp
  380. $[TAB]touch $[TARGET_DIR]/$[egg]
  381. #end egg
  382. // And this is the actual optchar pass.
  383. $[target] : $[sources] $[TARGET_DIR]/stamp
  384. $[TAB]egg-optchar $[OPTCHAR_OPTS] -d $[TARGET_DIR] $[sources]
  385. #end optchar_egg
  386. // Palettization rules.
  387. #forscopes install_egg
  388. #foreach egg $[SOURCES]
  389. #define pt $[egg:%.egg=$[source_prefix]%.pt]
  390. #define source $[source_prefix]$[egg]
  391. #define target $[pal_egg_dir]/$[notdir $[egg]]
  392. $[target] : $[source] $[pt] $[pal_egg_dir]/stamp
  393. #if $[PHASE]
  394. $[TAB]egg-palettize $[PALETTIZE_OPTS] -af $[texattrib_file] -dr $[install_dir] -dm $[install_dir]/%g/maps -ds $[install_dir]/shadow_pal -g phase_$[PHASE] -gdir phase_$[PHASE] -o $[target] $[source]
  395. #else
  396. $[TAB]egg-palettize $[PALETTIZE_OPTS] -af $[texattrib_file] -dr $[install_dir] -dm $[install_dir]/%g/maps -ds $[install_dir]/shadow_pal -o $[target] $[source]
  397. #endif
  398. $[pt] :
  399. $[TAB]touch $[pt]
  400. #end egg
  401. #end install_egg
  402. // Bam file creation.
  403. #forscopes install_egg
  404. #foreach egg $[SOURCES]
  405. #define source $[pal_egg_dir]/$[notdir $[egg]]
  406. #define target $[bam_dir]/$[notdir $[egg:%.egg=%.bam]]
  407. $[target] : $[source] $[bam_dir]/stamp
  408. $[TAB]egg2bam -pp $[install_dir] -ps rel -pd $[install_dir] $[EGG2BAM_OPTS] -o $[target] $[source]
  409. #end egg
  410. #foreach egg $[UNPAL_SOURCES]
  411. #define source $[source_prefix]$[egg]
  412. #define target $[bam_dir]/$[notdir $[egg:%.egg=%.bam]]
  413. $[target] : $[source] $[bam_dir]/stamp
  414. $[TAB]egg2bam $[EGG2BAM_OPTS] -o $[target] $[source]
  415. #end egg
  416. #foreach egg $[UNPAL_SOURCES_NC]
  417. #define source $[source_prefix]$[egg]
  418. #define target $[bam_dir]/$[notdir $[egg:%.egg=%.bam]]
  419. $[target] : $[source] $[bam_dir]/stamp
  420. $[TAB]egg2bam $[EGG2BAM_OPTS] -NC -o $[target] $[source]
  421. #end egg
  422. #end install_egg
  423. // Bam file installation.
  424. #forscopes install_egg
  425. #define egglist $[notdir $[SOURCES] $[UNPAL_SOURCES] $[UNPAL_SOURCES_NC]]
  426. #foreach egg $[filter-out $[language_egg_filters],$[egglist]]
  427. #define local $[egg:%.egg=%.bam]
  428. #define sourcedir $[bam_dir]
  429. #define dest $[install_model_dir]
  430. $[dest]/$[local] : $[sourcedir]/$[local]
  431. // cd ./$[sourcedir] && $[INSTALL]
  432. $[TAB]rm -f $[dest]/$[local]
  433. $[TAB]cp $[sourcedir]/$[local] $[dest]
  434. #end egg
  435. #if $[LANGUAGES]
  436. // Now look for the eggs of the current language.
  437. #foreach egg $[filter %_$[DEFAULT_LANGUAGE].egg,$[egglist]]
  438. #define wantegg $[egg:%_$[DEFAULT_LANGUAGE].egg=%_$[LANGUAGE].egg]
  439. #if $[filter $[wantegg],$[egglist]]
  440. // The current language file exists.
  441. #define local $[wantegg:%.egg=%.bam]
  442. #else
  443. //#print Warning: $[wantegg] not listed, using $[egg]
  444. #define local $[egg:%.egg=%.bam]
  445. #endif
  446. #define remote $[egg:%_$[DEFAULT_LANGUAGE].egg=%.bam]
  447. #define sourcedir $[bam_dir]
  448. #define dest $[install_model_dir]
  449. $[dest]/$[remote] : $[sourcedir]/$[local]
  450. // cd ./$[sourcedir] && $[INSTALL]
  451. $[TAB]rm -f $[dest]/$[remote]
  452. $[TAB]cp $[sourcedir]/$[local] $[dest]/$[remote]
  453. #end egg
  454. #endif
  455. #end install_egg
  456. // Bam file uninstallation.
  457. uninstall-bam :
  458. #forscopes install_egg
  459. #define egglist $[notdir $[SOURCES] $[UNPAL_SOURCES] $[UNPAL_SOURCES_NC]]
  460. #define generic_egglist $[filter-out $[language_egg_filters],$[egglist]]
  461. #if $[LANGUAGES]
  462. #define language_egglist $[patsubst %_$[DEFAULT_LANGUAGE].egg,%.egg,%,,$[egglist]]
  463. #endif
  464. #define files $[patsubst %.egg,$[install_model_dir]/%.bam,$[generic_egglist] $[language_egglist]]
  465. #if $[files]
  466. $[TAB]rm -f $[files]
  467. #endif
  468. #end install_egg
  469. // DNA file installation.
  470. #forscopes install_dna
  471. #foreach file $[filter-out $[language_dna_filters],$[SOURCES]]
  472. #define local $[file]
  473. #define remote $[notdir $[file]]
  474. #define dest $[install_model_dir]
  475. $[dest]/$[remote] : $[local]
  476. // $[INSTALL]
  477. $[TAB]rm -f $[dest]/$[remote]
  478. $[TAB]cp $[local] $[dest]
  479. #end file
  480. #if $[LANGUAGES]
  481. // Now files of the current langauge.
  482. #foreach file $[filter %_$[DEFAULT_LANGUAGE].dna,$[SOURCES]]
  483. #define wantfile $[file:%_$[DEFAULT_LANGUAGE].dna=%_$[LANGUAGE].dna]
  484. #if $[filter $[wantfile],$[SOURCES]]
  485. // The current language file exists.
  486. #define local $[wantfile]
  487. #else
  488. //#print Warning: $[wantfile] not listed, using $[file]
  489. #define local $[file]
  490. #endif
  491. #define remote $[notdir $[file:%_$[DEFAULT_LANGUAGE].dna=%.dna]]
  492. #define dest $[install_model_dir]
  493. $[dest]/$[remote] : $[local]
  494. // cd ./$[sourcedir] && $[INSTALL]
  495. $[TAB]rm -f $[dest]/$[remote]
  496. $[TAB]cp $[local] $[dest]/$[remote]
  497. #end file
  498. #endif
  499. #end install_dna
  500. // DNA file uninstallation.
  501. uninstall-other:
  502. #forscopes install_dna
  503. #define sources $[notdir $[SOURCES]]
  504. #define generic_sources $[filter-out $[language_dna_filters],$[sources]]
  505. #if $[LANGUAGES]
  506. #define language_sources $[patsubst %_$[DEFAULT_LANGUAGE].dna,%.dna,%,,$[sources]]
  507. #endif
  508. #define files $[patsubst %,$[install_model_dir]/%,$[generic_sources] $[language_sources]]
  509. #if $[files]
  510. $[TAB]rm -f $[files]
  511. #endif
  512. #end install_dna
  513. // Miscellaneous file installation.
  514. #forscopes install_audio install_icons install_shader install_misc
  515. #foreach file $[SOURCES]
  516. #define local $[file]
  517. #define remote $[notdir $[file]]
  518. #define dest $[install_model_dir]
  519. $[dest]/$[remote] : $[local]
  520. // $[INSTALL]
  521. $[TAB]rm -f $[dest]/$[remote]
  522. $[TAB]cp $[local] $[dest]
  523. #end file
  524. #end install_audio install_icons install_shader install_misc
  525. // Miscellaneous file uninstallation.
  526. uninstall-other:
  527. #forscopes install_audio install_icons install_shader install_misc
  528. #define files $[patsubst %,$[install_model_dir]/%,$[SOURCES]]
  529. #if $[files]
  530. $[TAB]rm -f $[files]
  531. #endif
  532. #end install_audio install_icons install_shader install_misc
  533. #end Makefile
  534. //////////////////////////////////////////////////////////////////////
  535. #elif $[eq $[DIR_TYPE], models_group]
  536. //////////////////////////////////////////////////////////////////////
  537. // This is a group directory: a directory above a collection of source
  538. // directories, e.g. $DTOOL/src. We don't need to output anything in
  539. // this directory.
  540. //////////////////////////////////////////////////////////////////////
  541. #elif $[eq $[DIR_TYPE], models_toplevel]
  542. //////////////////////////////////////////////////////////////////////
  543. // This is the toplevel directory for a models tree, e.g. $TTMODELS.
  544. // Here we build the root makefile.
  545. #map subdirs
  546. // Iterate through all of our known source files. Each models type
  547. // file gets its corresponding Makefile listed here.
  548. #forscopes */
  549. #if $[eq $[DIR_TYPE], models]
  550. #if $[build_directory]
  551. #addmap subdirs $[DIRNAME]
  552. #endif
  553. #endif
  554. #end */
  555. #output Makefile
  556. #format makefile
  557. #### Generated automatically by $[PPREMAKE] $[PPREMAKE_VERSION] from $[SOURCEFILE].
  558. ################################# DO NOT EDIT ###########################
  559. all : egg pal repal $[subdirs]
  560. install : all $[subdirs:%=install-%]
  561. #define sub_targets egg flt lwo maya soft bam pal clean-bam clean-pal clean-flt clean-lwo clean-maya clean-soft clean cleanall unpack-soft install-bam install-other uninstall-bam uninstall-other uninstall
  562. // Define the rules to propogate these targets to the Makefile within
  563. // each directory.
  564. #foreach target $[sub_targets]
  565. $[target] : $[subdirs:%=$[target]-%]
  566. #end target
  567. #
  568. # opt-pal : reorder and resize the palettes to be as optimal as
  569. # possible. This forces a rebuild of all the egg files.
  570. #
  571. opt-pal : pal do-opt-pal install
  572. optimize-palettes : opt-pal
  573. do-opt-pal :
  574. $[TAB]egg-palettize $[PALETTIZE_OPTS] -af $[texattrib_file] -dm $[install_dir]/%g/maps -opt -egg
  575. #
  576. # repal : reexamine the textures.txa file and do whatever needs to be
  577. # done to bring everything up to sync with it. Also make sure all egg
  578. # files are up-to-date.
  579. #
  580. repal :
  581. $[TAB]egg-palettize $[PALETTIZE_OPTS] -af $[texattrib_file] -dm $[install_dir]/%g/maps -all -egg
  582. re-pal : repal
  583. #
  584. # fix-pal : something has gone wrong with the palettes; rebuild all
  585. # palette images to fix it.
  586. #
  587. fix-pal :
  588. $[TAB]egg-palettize $[PALETTIZE_OPTS] -af $[texattrib_file] -dm $[install_dir]/%g/maps -redo -all -egg
  589. #
  590. # undo-pal : blow away all the palettization information and start fresh.
  591. #
  592. undo-pal : clean-pal
  593. $[TAB]rm -f $[texattrib_file:%.txa=%.boo]
  594. #
  595. # pi : report the palettization information to standard output for the
  596. # user's perusal.
  597. #
  598. pi :
  599. $[TAB]egg-palettize $[PALETTIZE_OPTS] -af $[texattrib_file] -dm $[install_dir]/%g/maps -pi
  600. .PHONY: pi.txt
  601. pi.txt :
  602. $[TAB]egg-palettize $[PALETTIZE_OPTS] -af $[texattrib_file] -dm $[install_dir]/%g/maps -pi >pi.txt
  603. #
  604. # pal-stats : report palettization statistics to standard output for the
  605. # user's perusal.
  606. #
  607. pal-stats :
  608. $[TAB]egg-palettize $[PALETTIZE_OPTS] -af $[texattrib_file] -dm $[install_dir]/%g/maps -s
  609. stats-pal : pal-stats
  610. // Somehow, something in the cttools confuses some shells, so that
  611. // when we are attached, 'cd foo' doesn't work, but 'cd ./foo' does.
  612. // Weird. We get around this by putting a ./ in front of each cd
  613. // target below.
  614. #formap dirname subdirs
  615. $[dirname] : $[dirnames $[if $[build_directory],$[DIRNAME]],$[DEPEND_DIRS]]
  616. $[TAB]cd ./$[RELDIR] && $(MAKE) all
  617. #end dirname
  618. // Define the rules to propogate these targets to the Makefile within
  619. // each directory.
  620. #foreach target install $[sub_targets]
  621. #formap dirname subdirs
  622. $[target]-$[dirname] :
  623. $[TAB]cd ./$[RELDIR] && $(MAKE) $[target]
  624. #end dirname
  625. #end target
  626. #end Makefile
  627. //////////////////////////////////////////////////////////////////////
  628. #endif // DIR_TYPE