# Builds p7zip 9.20.1 w/ DJGPP (G++) under native FreeDOS + XMS (SFN 8.3)
# This assumes that longer names are truncated correctly, hence DJTAR 2.04.
# Only tested with DJGPP 2.04 /beta/ (Make 3.81 etc.), so caveat emptor.

ifeq ($(DJGPP),)
$(error Why isn't your DJGPP compiler enabled??)
endif

P7ZIPDIR=p7zip_9.20-
P7ZIPSRC=p7zip_9_.bz2

TIME=redir -t

.PHONY: all clean

all: 7za.exe

7za.exe: $(P7ZIPSRC) makefile.rug p7z_sfn.txt p7z_sed.txt
	djtar -x -n p7z_sfn.txt $(P7ZIPSRC)
	cd $(P7ZIPDIR)
	$(TIME) sed -i -f ..\p7z_sed.txt ...\make* ...\*.[ch]*
	copy ..\makefile.rug makefile.mac
	$(TIME) $(MAKE)
	dir bin\*.exe

clean:
	rm -r $(P7ZIPDIR)
