File tree Expand file tree Collapse file tree 3 files changed +42
-8
lines changed
Expand file tree Collapse file tree 3 files changed +42
-8
lines changed Original file line number Diff line number Diff line change @@ -48,13 +48,12 @@ INC_FLAGS = $(addprefix -I,$(INC_DIRS))
4848# Target-specific flags
4949CPU_FLAGS ?= -mfloat-abi=$(FLOAT_ABI ) -m$(INSTR_SET ) -mcpu=$(CPU )
5050
51- CPPFLAGS ?=$(DEFS ) $(INC_FLAGS )
51+ CPPFLAGS ?= -MMD $(DEFS ) $(INC_FLAGS )
5252CFLAGS ?=$(CPU_FLAGS ) $(OPT )
5353CXXFLAGS :=$(CFLAGS ) -fno-exceptions -fno-rtti
5454LDFLAGS ?=$(CPU_FLAGS )
5555
56- # dependency
57- CXXFLAGS += -M
56+
5857
5958# Do not link stdlib with executable
6059CFLAGS += -nostdlib -fno-tree-loop-distribute-patterns -fdata-sections -ffunction-sections
@@ -93,10 +92,10 @@ $(BUILD_DIR)/%.s:%.cpp
9392 @echo " AS" $< " ==> " $@
9493 $(CXX ) $(CPPFLAGS ) $(CXXLAGS ) -o $@ -S $<
9594
96- # $(BUILD_DIR)/%.o:%.c
97- # @mkdir -p $(dir $@)
98- # @echo "CC" $< " ==> " $@
99- # $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
95+ $(BUILD_DIR ) /% .o :% .c
96+ @mkdir -p $(dir $@ )
97+ @echo " CC" $< " ==> " $@
98+ $(CC ) $(CPPFLAGS ) $(CFLAGS ) -o $@ -c $<
10099
101100$(BUILD_DIR ) /% .o :% .cpp
102101 @mkdir -p $(dir $@ )
@@ -105,7 +104,7 @@ $(BUILD_DIR)/%.o:%.cpp
105104
106105$(BUILD_DIR ) /$(TARGET ) .elf : $(OBJS )
107106 @echo " Linking sources into " $@
108- @ $(CC ) $(LDFLAGS ) -o $@ $^
107+ $(CC ) $(LDFLAGS ) -o $@ $^
109108
110109
111110flash : bin
@@ -117,3 +116,6 @@ debug: all
117116
118117clean :
119118 rm -rf build
119+
120+
121+ -include $(OBJS :% .o=% .d)
Original file line number Diff line number Diff line change @@ -135,3 +135,22 @@ make flash
1351353. Click in Run and Debug option in VsCode sidebar. Then launch Cortex Debug target.
136136
137137Happy debugging....
138+
139+ # ## Dependency option
140+ -M
141+ Outputs a rule suitable for makefile, does not compile the file
142+ The generated rule does not have a command
143+
144+ -MM
145+ Outputs a rule suitable for makefile, does not compile the file.
146+ In the dependencies only include user files, do not include system header files
147+
148+ -MT/-MQ (-MM -MT abc.o) => change the target
149+ This changes the name of the target
150+ -MT => generates the same string as provided
151+ -MQ => replaces value of the make variable in the target (expansation)
152+
153+ -MD => D represents that the preprocessor output should be generated as a side effect and the main compilation happens
154+ If -o options is specified then it is taken as name for the preprocessor output with .d
155+ else name of input file is taken with extensions as .d
156+ To override the name of the pre-processor output file -MF option should be used
Original file line number Diff line number Diff line change 1+ . cpu arm7tdmi
2+ .arch armv4t
3+ .fpu softvfp
4+ .eabi_attribute 20 , 1
5+ .eabi_attribute 21 , 1
6+ .eabi_attribute 23 , 3
7+ .eabi_attribute 24 , 1
8+ .eabi_attribute 25 , 1
9+ .eabi_attribute 26 , 1
10+ .eabi_attribute 30 , 6
11+ .eabi_attribute 34 , 0
12+ .eabi_attribute 18 , 4
13+ .file "main.cpp"
You can’t perform that action at this time.
0 commit comments