-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
55 lines (39 loc) · 1.32 KB
/
Makefile
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
ARCH = ../gcc-arm-none-eabi-4_6-2012q2/bin/arm-none-eabi
CC = ${ARCH}-gcc
CPP = ${ARCH}-g++
AS = ${ARCH}-as
LD = ${ARCH}-ld
AR = ${ARCH}-ar
OBJCOPY = ${ARCH}-objcopy
PLATFORM = raspi
# Release Version -> Optimize
#CFLAGS = -O3 -std=gnu99 -Werror -D__$(PLATFORM)__ -DRASPBERRY_PI
#ASFLAGS =
CFLAGS = -O0 -g -std=gnu99 -Werror -D__$(PLATFORM)__ -DRASPBERRY_PI -fno-builtin
ASFLAGS = -g
CFLAGS_FOR_TARGET = -mcpu=arm1176jzf-s
ASFLAGS_FOR_TARGET = -mcpu=arm1176jzf-s
LDFLAGS = -nostdlib -static --error-unresolved-symbols
MODULES := raspi
SRC_DIR := $(addprefix src/,$(MODULES))
INC_DIR := $(addsuffix /include,$(SRC_DIR))
BUILD_DIR := $(addsuffix /build,$(SRC_DIR))
ASRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.s))
AOBJ := $(ASRC:.s=.o)
CSRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c))
COBJ := $(CSRC:.c=.o)
INCLUDES := -Isrc $(addprefix -I,$(SRC_DIR) $(INC_DIR))
vpath %.c $(SRC_DIR)
vpath %.cpp $(SRC_DIR)
vpath %.s $(SRC_DIR)
%.o: %.c
$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) $(CFLAGS) -c -o $*.o $<
%.o: %.s
$(AS) $(ASFLAGS_FOR_TARGET) $(INCLUDES) $(ASFLAGS) -o $*.o $<
OBJ = $(AOBJ) $(COBJ)
bin/kernel.img: bin/kernel.elf
${OBJCOPY} -O binary $< $@
bin/kernel.elf: raspi.ld $(OBJ)
${LD} ${LDFLAGS} $(OBJ) -Map bin/kernel.map -o $@ -T raspi.ld
clean:
rm -f bin/*.elf bin/*.img bin/*.map $(OBJ)