源文件被包含在子文件夹的Makefile编写

文件夹分布情况:

源文件被包含在子文件夹的Makefile编写

 

Makefile:

从第14行开始,"/*.S"字段非注释,但是变了颜色,忽略颜色变化。

 

 1 CROSS_COMPILE ?= arm-linux-gnueabihf-
 2 TARGET          ?= key
 3 
 4 CC               := $(CROSS_COMPILE)gcc
 5 LD                 := $(CROSS_COMPILE)ld
 6 OBJCOPY         :=$(CROSS_COMPILE)objcopy
 7 OBJDUMP         :=$(CROSS_COMPILE)objdump
 8 
 9 INCUDIRS    := imx6u   bsp/beep    bsp/clk    bsp/delay    bsp/key    bsp/led
10 
11 SRCDIRS        := project bsp/beep    bsp/clk    bsp/delay    bsp/key    bsp/led
12 
13 INCLUDE        := $(patsubst %, -I %,$(INCUDIRS))
14 SFILES        :=$(foreach dir,$(SRCDIRS),$(wildcard $(dir)/*.S))
15 CFILES        :=$(foreach dir,$(SRCDIRS),$(wildcard $(dir)/*.c))
16 SFILENDIR        :=$(notdir $(SFILES))
17 CFILENDIR        :=$(notdir $(CFILES))
18 SOBJS        := $(patsubst %, obj/%, $(SFILENDIR:.S=.o))
19 COBJS        := $(patsubst %, obj/%, $(CFILENDIR:.c=.o))
20 OBJS        := $(SOBJS) $(COBJS)
21 
22 VPATH        := $(SRCDIRS)
23 
24 
25 .PHONY: clean
26 
27 $(TARGET).bin : $(OBJS)
28     $(LD) -Timx6u.lds -o $(TARGET).elf $^
29     $(OBJCOPY) -O binary -S $(TARGET).elf $@
30     $(OBJDUMP) -D -m arm $(TARGET).elf > $(TARGET).dis
31 
32 $(SOBJS) : obj/%.o:%.S
33     $(CC) -Wall -nostdlib -c -O2 $(INCLUDE) -o $@ $<
34 
35 $(COBJS): obj/%.o:%.c
36     $(CC) -Wall -nostdlib -c -O2 $(INCLUDE) -o $@ $<
37 
38 clean:
39     rm -rf $(TARGET).elf $(TARGET).bin $(TARGET).dis $(OBJS) load.imx
40 
41 print:
42     @echo VPATH=$(VPATH)
43     @echo INCLUDE=$(INCLUDE)

 

上一篇:【模板】计几 射线法判断点是否在简单多边形内


下一篇:(标注普尔500证券实战)Python教程之训练测试数据集划分和交叉验证-Train/Test Split and Cross Validation