From 1a789278543dc702638c7062b9922f3bcc9b04dd Mon Sep 17 00:00:00 2001 From: Wayne Warthen Date: Mon, 26 Jul 2021 10:00:04 -0700 Subject: [PATCH] Make and Build Refactoring --- Build.cmd | 6 +++ Clean.cmd | 5 +++ Source/Apps/I2C/Makefile | 19 ++-------- Source/Apps/Makefile | 2 +- Source/Apps/ramtest/Makefile | 2 +- Source/HBIOS/Build.cmd | 71 ++++++++++++++++++++++++++++++++---- Source/Images/Makefile | 2 + Source/RomDsk/Build.cmd | 6 +++ Tools/Makefile.inc | 46 ++++++++++++++++------- Tools/unix/Makefile | 7 ++-- Tools/unix/bin2asm/Makefile | 4 +- Tools/unix/bst/Makefile | 2 +- Tools/unix/lzsa/Makefile | 4 +- Tools/unix/uz80as/Makefile | 2 +- Tools/unix/zx/Makefile | 2 +- 15 files changed, 131 insertions(+), 49 deletions(-) create mode 100644 Build.cmd create mode 100644 Clean.cmd diff --git a/Build.cmd b/Build.cmd new file mode 100644 index 00000000..2b4a31d1 --- /dev/null +++ b/Build.cmd @@ -0,0 +1,6 @@ +@echo off +setlocal + +pushd Source && call Build %* || exit /b & popd + +pause diff --git a/Clean.cmd b/Clean.cmd new file mode 100644 index 00000000..3c7b25e2 --- /dev/null +++ b/Clean.cmd @@ -0,0 +1,5 @@ +@echo off +setlocal + +pushd Binary && call Clean || exit /b 1 & popd +pushd Source && call Clean || exit /b 1 & popd diff --git a/Source/Apps/I2C/Makefile b/Source/Apps/I2C/Makefile index e205dc82..a6715214 100644 --- a/Source/Apps/I2C/Makefile +++ b/Source/Apps/I2C/Makefile @@ -2,20 +2,7 @@ OBJECTS = i2cscan.com rtcds7.com i2clcd.com DEST = ../../../Binary/Apps TOOLS = ../../../Tools -include $(TOOLS)/Makefile.inc - -DEPS1 := i2cscan.asm $(shell find . -name '*.inc') -DEPS2 := rtcds7.asm $(shell find . -name '*.inc') -DEPS3 := i2clcd.asm $(shell find . -name '*.inc') - - -i2cscan.com: $(DEPS1) - $(TASM) -dWBW i2cscan.asm i2cscan.com i2cscan.lst - -rtcds7.com: $(DEPS2) - $(TASM) -dWBW rtcds7.asm rtcds7.com rtcds7.lst - -i2clcd.com: $(DEPS3) - $(TASM) -dWBW i2clcd.asm i2clcd.com i2clcd.lst - +USETASM=1 +TASMFLAGS=-dWBW +include $(TOOLS)/Makefile.inc diff --git a/Source/Apps/Makefile b/Source/Apps/Makefile index cbcd6675..7f87a2d0 100644 --- a/Source/Apps/Makefile +++ b/Source/Apps/Makefile @@ -10,5 +10,5 @@ include $(TOOLS)/Makefile.inc USETASM = 1 -survey.com: USETASM=0 +survey.com: USETASM = 0 diff --git a/Source/Apps/ramtest/Makefile b/Source/Apps/ramtest/Makefile index f99ee0bc..7e910bca 100644 --- a/Source/Apps/ramtest/Makefile +++ b/Source/Apps/ramtest/Makefile @@ -6,5 +6,5 @@ OTHERS = loader.bin dbgmon.bin include $(TOOLS)/Makefile.inc ramtest.com: loader.bin dbgmon.bin - cat loader.bin dbgmon.bin >ramtest.com + cat $^ >$@ diff --git a/Source/HBIOS/Build.cmd b/Source/HBIOS/Build.cmd index f6639106..64bd4a01 100644 --- a/Source/HBIOS/Build.cmd +++ b/Source/HBIOS/Build.cmd @@ -15,19 +15,46 @@ set ZXBINDIR=%TOOLS%/cpm/bin/ set ZXLIBDIR=%TOOLS%/cpm/lib/ set ZXINCDIR=%TOOLS%/cpm/include/ +:: +:: This PowerShell script validates the build variables passed in. If +:: necessary, the user is prmopted to pick the variables. It then creates +:: an include file that is imbedded in the HBIOS assembly (build.inc). +:: It also creates a batch command file that sets environment variables +:: for use by the remainder of this batch file (build_env.cmd). +:: + PowerShell -ExecutionPolicy Unrestricted .\Build.ps1 %* || exit /b +:: +:: Below, we process the command file created by the PowerShell script. +:: This sets the environment variables: Platform, Config, ROMName, +:: ROMSize, & CPUType. +:: + call build_env.cmd +:: +:: Start of the actual build process for a given ROM. +:: + echo Building %ROMSize%K ROM %ROMName% for Z%CPUType% CPU... +:: +:: UNA is a special case, check for it and jump if needed. +:: + if %Platform%==UNA goto :UNA +:: +:: Bring the previously build font files into this directory +:: + copy ..\Fonts\font*.asm . || exit /b :: :: Build HBIOS Core (all variants) :: + tasm -t%CPUType% -g3 -dROMBOOT hbios.asm hbios_rom.bin hbios_rom.lst || exit /b tasm -t%CPUType% -g3 -dAPPBOOT hbios.asm hbios_app.bin hbios_app.lst || exit /b tasm -t%CPUType% -g3 -dIMGBOOT hbios.asm hbios_img.bin hbios_img.lst || exit /b @@ -35,6 +62,7 @@ tasm -t%CPUType% -g3 -dIMGBOOT hbios.asm hbios_img.bin hbios_img.lst || exit /b :: :: Build ROM Components :: + call :asm dbgmon call :asm romldr call :asm eastaegg @@ -46,27 +74,40 @@ call :asm updater call :asm imgpad2 :: -:: Create ROM bank images by assembling components +:: Create additional ROM bank images by assembling components into +:: 32K chunks which can be concatenated later. Note that +:: osimg_small is a special case because it is 20K in size. This +:: image is subsequently used to generate the .com loadable file. :: copy /b romldr.bin + dbgmon.bin + ..\zsdos\zsys_wbw.bin + ..\cpm22\cpm_wbw.bin osimg.bin || exit /b -copy /b romldr.bin + dbgmon.bin + ..\zsdos\zsys_wbw.bin osimg_small.bin || exit /b copy /b ..\Forth\camel80.bin + nascom.bin + tastybasic.bin + game.bin + eastaegg.bin + netboot.mod + updater.bin + usrrom.bin osimg1.bin || exit /b copy /b imgpad2.bin osimg2.bin || exit /b +copy /b romldr.bin + dbgmon.bin + ..\zsdos\zsys_wbw.bin osimg_small.bin || exit /b + :: -:: Create final ROM images +:: Create final images (.rom, .upd, & .com) +:: The previously created bank images are concatenated as needed. +:: +:: The .rom image is made up of 4 banks followed by the ROM Disk. This +:: is for programming onto a ROM. +:: +:: The .upd image is the same as above, but without the the ROM Disk. +:: This is so you can update just the code portion of your ROM without +:: updating the ROM Disk contents. +:: +:: The .com image is a scaled down version of the ROM that you can run +:: as a standard application under an OS and it will replace your +:: HBIOS on the fly for testing purposes. :: - -set RomDiskDat= -if %ROMSize% GTR 128 set RomDiskDat=..\RomDsk\rom%ROMSize%_wbw.dat copy /b hbios_rom.bin + osimg.bin + osimg1.bin + osimg2.bin + ..\RomDsk\rom%ROMSize%_wbw.dat %ROMName%.rom || exit /b copy /b hbios_rom.bin + osimg.bin + osimg1.bin + osimg2.bin %ROMName%.upd || exit /b copy /b hbios_app.bin + osimg_small.bin %ROMName%.com || exit /b :: -:: Copy to output directory +:: Copy results to output directory :: copy %ROMName%.rom ..\..\Binary || exit /b @@ -81,23 +122,39 @@ goto :eof :UNA +:: +:: This process is basically equivalent to the one above, but tailored +:: for the UNA BIOS. +:: + +:: Build ROM components required by UNA call :asm dbgmon call :asm romldr +:: Create the OS bank copy /b romldr.bin + dbgmon.bin + ..\zsdos\zsys_una.bin + ..\cpm22\cpm_una.bin osimg.bin || exit /b +:: Copy OS Bank and ROM Disk image files to output copy /b osimg.bin ..\..\Binary\UNA_WBW_SYS.bin || exit /b copy /b ..\RomDsk\rom%ROMSize%_una.dat ..\..\Binary\UNA_WBW_ROM%ROMSize%.bin || exit /b +:: Create the final ROM image copy /b ..\UBIOS\UNA-BIOS.BIN + osimg.bin + ..\UBIOS\FSFAT.BIN + ..\RomDsk\rom%ROMSize%_una.dat %ROMName%.rom || exit /b +:: Copy to output copy %ROMName%.rom ..\..\Binary || exit /b goto :eof +:: +:: Simple procedure to assemble a specified component via TASM. +:: + :asm + echo. echo Building %1... tasm -t80 -g3 -fFF %1.asm %1.bin %1.lst || exit /b + goto :eof diff --git a/Source/Images/Makefile b/Source/Images/Makefile index 7df9706f..1540ddce 100644 --- a/Source/Images/Makefile +++ b/Source/Images/Makefile @@ -28,6 +28,8 @@ DEST=../../Binary TOOLS = ../../Tools include $(TOOLS)/Makefile.inc +.SHELLFLAGS = -ce + DIFFPATH = $(DIFFTO)/Binary hd512_combo.img: $(HD512PREFIX) $(HD512IMGS) diff --git a/Source/RomDsk/Build.cmd b/Source/RomDsk/Build.cmd index 965a2dd0..24f9bbed 100644 --- a/Source/RomDsk/Build.cmd +++ b/Source/RomDsk/Build.cmd @@ -21,6 +21,9 @@ set ZXINCDIR=%TOOLS%/cpm/include/ :: the final ROM size less 128K. :: +copy NUL rom128_wbw.dat +copy NUL rom128_una.dat + :: MakeDisk set RomApps=assign mode rtc syscopy xm @@ -47,13 +50,16 @@ set Bios=%5 echo Making ROM Disk %Output% +:: Create the empty disk image file srec_cat -Generate 0 %Size% --Constant 0xE5 -Output %Output%.dat -Binary || exit /b +:: Populate the disk image via cpmtools cpmcp -f %Format% %Output%.dat %Content%/*.* 0: || exit /b for %%f in (%RomApps%) do cpmcp -f %Format% %Output%.dat ../../Binary/Apps/%%f.com 0: || exit /b cpmcp -f %Format% %Output%.dat ..\cpm22\cpm_%Bios%.sys 0:cpm.sys || exit /b cpmcp -f %Format% %Output%.dat ..\zsdos\zsys_%Bios%.sys 0:zsys.sys || exit /b +:: Mark all disk files R/O for safety cpmchattr -f %Format% %Output%.dat r 0:*.* || exit /b goto :eof diff --git a/Tools/Makefile.inc b/Tools/Makefile.inc index 21ef90b8..28cb24fc 100644 --- a/Tools/Makefile.inc +++ b/Tools/Makefile.inc @@ -34,8 +34,12 @@ DIFFPATH := $(DIFFTO)/$(RELPATH) # CASEFN = $(TOOLS)/unix/casefn.sh +# +# compiler/assembler locations and flags +# ZXCC=$(BINDIR)/zx TASM=$(BINDIR)/uz80as -t z80 +TASMFLAGS= OPENSPIN=$(BINDIR)/openspin BSTC=$(BINDIR)//bstc CPMCP=$(BINDIR)/cpmcp @@ -45,32 +49,42 @@ CPMCP=$(BINDIR)/cpmcp # CPM=$(TOOLS)/cpm/bin +# +# .ONESHELL uses a single shell instance for all shell scripts. +# .SHELLFLAGS is used to cause all shell scripts to echo ("e") and to +# exit if any command returns a non-zero result ("x"). +# +.ONESHELL: +.SHELLFLAGS = -cex + %.com: %.asm - if [ "$(USETASM)" = 1 ] ; then \ - $(TASM) $< $@ ; \ + @if [ "$(USETASM)" = 1 ] ; then \ + $(TASM) $(TASMFLAGS) $< $@ $*.lst ; \ else \ $(ZXCC) $(CPM)/MAC -$< -$$PO ; \ $(ZXCC) $(CPM)/MLOAD25 -tmp.bin=$*.hex ; \ mv tmp.bin $@ ; \ + rm -f /tmp/casefn.cache ; \ rm -f $$($(CASEFN) $*.hex) ; \ fi %.hex: %.asm - $(ZXCC) $(CPM)/MAC -$< -$$PO ; \ + $(ZXCC) $(CPM)/MAC -$< -$$PO %.bin: %.ASM $(ZXCC) $(CPM)/MAC -$< -$$PO $(ZXCC) $(CPM)/MLOAD25 -tmp.bin=$*.hex mv tmp.bin $@ + rm -f /tmp/casefn.cache rm -f $$($(CASEFN) $*.hex) %.com: %.z80 - $(ZXCC) $(CPM)/Z80ASM -$(basename $<)/F ; \ - rm -f /tmp/casefn.cache ; \ + $(ZXCC) $(CPM)/Z80ASM -$(basename $<)/F + rm -f /tmp/casefn.cache mv $$($(CASEFN) $@) tmp.com ; mv tmp.com $@ %.bin: %.asm - $(TASM) $< $@ + $(TASM) $(TASMFLAGS) $< $@ $*.lst %.rel: %.asm $(ZXCC) $(CPM)/RMAC -$< @@ -95,8 +109,6 @@ ifeq ($(UNAME), Linux) $(BSTC) -e -l $< endif -.ONESHELL: - # # darwin bstc won't run, since mac os does not do 32 bit binaries any more # openspin ought to work @@ -110,29 +122,36 @@ endif # first target is default # all:: $(OBJECTS) - @$(foreach subdir,$(SUBDIRS),echo "*** Making directory $(subdir)"; $(MAKE) --directory $(subdir) all || exit 1;) + @for dir in $(SUBDIRS) ; do \ + $(MAKE) --directory $$dir all ; \ + done @if [ "$(DEST)" ] ; then for file in $(filter-out $(NOCOPY),$(OBJECTS)) ; do \ mkdir -p $(DEST) ; \ - echo copy $$file to $(DEST) ; \ + echo Copying $$file to $(DEST) ; \ rm -f /tmp/casefn.cache ; \ cp $$($(CASEFN) $$file) $(DEST) ; \ done ; fi @if [ "$(DOCDEST)" ] ; then for file in $(DOCS) ; do \ mkdir -p $(DOCDEST) ; \ - echo copy $$file to $(DOCDEST) ; \ + echo Copying $$file to $(DOCDEST) ; \ + rm -f /tmp/casefn.cache ; \ cp $$($(CASEFN) $$file) $(DOCDEST) ; \ done ; fi clean:: @-rm -f $$($(CASEFN) make.out *.sym *.lst *.prn *.diff *.dump $(OTHERS) $(filter-out $(NODELETE),$(OBJECTS))) - @$(foreach subdir,$(SUBDIRS),echo "*** Cleaning directory $(subdir)"; $(MAKE) --directory $(subdir) clean || exit 1;) + @for dir in $(SUBDIRS) ; do \ + $(MAKE) --directory $$dir clean ; \ + done clobber:: clean @if [ "$(DEST)" ] ; then for file in $(OBJECTS) ; do \ rm -f $$($(CASEFN) $(DEST)/$$file) ; \ done ; fi @-rm -f $$($(CASEFN) $(filter-out $(NODELETE),$(OBJECTS))) - @$(foreach subdir,$(SUBDIRS),echo "*** Clobbering directory $(subdir)"; $(MAKE) --directory $(subdir) clobber || exit 1;) + @for dir in $(SUBDIRS) ; do \ + $(MAKE) --directory $$dir clobber ; \ + done # # this is used to verify that the unix and windows tool chains are generating # the same objects @@ -165,4 +184,3 @@ endif vdiff: make VERBOSEDIFF=2 diff - diff --git a/Tools/unix/Makefile b/Tools/unix/Makefile index caa6c4ff..cba1782e 100644 --- a/Tools/unix/Makefile +++ b/Tools/unix/Makefile @@ -13,10 +13,11 @@ SUBDIRS = bst uz80as zx cpmtools bin2asm lzsa all: @chmod +x casefn.sh - @$(foreach subdir,$(SUBDIRS),$(MAKE) --directory $(subdir) all || exit 1;) + @$(foreach subdir,$(SUBDIRS),$(MAKE) --directory $(subdir) all;) clobber: - @$(foreach subdir,$(SUBDIRS),$(MAKE) --directory $(subdir) clobber || exit 1;) + @$(foreach subdir,$(SUBDIRS),$(MAKE) --directory $(subdir) clobber;) + @rm -rf ../$(UNAME) clean: - @$(foreach subdir,$(SUBDIRS),$(MAKE) --directory $(subdir) clean || exit 1;) + @$(foreach subdir,$(SUBDIRS),$(MAKE) --directory $(subdir) clean;) \ No newline at end of file diff --git a/Tools/unix/bin2asm/Makefile b/Tools/unix/bin2asm/Makefile index ec98153d..1ffdbd79 100644 --- a/Tools/unix/bin2asm/Makefile +++ b/Tools/unix/bin2asm/Makefile @@ -16,9 +16,9 @@ $(DEST): .PHONY: clean clean: - rm -f $(OBJ_FILES) + rm -f $(OBJ_FILES) $(BINARY) -clobber: +clobber: clean rm -f $(DEST)/$(BINARY) $(BINARY) $(BINARY): $(OBJ_FILES) diff --git a/Tools/unix/bst/Makefile b/Tools/unix/bst/Makefile index d3170586..2e6c8227 100644 --- a/Tools/unix/bst/Makefile +++ b/Tools/unix/bst/Makefile @@ -20,7 +20,7 @@ all: $(DEST) $(DEST): mkdir $(DEST) -clobber: +clobber: clean -for i in *.$(SUFFIX) ; do \ rm $(DEST)/$$(basename $$i .$(SUFFIX)) ; \ done diff --git a/Tools/unix/lzsa/Makefile b/Tools/unix/lzsa/Makefile index 84df4aab..9f9cd895 100644 --- a/Tools/unix/lzsa/Makefile +++ b/Tools/unix/lzsa/Makefile @@ -36,11 +36,11 @@ all: $(APP) cp -p $(APP) ../../$(UNAME) $(APP): $(OBJS) - @mkdir -p ../../bin/posix + #@mkdir -p ../../bin/posix $(CC) $^ $(LDFLAGS) -o $(APP) clean: @rm -rf $(APP) $(OBJDIR) -clobber: +clobber: clean rm -f ../../$(UNAME)/$(APP) diff --git a/Tools/unix/uz80as/Makefile b/Tools/unix/uz80as/Makefile index 1a22b386..164ca7e8 100644 --- a/Tools/unix/uz80as/Makefile +++ b/Tools/unix/uz80as/Makefile @@ -53,7 +53,7 @@ clobber: clean -rm -f uz80as $(DEST)/uz80as clean: - -rm -f $(OBJECTS) + -rm -f $(OBJECTS) uz80as uz80as: $(OBJECTS) $(CC) $(CFLAGS) -o uz80as $(OBJECTS) diff --git a/Tools/unix/zx/Makefile b/Tools/unix/zx/Makefile index 12adc60f..862ec7a3 100644 --- a/Tools/unix/zx/Makefile +++ b/Tools/unix/zx/Makefile @@ -23,7 +23,7 @@ $(DEST): mkdir -p $(DEST) clean: - -rm -f $(OBJECTS) config.h + -rm -f $(OBJECTS) config.h zx clobber: clean -rm -f $(DEST)/zx $(DEST)/bios.bin zx