-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathMakefile
64 lines (53 loc) · 1.53 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
60
61
62
63
64
# You can override the CFLAGS and C compiler externally,
# e.g. make PLATFORM=cortex-m3
CFLAGS += -g -Wall -Werror -I include
ifeq ($(PLATFORM),cortex-m3)
CC = arm-none-eabi-gcc
AR = arm-none-eabi-ar
CFLAGS += -mcpu=cortex-m3 -mthumb
CFLAGS += -fno-common -Os
CFLAGS += -ffunction-sections -fdata-sections
else ifeq ($(PLATFORM),cortex-m0)
CC = arm-none-eabi-gcc
AR = arm-none-eabi-ar
CFLAGS += -mcpu=cortex-m0 -mthumb
CFLAGS += -fno-common -Os
CFLAGS += -ffunction-sections -fdata-sections
else ifeq ($(PLATFORM),m68k-elf)
CC = m68k-elf-gcc
AR = m68k-elf-ar
CFLAGS += -mcpu=68000
CFLAGS += -fno-common -Os
CFLAGS += -ffunction-sections -fdata-sections
CFLAGS += -ffreestanding
CFLAGS += -DNO_UNISTD_H
else ifeq ($(PLATFORM),pic32mm)
CC = xc32-gcc
AR = xc32-ar
CFLAGS += -g -x c -c -mprocessor=32MM0256GPM064
endif
# With this, the makefile should work on Windows also.
ifdef windir
RM = del
endif
# Just include all the source files in the build.
CSRC = $(wildcard src/*.c)
OBJS = $(CSRC:.c=.o)
# And the files for the test suite
TESTS_CSRC = $(wildcard tests/*_tests.c)
TESTS_OBJS = $(TESTS_CSRC:.c=)
# Some of the files uses "templates", i.e. common pieces
# of code included from multiple files.
CFLAGS += -Isrc/templates
all: libc.a
clean:
$(RM) $(OBJS) $(TESTS_OBJS) libc.a
libc.a: $(OBJS)
$(RM) $@
$(AR) ru $@ $^
run_tests: $(TESTS_OBJS)
$(foreach f,$^,$f)
tests/%: tests/%.c tests/tests_glue.c libc.a
$(CC) $(CFLAGS) -o $@ $^
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<