-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
60 lines (45 loc) · 1.07 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
55
56
57
58
59
# Build Target
TARGET=libbrisc.a
# CPU
CPU=cpu/${BRISC_CPU}
# GCC toolchain programs.
CC = ${BRISC_GCC}-gcc
AR = ${BRISC_GCC}-ar
# C compilation directives
CFLAGS += -c
CFLAGS += -Wall
CFLAGS += ${BRISC_CFLAGS}
include $(CPU)/cflags.mk
# Archiver Flags.
AFLAGS += rcs
# Header file directories.
INCLUDE += -I $(CPU)
INCLUDE += -I inc
# CPU Source files.
C_SRC += $(CPU)/cpu.c
# BRISCIT Source Files
C_SRC += src/brisc_sched.c
C_SRC += src/brisc_irq.c
C_SRC += src/brisc_thread.c
C_SRC += src/brisc_mutex.c
C_SRC += src/brisc_sem.c
C_SRC += src/brisc_delay.c
# Object files to build.
OBJS = $(AS_SRC:.S=.o)
OBJS += $(C_SRC:.c=.o)
# Default rule to build the whole project.
.PHONY: all
all: $(TARGET)
# Rule to build assembly files.
%.o: %.S
$(CC) -x assembler-with-cpp $(ASFLAGS) $(INCLUDE) $< -o $@
# Rule to compile C files.
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDE) $< -o $@
# Rule to create an ELF file from the compiled object files.
$(TARGET): $(OBJS)
$(AR) $(AFLAGS) $@ $^
# Rule to clear out generated build files.
.PHONY: clean
clean:
rm -f $(OBJS) $(TARGET)