forked from PetteriAimonen/Baselibc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
42 lines (31 loc) · 924 Bytes
/
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
OBJCOPY=./toolchain/bin/llvm-objcopy
CC=./toolchain/bin/clang
# You can override the CFLAGS and C compiler externally,
# e.g. make PLATFORM=cortex-m3
CFLAGS += -g -Wall -Werror -I include
CFLAGS += -O3 --target=tl45-unknown-none -fintegrated-as
# 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 += -O3 -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 $@ $<