# simple makefile to build a directory of .3ds' into .bins
# self scans, then reinvokes

# you can just do "make horse.bin" or "make moo.bin fish.bin" to do an
# explicit list as opposed to having it just go do them all

dirfile=fl.tmp

dynamic_list .PHONY:
   @-ls -1 *.3ds > $(dirfile)
   @%set cur_files=$(dirfile,@,.3ds=,LC)
   -@make $(MFLAGS) "bin_list=$(cur_files,>.bin)" re_run
   @del $(dirfile)

re_run .PHONY: $(bin_list)

%.e: %.3ds
   --n:\bin\win95\n3ds2e $(.SOURCE) $(.SOURCE,.3ds=.e)
	sed -f replace.scr $(.SOURCE,.3ds=.e) > TEMP.E 
	del $(.SOURCE,.3ds=.e) > NUL
	ren TEMP.E $(.SOURCE,.3ds=.e) > NUL
    
%.e: %.rtg
   --n:\bin\win95\rtg2e $(.SOURCE) $(.SOURCE,.rtg=.e)
        sed -f replace.scr $(.SOURCE,.rtg=.e) > TEMP.E 
        del $(.SOURCE,.rtg=.e) > NUL
        ren TEMP.E $(.SOURCE,.rtg=.e) > NUL
    
%.bin: %.3ds
   --n:\bin\win95\n3ds2e $(.SOURCE) $(.SOURCE,.3ds=.e)
	sed -f replace.scr $(.SOURCE,.3ds=.e) > TEMP.E 
	del $(.SOURCE,.3ds=.e) > NUL
	ren TEMP.E $(.SOURCE,.3ds=.e) > NUL
   n:\bin\win95\bsp $(.SOURCE,.3ds=.e) -R @bsp.cfg
#   del $(.SOURCE,.3ds=.e)

%.bin: %.rtg
   --n:\bin\win95\rtg2e $(.SOURCE) $(.SOURCE,.rtg=.e)
        sed -f replace.scr $(.SOURCE,.rtg=.e) > TEMP.E 
        del $(.SOURCE,.rtg=.e) > NUL
        ren TEMP.E $(.SOURCE,.rtg=.e) > NUL
   n:\bin\win95\bsp $(.SOURCE,.rtg=.e) -R @bsp.cfg
#   del $(.SOURCE,.rtg=.e)

