-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
163 lines (137 loc) · 4.96 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>
# Define project name
PROJECT = pmc
include cfg/features.mk
include hal/hal.mk
include cfg/system.mk
include cfg/files.mk
include test/test_cfg.mk
# Define optimisation level here -O3 for best or -O0 for no optimisation
OPT += -O3
OPT += -ffunction-sections
OPT += -fdata-sections
# coverage
ifeq ($(JENKINS),yes)
OPT += -ftest-coverage
OPT += -fprofile-arcs
CPPFLAGS += -ftest-coverage
CPPFLAGS += -fprofile-arcs
LDFLAGS += -ftest-coverage
LDFLAGS += -fprofile-arcs
LIB += -lgcov
endif
CFLAGS += $(OPT)
# -g: produce debugging information
CFLAGS += -g
#enable warnings
CFLAGS += -Wall
#do all checks according to C standard.
CFLAGS += -pedantic
# Use C99 with GNU extensions
CFLAGS += -std=gnu99
# print warnings in color
#CFLAGS += -fdiagnostics-color
CPPFLAGS += -g -Wall -pedantic -fdiagnostics-color
# to get reproduceable builds:
CFLAGS += -save-temps=obj
ASFLAGS += -save-temps=obj
ifeq ($(COMPILER),clang)
#CFLAGS += --analyze
else
endif
#CFLAGS += -nostdinc
#LDFLAGS += -nostdinc
LDFLAGS += -g
LDFLAGS += -Wall
# preparing the variables
INCDIR = $(patsubst %,-I%, $(INCDIRS))
OBJS = $(addprefix $(BIN_FOLDER),$(STARTUP:.s=.o) $(SRC:.c=.o))
#targets:
#========
help:
@echo " "
@echo "Build targets for PMC (PaceMaker Client)"
@echo " "
@echo "make clean - delete all created files"
@echo "make doxygen - create documentation"
@echo "make cmocka_test - run cmocka unit tests"
@echo "make cpputest_test - run CppUTest unit tests"
@echo "make list - readelf + objdump"
@echo "make all BOARD=linux - build project to run on Linux"
@echo "make all BOARD=401nucleo - build project to run on Nucleo(-64)-F401RE board"
@echo "make all BOARD=446nucleo - build project to run on Nucleo(-64)-F446RE board"
@echo "make all BOARD=stm407disco - build project to run on STM32F4 discovery board"
@echo "make all BOARD=pipy - build project to run on pipy board"
@echo "make all BOARD=rumba - build project to run on rumba board"
@echo "make all BOARD=ultimaker_original - build project to run on Ultimaker Original"
@echo "make burn BOARD=401nucleo - programm the created file to Nucleo(-64)-F401RE board"
@echo "make burn BOARD=446nucleo - programm the created file to Nucleo(-64)-F446RE board"
@echo "make burn BOARD=stm407disco - programm the created file to STM32F4 discovery board"
@echo "make burn BOARD=pipy - programm the created file to pipy board"
@echo "make burn BOARD=rumba - programm the created file to rumba board"
@echo "make burn BOARD=ultimaker_original - programm the created file to Ultimaker Original"
@echo " "
all: directories $(OBJS) $(BIN_FOLDER)$(PROJECT).elf $(OBJS) $(BIN_FOLDER)$(PROJECT).bin list
$(TRGT)size $(BIN_FOLDER)$(PROJECT).elf
$(BIN_FOLDER)%o: %c
@$(MKDIR_P) $(@D)
$(CC) -c $(CFLAGS) $(DDEFS) $(OPTIONS_ARCH) $(INCDIR) $< -o $@
$(BIN_FOLDER)%o: %s
@$(MKDIR_P) $(@D)
$(AS) -c $(ASFLAGS) $(OPTIONS_ARCH) $< -o $@
%elf: $(OBJS)
$(LD) $(OBJS) $(LDFLAGS) $(OPTIONS_ARCH) $(LIB) -o $@
$(SIZE) $(BIN_FOLDER)$(PROJECT).elf
%hex: %elf
$(HEX) $< $@
%bin: %elf
$(BIN) $< $@
%txt: %elf
$(DIS) $< $@ > $@
%vhx: %elf
$(VERILOG_HEX) $< $@
doxygen:
-rm -rf doc/doxygen
$(DOXYGEN) Doxyfile
include test/test_target.mk
directories:
@echo "Board = $(BOARD)"
@echo "Architecture = $(ARCHITECTURE)"
@echo "Board Folder = $(BOARD_FOLDER)"
@$(MKDIR_P) $(BIN_FOLDER)
@$(MKDIR_P) $(TEST_BIN_FOLDER)
clean:
-rm -rf $(TEST_BIN_FOLDER)
-rm -rf $(BIN_FOLDER)
list:
@echo " READ -> $(BIN_FOLDER)$(PROJECT).rd"
@arm-none-eabi-readelf -Wall $(BIN_FOLDER)$(PROJECT).elf > $(BIN_FOLDER)$(PROJECT).rd
@echo " LIST -> $(BIN_FOLDER)$(PROJECT).lst"
@$(OBJDUMP) -axdDSstr $(BIN_FOLDER)$(PROJECT).elf > $(BIN_FOLDER)$(PROJECT).lst
#$(OBJDUMP) -h -S -z $< > $@
ifeq ($(BOARD),$(filter $(BOARD),stm407disco pipy 401nucleo 446nucleo))
burn:
# needs https://github.com/texane/stlink
$(STLINK_FOLDER)/st-flash write $(BIN_FOLDER)$(PROJECT).bin 0x8000000
debug:
# needs https://github.com/texane/stlink
$(STLINK_FOLDER)/st-util&
$(DB) $(BIN_FOLDER)$(PROJECT).elf
else ifeq ($(BOARD),$(filter $(BOARD),rumba ultimaker_original))
burn:
# needs avrdude
avrdude -p$(MCU) -c$(PROGRAMMER) -P$(PROGRAM_PORT) -D -U flash:w:$(BIN_FOLDER)$(PROJECT).elf -v
# -v
endif
.PHONY: all clean directories list
# end of file