Skip to content

Commit

Permalink
Introduce makefiles for building Nextor (#82)
Browse files Browse the repository at this point in the history
Makefiles are introduced in the following directories:

source/kernel
source/command/msxdos
source/tools
source/tools/C

Also there's a top-level makefile in source/ that invokes all others.

Minor changes were needed in code (b3.mac and ascii8/chgbnk.mac)

The compile.sh scripts are removed.
  • Loading branch information
Konamiman committed Aug 1, 2021
1 parent 0e132ac commit 31f315e
Show file tree
Hide file tree
Showing 16 changed files with 718 additions and 618 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -25,6 +25,7 @@ dos250ba.dat
kernel.dat
nextor2.rom
info/*.pdf
source/kernel/*.bytes
source/kernel/bank*/*.inc
source/kernel/drivers/*.inc
source/kernel/drivers/**/*.inc
Expand All @@ -37,6 +38,7 @@ source/kernel/bank5/*.asm
source/command/msxdos/*.inc
source/command/msxdos/codes.mac
source/command/msxdos/data.mac
source/command/msxdos/USEKMSG.MAC
source/tools/**.inc
source/tools/**.asm
source/tools/**.com
Expand Down
18 changes: 10 additions & 8 deletions README.md
Expand Up @@ -30,6 +30,7 @@ The "official" environment for building Nextor is Linux. Legacy support for Wind

To build Nextor on Linux you'll need:

* `make`. On Debian/Ubuntu-ish systems you can just `apt-get install make`.
* The native MACRO80 tools provided by [the M80dotNet project](https://github.com/Konamiman/M80dotNet). Go to [the releases section](https://github.com/Konamiman/M80dotNet/releases) and download the appropriate variant of the latest version.
* [SDCC](http://sdcc.sourceforge.net/), for FDISK and the command line tools written in C. On Debian/Ubuntu-ish systems you can just `apt-get install sdcc`.
* `objcopy` from [the binutils package](https://www.gnu.org/software/binutils/). On Debian/Ubuntu-ish systems you can just `apt-get install binutils`.
Expand All @@ -38,14 +39,15 @@ To build Nextor on Linux you'll need:

Except for those obtained via `apt`, you'll need to place these tools at a suitable location to be able to use them, e.g. `/usr/bin`.

Once the tools are in place you can use the following scripts to build the various components of Nextor:
There are five makefiles that will take care of building the different components of Nextor. Once the tools are in place you can just `cd` to the appropriate directory and run `make`:

* `source/kernel/compile.sh`: builds the kernel ROM files and copies them to the `bin/kernels` directory. Can be executed as `compile.sh drivers` to only compile the drivers.
* `source/kernel/bank5/compile.sh`: builds only the part of the kernel corresponding to the buildt-in FDISK tool and patches the ROM files in the `bin/kernels` directory with the result.
* `source/kernel/bank5/compile_fdisk.sh`: this one is NOT intended to be used directly, it's called by the previous two and it does the actual compilation from the FDISK source files. If `fdisk.dat` already exists and is newer than `fdisk.c` then it will not be compiled (and the same for `fdisk2.dat` and `fdisk2.c`).
* `source/command/msxdos.sh`: builds `NEXTOR.SYS` and copies it to the `bin/tools` directory.
* `source/tools/compile.sh`: builds the command line tools written in assembler and copies them to the `bin/tools` directory. To build only one of the tools pass its name as an argument (without extension).
* `source/tools/C/compile.sh`: builds the command line tools written in C and copies them to the `bin/tools` directory. To build only one of the tools pass its name as an argument (without extension).
* `source/kernel`: builds the kernel ROM files and copies them to the `bin/kernels` directory. There are handy aliases for the different ROM files, so you can run e.g. `make ide`; see the `kernels` rule at the beginning of the file for the full list.
* `source/command/msxdos`: builds `NEXTOR.SYS` and copies it to the `bin/tools` directory.
* `source/tools`: builds the command line tools written in assembler and copies them to the `bin/tools` directory.
* `source/tools/C`: builds the command line tools written in C and copies them to the `bin/tools` directory.
* `source`: this one just invokes the other four in sequence, so it builds pretty much everything. It supports `make clean` too.

You may want to take a look at [this now closed pull request from Dean Netherton](https://github.com/Konamiman/Nextor/pull/79) that contains a different attempt at writing makefiles for bulding Nextor. It even has some nice extra features like building FDD and HDD images with Nextor, and building the `mknexrom` tool itself.

## Windows

Expand All @@ -59,4 +61,4 @@ To build Nextor on Windows you need:
* [SDCC](http://sdcc.sourceforge.net/), for FDISK and the command line tools written in C.
* .NET Framework 2.0 or higher, for the `SymToEqus` tool.

You'll find a number of `.bat` files available at the same locations of the Linux `.sh` scripts (see "Linux" section above) that serve the same purpose.
You'll find a number of `.bat` files available at the same locations of the Linux makefiles except for the one in `source` (see "Linux" section above). These are not "makefile-ish" and always build the whole set of kernels/tools.
18 changes: 18 additions & 0 deletions source/Makefile
@@ -0,0 +1,18 @@
# Top level makefile for Nextor.
# It will build the kernel ROM files, NEXTOR.SYS and the command line tools.
# The generated files will be copied to bin/kernels and bin/tools.
# The makefiles on each directory can be used independently as well.

all:
$(MAKE) -C kernel
$(MAKE) -C command/msxdos
$(MAKE) -C tools
$(MAKE) -C tools/C

.PHONY: clean

clean:
$(MAKE) -C kernel clean
$(MAKE) -C command/msxdos clean
$(MAKE) -C tools clean
$(MAKE) -C tools/C clean
87 changes: 87 additions & 0 deletions source/command/msxdos/Makefile
@@ -0,0 +1,87 @@
# Makefile for NEXTOR.SYS

# The generated NEXTOR.SYS and NEXTOR.SYS.japanese are copied to the bin/tools directory.

export X80_COMMAND_LINE=-t -nb
export M80_COMMAND_LINE=-8

define hex2bin
objcopy -I ihex -O binary $(1) $(2)
endef

define copy_to_bin
cp $(1) ../../../bin/tools/$(2)
endef

nextor-sys: NEXTOR.SYS NEXTORK.SYS

.phony: prerequisites

TOOLS := M80 L80 objcopy

prerequisites:
@mkdir -p ../../../bin/tools
$(foreach exec,$(TOOLS),\
$(if $(shell which $(exec)),,$(error "ERROR: can't execute $(exec), is it installed/in PATH?")))

-include prerequisites

INCS := ../../kernel/macros.inc ../../kernel/const.inc ../../kernel/condasm.inc
RELS := KMSG.REL MESSAGES.REL REAL.REL REF.REL RELOC.REL VER.REL END.REL

NEXTOR.SYS: \
$(RELS) \
CODES.REL \
DATA.REL \
sys.mac \
kmsg.mac \
nokmsg.mac

cp nokmsg.mac USEKMSG.MAC
M80 -p ../../kernel =SYS
L80 /P:100,CODES,DATA,RELOC,VER,REF,SYS,REAL,SYS,MESSAGES,END,NEXTOR/n/x/y/e
$(call hex2bin,NEXTOR.HEX,NEXTOR.SYS)
$(call copy_to_bin,NEXTOR.SYS)

NEXTORK.SYS: \
$(RELS) \
CODES.REL \
DATA.REL \
KMSG.REL \
sys.mac \
yeskmsg.mac

cp yeskmsg.mac USEKMSG.MAC
M80 -p ../../kernel =SYS
L80 /P:100,CODES,DATA,RELOC,VER,REF,SYS,REAL,SYS,MESSAGES,KMSG,END,NEXTORK/n/x/y/e
$(call hex2bin,NEXTORK.HEX,NEXTORK.SYS)
$(call copy_to_bin,NEXTORK.SYS,NEXTOR.SYS.japanese)

lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,\
$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,\
$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1))))))))))))))))))))))))))

.SECONDEXPANSION:
$(RELS): \
$$(patsubst %.rel,%.mac,$$(call lc, $$@)) \
$(INCS)

M80 =$(notdir $(patsubst %.REL,%,$@))

CODES.REL: \
../../kernel/codes.mac \
$(INCS)

M80 -p ../../kernel =CODES

DATA.REL: \
../../kernel/data.mac \
$(INCS)

M80 -p ../../kernel =DATA

.PHONY: clean

clean:
for ext in BIN HEX REL SYM; do find . -type f -name "*.$$ext" -delete; done
rm -f USEKMSG.MAC
41 changes: 0 additions & 41 deletions source/command/msxdos/compile.sh

This file was deleted.

0 comments on commit 31f315e

Please sign in to comment.