include defs.mak
prot32_as=-march i486
mztinit_as=-mtune=i486
dpmi_max_paras=0x9000
addmzhdr_opts=-m $(dpmi_max_paras) -M $(dpmi_max_paras)
dir_var=-D_d_use_local_hdrs

all:$(progs_exe) $(progs_com)
dt_tsr-elf.o:dt_tsr.s
	$(call as_elf_dt,.code16\n,-defsym real_mode=1)
dt_tsr_map.h:dt_tsr-elf.o
	$(q)$(call build_com,--print-map)|sort|uniq|ltrim|dt_tsr.bsh $@
	$(q)rm a.out
dtunload-elf.o:dt_tsr_map.h
dt_tsr:dt_tsr.com dtunload.com
%-go32.o:%.s
	$(q)$(djas) -g \
 -I $(prod_incdir) $< -o $@
bdev.exe lfndj.exe dj32.exe:%.exe:%-go32.o
	$(q)djld  $< -Tdj32.ld -L $(prod_libdir) -o $@ -ldt32 -lasmdj32 \
-L $(HOMEDRV)/djgpp/lib \
-L$(HOMEDRV)/djgpp/lib/gcc/djgpp/4.21 -lc -lgcc
ifndef debug
	$(q)djstrip $@
endif
/c/mydocs/bin/%:%
	$(q)cp $< $@
	$(q)echo '$<' >/c/runonce.bat
mc9865.exe:makefile
	$(q)cp /c/bin/mc9865.exe tmp
	$(q)bytes 14 0x90|insertfile tmp - 0x1b37
	$(q)cp tmp $@
q.s:mc9865.exe
	$(q)skipbytes 0x200 -n0x3330 $< -o tmp
	$(q)dis16 tmp --start 0x10|obj2s -o $@
fdmpbios.img:fdmpbios.bin
	$(q)sectoralign $< $@
%.c:%.x
	$(q)precpp $<
$(as_is_progs):%:$(as_is_src)/%
	$(q)cp $< $@
vmc9865-elf.o:9865.dat rn9865.exe
9865.dat:
	$(q)dump9865
rn9865.exe:
	$(q)cp /c/bin/mc9865.exe tmp.exe
	$(q)skipbytes 0x200 tmp.exe -o tmp.bin
	$(q)bytes 1 0xcc|insertfile tmp.bin -  0xd66 0xd7e
	$(q)insertfile tmp.exe tmp.bin 0x200
	$(q)mv tmp.exe $@
%.obj:%.i
	$(q)tcc -c $<
%.i:%.tc
	$(q)tcpp $<|grep -vi '^\#' >$@
$($(filter %.c,$(as_is_progs)):.c=.tc):%.tc:../%.c
	$(q)cp $< $@
%-go32.o:%.S
	$(q)djgcc $< -o $@ -c \
-I /i/mydocs/src/djgpp/libc/crt0
%.b32:%.bin32
	$(q)cp $< $@

mzttest.raw:makefile
	$(q)speakr 'enough for now' -o mzttest-data.tmp
	$(q)stereo2mono mzttest-data.tmp -o mzttest-data.tmp1
	$(q)s16l2u8 mzttest-data.tmp1  -o $@
	$(q)rm mzttest-data.tmp*
skipbyte.exe:skipbytes.exe
	$(q)cp $< $@
krnl.bin:krnl32-elf32.o

gdp.com:getdriveparms.com
	$(q)cp $< $@

otrbios.exe:otrbios.bin
	$(q)addmzhdr  $< $@

discscan.x:%:../pm/pm/%
	$(q)cp $< $@
include rules.mak
