summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 32b7615617c715f188a2c6b6a6e9660956892a53 (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
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/make -R

CC	= gcc
CFLAGS	= -m32
AS	= as
ASFLAGS	= --32
LD	= ld
LDFLAGS = -m elf_i386 -z max-page-size=4096
OBJCOPY = objcopy

OBJS = header.o start.o printmsg.o \
       int2f.o acc.o fxn.o \
       utf.o datetime.o \
       message.o

.SUFFIXES: .s .S .o .elf .lst .map .exe .img

all: v9fs.exe v9fs.img

.PRECIOUS: %.s
%.s: %.S v9fs.h
	$(CC) $(CFLAGS) -D__ASSEMBLY__ -E -o $@ $<

%.o: %.S

.PRECIOUS: %.o
%.o: %.s
	$(AS) $(ASFLAGS) -a=$*.lst -o $@ $<

v9fs.elf: dostsr.ld $(OBJS)
	$(LD) $(LDFLAGS) -T dostsr.ld -Map=$*.map -o $@ $(OBJS)

%.exe: %.elf
	$(OBJCOPY) -O binary $< $@

.PHONY: cp
cp:
	$(MAKE) -C cp

cp/default.uni: cp

utf.o: cp/default.uni

v9fs.img: v9fs.exe cp
	rm -f $@
	qemu-img create -f raw $@ 1440K
	mkdosfs -v -n V9FS $@
	mcopy -i $@ v9fs.exe '::'
	mcopy -i $@ cp/cp*.uni '::'

clean:
	rm -f *.s *.o *.lst *.map *.elf *.exe *.img
	$(MAKE) -C cp clean

spotless: clean
	rm -f \#* *~
	$(MAKE) -C cp spotless