-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
136 lines (93 loc) · 3.1 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
# Makefile for DSO203 example application
# Petteri Aimonen <jpa@dso.mail.kapsi.fi> 2011
# Name of the target application
NAME = LOGICAPP
# Names of the object files (add all .c files you want to include)
OBJS = main.o ds203_io.o dsosignalstream.o \
xposhandler.o textdrawable.o signalgraph.o \
breaklines.o cursor.o window.o grid.o timemeasure.o \
cxxglue.o libc_glue.o fix16.o fix16_exp.o lcd.o buttons.o \
menudrawable.o
# Linker script (choose which application position to use)
LFLAGS = -L linker_scripts -T app3.lds
# Any libraries to include
LIBS = -lm -lgcc baselibc/libc.a
# Include directories for .h files
CFLAGS = -I baselibc/include -I stm32_headers -I DS203 -I libfixmath
# Include directories for .hh files
CXXFLAGS = -I streams -I gui
# DS203 generic stuff
OBJS += startup.o BIOS.o Interrupt.o
# Names of the toolchain programs
CC = arm-none-eabi-gcc
CXX = arm-none-eabi-g++
CP = arm-none-eabi-objcopy
OD = arm-none-eabi-objdump
# Processor type
CFLAGS += -mcpu=cortex-m3 -mthumb -mno-thumb-interwork
# Optimization & debug settings
CFLAGS += -fno-common -O1 -g
# Compiler warnings
CFLAGS += -Wall -Werror -Wno-unused
# Flags for C++
CXXFLAGS += -fno-exceptions -fno-rtti -std=gnu++0x
# Default linker arguments (disables GCC-provided startup.c, creates .map file)
LFLAGS += -nostartfiles -nostdlib -Wl,-Map=build/$(NAME).map -eReset_Handler
# Directory for .o files
VPATH = build
_OBJS = $(addprefix build/,$(OBJS))
all: $(NAME).HEX
clean:
rm -f $(NAME).HEX build/*
$(NAME).HEX: build/$(NAME).elf
$(CP) -O ihex $< $@
build/$(NAME).elf: ${_OBJS} baselibc/libc.a
$(CXX) $(CFLAGS) $(CXXFLAGS) $(LFLAGS) -o $@ ${_OBJS} ${LIBS}
# Rebuild all objects if a common header changes
$(_OBJS): DS203/*.h Makefile dependencies
# C files
build/%.o: %.c *.h
$(CC) $(CFLAGS) -std=gnu99 -c -o $@ $<
build/%.o: DS203/%.c
$(CC) $(CFLAGS) -c -o $@ $<
build/%.o: DS203/%.S
$(CC) $(CFLAGS) -c -o $@ $<
# C++ files
build/%.o: gui/%.cc gui/*.hh streams/*.hh
$(CXX) $(CFLAGS) $(CXXFLAGS) -c -o $@ $<
build/%.o: streams/%.cc gui/*.hh streams/*.hh
$(CXX) $(CFLAGS) $(CXXFLAGS) -c -o $@ $<
build/%.o: %.cc gui/*.hh streams/*.hh
$(CXX) $(CFLAGS) $(CXXFLAGS) -c -o $@ $<
# Dependencies
baselibc/libc.a: baselibc/Makefile
make -C baselibc
baselibc: baselibc.tar.gz
tar xzf baselibc.tar.gz
touch baselibc
build/%.o: libfixmath/%.c
$(CC) $(CFLAGS) -DFIXMATH_NO_CACHE -c -o $@ $<
libfixmath/%: libfixmath
libfixmath:
tar xzf libfixmath.tar.gz
touch libfixmath
build:
mkdir -p build
dependencies: baselibc libfixmath build
# Installing
deploy: $(NAME).HEX
mount /mnt/dso
cp $< /mnt/dso
umount /mnt/dso
# The rest is for the developer unit tests
HOSTCXX = g++
HOSTCXXFLAGS = -I. -Istreams -Igui -Wall -g -O0 $(CXXFLAGS)
run_tests: build/dsosignalstream_tests build/xposhandler_tests
$(foreach test, $^, \
echo $(test) && \
./$(test) > /dev/null && \
) true
build/%_tests: gui/%_tests.cc gui/%.cc gui/*.hh streams/*.hh
$(HOSTCXX) $(HOSTCXXFLAGS) -o $@ gui/$*_tests.cc gui/$*.cc
build/%_tests: streams/%_tests.cc streams/%.cc streams/*.hh
$(HOSTCXX) $(HOSTCXXFLAGS) -o $@ streams/$*_tests.cc streams/$*.cc