forked from coduin/epiphany-bsp
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
117 lines (85 loc) · 2.46 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
ESDK=${EPIPHANY_HOME}
# ARCH will be either x86_64, x86, or armv7l (parallella)
ARCH=$(shell uname -m)
ifeq ($(ARCH),x86_64)
PLATFORM_PREFIX=arm-linux-gnueabihf-
else
PLATFORM_PREFIX=
endif
HOST_LIBNAME = libhost-bsp
E_LIBNAME = libe-bsp
LIBEXT = .a
E_SRCS = \
e_bsp.c \
e_bsp_drma.c \
e_bsp_mp.c \
e_bsp_memory.c
E_ASM_SRCS = \
e_bsp_raw_time.s
E_HEADERS = \
include/common.h \
include/e_bsp.h \
include/e_bsp_private.h
HOST_HEADERS = \
include/common.h \
include/host_bsp.h
HOST_SRCS = \
host_bsp.c
INCLUDES = -I/usr/arm-linux-gnueabihf/include \
-I./include \
-I${ESDK}/tools/host/include
HOST_LIBS= -L${ESDK}/tools/host/lib \
-le-hal
E_FLAGS = -Os -fno-strict-aliasing -ffast-math -std=c99 -Wall
E_OBJS = $(E_SRCS:%.c=bin/e/%.o) $(E_ASM_SRCS:%.s=bin/e/%.o)
HOST_OBJS = $(HOST_SRCS:%.c=bin/host/%.o)
E_ASMS = $(E_SRCS:%.c=bin/e/%.s)
########################################################
vpath %.c src
vpath %.s src
bin/host/%.o: %.c $(HOST_HEADERS)
@echo "CC $<"
@$(PLATFORM_PREFIX)gcc -O3 -Wall -std=c99 $(INCLUDES) -c $< -o $@ ${HOST_LIBS}
# C code to object file
bin/e/%.o: %.c $(E_HEADERS)
@echo "CC $<"
@e-gcc $(E_FLAGS) $(INCLUDES) -c $< -o $@ -le-lib
# Assembly to object file
bin/e/%.o: %.s $(E_HEADERS)
@echo "CC $<"
@e-gcc $(E_FLAGS) -c $< -o $@ -le-lib
# C code to assembly
bin/e/%.s: %.c $(E_HEADERS)
@echo "CC $<"
@e-gcc $(E_FLAGS) $(INCLUDES) -fverbose-asm -S $< -o $@
all: host e
host: host_dirs lib/$(HOST_LIBNAME)$(LIBEXT)
e: e_dirs lib/$(E_LIBNAME)$(LIBEXT)
assembly: $(E_ASMS)
lint:
@scripts/cpplint.py --filter=-whitespace/braces,-readability/casting,-build/include,-build/header_guard --extensions=h,c $(E_SRCS:%.c=src/%.c) $(HOST_SRCS:%c=src/%c) $(E_HEADERS) $(HOST_HEADERS)
unit_test:
@make -B; cd test; make -B; ./test.py
doxygen: $(E_HEADERS) $(HOST_HEADERS)
@cd doc; doxygen Doxyfile
host_dirs:
@mkdir -p bin/host lib
e_dirs:
@mkdir -p bin/e lib
lib/$(HOST_LIBNAME)$(LIBEXT): $(HOST_OBJS)
@$(PLATFORM_PREFIX)ar rs $@ $^
lib/$(E_LIBNAME)$(LIBEXT): $(E_OBJS)
@e-ar rs $@ $^
sizecheck: src/sizeof_check.cpp
@echo "-----------------------"
@echo "Sizecheck using e-g++"
@echo "-----------------------"
e-g++ -Wall $(INCLUDES) -c $< -o /dev/null
@echo "-----------------------"
@echo "Sizecheck using g++"
@echo "-----------------------"
$(PLATFORM_PREFIX)g++ -Wall $(INCLUDES) -c $< -o /dev/null
########################################################
clean:
rm -r lib
rm -r bin