Template.models.pp 29 KB

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