TARGET := ../arrayForth/OkadWork.cf  # code to disassemble
CF2_ANALYZE := $(PWD)
all: check
%.dsm: %.bin %.cul
	[ -e $@ ] && cp -f $@ /tmp  # save a copy for comparison
	cidis $+ > $@
cf2.%.dsm: cf2.bin
	objdump --disassemble-all --target=binary --architecture=$* $< > $@
/tmp/%.bin: %.dsm
	cias $< $@
check: /tmp/cf2.bin cf2.bin
	if cmp -l $+; then touch $@; fi
cf2.bin: $(TARGET)
	dd if=$< of=$@ bs=256 count=48  # first 12K = 0x3000 bytes
upload:
	rsync -avuz --delete $(DRYRUN) \
	 . www:/var/www/unternet.net/src/$(notdir $(PWD))/
	cd ../arrayForth && rsync -avuz --delete $(DRYRUN) \
	 . www:/var/www/unternet.net/src/arrayForth/
	cd .. && rsync -avuz ciasdis-0-3-0.tgz www:/var/www/unternet.net/src/
/tmp/cftest.cf: /tmp/cf2.bin
	cp $(TARGET) $@
	dd if=$< of=$@ conv=notrunc
qemu:	/tmp/cftest.cf
	qemu -m 32 -fda $<  # check for bootworthiness
ciasdis-0.3.0.jccf2.patch: ../ciasdis-0-3-0.tgz ../ciasdis
	makepatch -description "stops CRAWL after CALL," \
         -description "prepends space to comment to fix RB, bug" \
	 $+ >$@
patch: ciasdis-0.3.0.jccf2.patch
	ln -s $< $@
../ciasdis-0-3-0.tgz:
	wget http://home.hccnet.nl/a.w.m.van.der.horst/$@
../ciasdis: ../ciasdis-0-3-0.tgz
	cd .. && mkdir ciasdis && cd ciasdis && tar xvfz $< && \
	 patch -p0 <$(CF2_ANALYZE)/patch && $(MAKE) ciasdis
cfdoc:	../cf2/ColorForth2.0a.doc
	ooffice $<
tutorial: ../cf2/ColorForth_Tutorial.doc
	ooffice $<
diff:
	diff cf2.dsm /tmp
