1 csrc = $(wildcard src/*.c) $(wildcard src/libc/*.c)
2 ssrc = $(wildcard src/*.s) $(wildcard src/libc/*.s)
3 Ssrc = $(wildcard src/*.S) $(wildcard src/libc/*.S)
4 obj = $(csrc:.c=.o) $(ssrc:.s=.o) $(Ssrc:.S=.o)
9 ifneq ($(shell uname -m | sed 's/^arm.*/arm/'), arm)
10 toolprefix = arm-linux-gnueabihf-
11 CPP = $(toolprefix)cpp
15 OBJCOPY = $(toolprefix)objcopy
18 warn = -pedantic -Wall
21 gccopt = -fpic -ffreestanding -nostdinc
22 arch = -mcpu=arm1176jzf-s
24 CFLAGS = $(arch) $(warn) $(opt) $(dbg) $(gccopt) $(inc) $(def)
25 ASFLAGS = $(arch) $(dbg) $(inc)
26 LDFLAGS = -nostdlib -T rpikern.ld -print-gc-sections
28 QEMU_FLAGS = -m 256 -M raspi2 -serial stdio
32 $(OBJCOPY) -O binary $< $@
35 $(LD) -o $@ $(obj) -Map link.map $(LDFLAGS)
40 @echo 'gen dep $@ ...'
41 @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
45 rm -f $(obj) $(bin) $(elf) link.map
53 qemu-system-arm $(QEMU_FLAGS) -kernel $(elf)