This repository has been archived by the owner on Nov 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathMakefile
135 lines (102 loc) · 3.05 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
ESDK=${EPIPHANY_HOME}
# ARCH will be either x86_64, x86, or armv7l (parallella)
ARCH=$(shell uname -m)
ifeq ($(ARCH),x86_64)
ARM_PLATFORM_PREFIX=arm-linux-gnueabihf-
E_PLATFORM_PREFIX =epiphany-elf-
else
ARM_PLATFORM_PREFIX=
E_PLATFORM_PREFIX =e-
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_bsp_buffer.c \
e_bsp_buffer_deprecated.c \
e_bsp_dma.c
E_ASM_SRCS = \
e_bsp_raw_time.s
E_HEADERS = \
include/ebsp_common.h \
include/e_bsp.h \
include/e_bsp_private.h
HOST_HEADERS = \
include/ebsp_common.h \
include/host_bsp.h \
include/host_bsp_private.h
HOST_SRCS = \
host_bsp.c \
host_bsp_memory.c \
host_bsp_buffer.c \
host_bsp_buffer_deprecated.c \
host_bsp_mp.c \
host_bsp_utility.c \
host_bsp_debug.c
#First include directory is only for cross-compiling
INCLUDES = -I/usr/include/esdk \
-I./include \
-I${ESDK}/tools/host/include
HOST_LIBS= -L${ESDK}/tools/host/lib \
-le-hal
CCFLAGS = -std=c99 -O3 -Wall -Wfatal-errors
EFLAGS = -std=c99 -O3 -fno-strict-aliasing -ffast-math -fno-tree-loop-distribute-patterns -Wall -Wfatal-errors
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 $<"
@$(ARM_PLATFORM_PREFIX)gcc $(CCFLAGS) $(INCLUDES) -c $< -o $@ ${HOST_LIBS}
# C code to object file
bin/e/%.o: %.c $(E_HEADERS)
@echo "CC $<"
@$(E_PLATFORM_PREFIX)gcc $(EFLAGS) $(INCLUDES) -c $< -o $@ -le-lib
# Assembly to object file
bin/e/%.o: %.s $(E_HEADERS)
@echo "CC $<"
@$(E_PLATFORM_PREFIX)gcc $(EFLAGS) -c $< -o $@ -le-lib
# C code to assembly
bin/e/%.s: %.c $(E_HEADERS)
@echo "CC $<"
@$(E_PLATFORM_PREFIX)gcc $(EFLAGS) $(INCLUDES) -fverbose-asm -S $< -o $@
all: host e
debug: CCFLAGS += -DDEBUG -g
debug: EFLAGS += -DDEBUG
debug: 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
docs: $(E_HEADERS) $(HOST_HEADERS)
@cd docs; doxygen Doxyfile_host && doxygen Doxyfile_e && make html
host_dirs:
@mkdir -p bin/host lib
e_dirs:
@mkdir -p bin/e lib
lib/$(HOST_LIBNAME)$(LIBEXT): $(HOST_OBJS)
@$(ARM_PLATFORM_PREFIX)ar rs $@ $^
lib/$(E_LIBNAME)$(LIBEXT): $(E_OBJS)
@$(E_PLATFORM_PREFIX)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 "-----------------------"
$(ARM_PLATFORM_PREFIX)g++ -Wall $(INCLUDES) -c $< -o /dev/null
########################################################
clean:
rm -r lib
rm -r bin