Template.models.pp 28 KB

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