aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: ffb4e2ec63536530fcbf6006a5bcb562f5c2b8af (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
58
59
60
61
62
MAKE       = make
MAKEFLAGS += --no-print-directory

include Makefile.config

.PHONY: all run clean test FORCE
all: glitch.elf

run: glitch.iso
	@qemu-system-i386 -cdrom glitch.iso -accel kvm -d cpu_reset -display gtk,zoom-to-fit=on

clean:
	@${MAKE} ARCH=${ARCH} -C lib clean
	@${MAKE} ARCH=${ARCH} -C ${ARCH} clean
	@${MAKE} ARCH=${ARCH} -C devices clean
	@${MAKE} ARCH=${ARCH} -C src clean

info:
	@echo "* Build information *"
	@echo "  ARCH  ${ARCH}"
	@echo "  MAKE  $(shell ${MAKE} --version | head -n1)"
	@echo "  CC    $(shell ${CC} --version | head -n1)"
	@echo "        ${CCFLAGS}"
	@echo "  LD    $(shell ${LD} --version | head -n1)"
	@echo "        ${LDFLAGS}"

test:
	grep -r 'asm' devices lib src

FORCE:

.config: Kconfig
	@alldefconfig

Makefile.config: .config
	@cp .config Makefile.config
	@echo -e '\n# toolchain.mk' >> Makefile.config
	@cat $$(sed -nE "s/CONFIG_ARCH_(.+)=y/\1/p" .config)/toolchain.mk >> Makefile.config

lib/libk.a: FORCE
	@${MAKE} -C lib libk.a
i686/arch.a: FORCE
	@${MAKE} -C ${ARCH} arch.a
devices/devs.a: FORCE
	@${MAKE} -C devices devs.a
src/kernel.a: FORCE
	@${MAKE} -C src kernel.a

glitch.elf: ${ARCH}/arch.a src/kernel.a devices/devs.a lib/libk.a
	@echo '  LD   $@'
	@${LD} ${LDFLAGS} -T ${ARCH}/linker.ld -o $@ $^

glitch.iso: glitch.elf grub/grub.cfg
	@grub-file --is-x86-multiboot2 glitch.elf
	@mkdir -p isodir/boot/grub
	@mkdir -p isodir/boot/glitch
	@grub-script-check grub/grub.cfg
	@cp grub/grub.cfg isodir/boot/grub/grub.cfg
	@cp glitch.elf isodir/boot/glitch/glitch.elf
	@${STRIP} isodir/boot/glitch/glitch.elf
	@grub-mkrescue -o glitch.iso isodir