summaryrefslogtreecommitdiffstats
path: root/sw/z80/makefile
blob: 3d682ca6430bbde4f04a8fd4dd31ea70bb915d6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
####
# source code settings
#
OSNAME := helvetiOS
 
CSOURCES 	:= $(wildcard kernel/*.c) $(wildcard libc/*.c)
OBJECTS 	:= $(patsubst %.c,build/%.rel,$(CSOURCES))
HEXFILE		:= build/$(OSNAME).hex
BINARY  	:= build/$(OSNAME).bin

### 
# compiler settings

CC 		:= sdcc

CFLAGS	:= -mz80 \
			-I kernel/include -I libc/include -DDEBUG

LDFLAGS := -mz80 --no-std-crt0 crt0.rel \
			--code-loc 0x0800 --data-loc 0x8000

.PHONY: dirs dis clean
all: $(BINARY)

# build binary
$(BINARY): $(OBJECTS) dirs
	$(CC) $(LDFLAGS) $(OBJECTS) -o $(HEXFILE)
	xxd -r -p $(HEXFILE) $(BINARY)

$(OBJECTS): build/%.rel : %.c $(CSOURCES) dirs crt0.rel
	$(CC) $(CFLAGS) -c $< -o $@

crt0.rel: crt0.s
	sdasz80 -o $<

dirs:
	mkdir -p build build/kernel build/libc

dis: $(BINARY)
	z80dasm -a -g 0h $< -o $(OSNAME).s

clean:
	- rm -rd build/*
	- rm $(OSNAME).s
	- rm crt0.rel