[Makefile]一个错找了半天
11/25
一个错找了半天
1S_OBJS := $(patsubst % ,obj/%, $(S_FILE_NO_DIR:.S=.o))
2S_OBJS := $(patsubst %, obj/%, $(S_FILE_NO_DIR:.S=.o))
一个对一个错,就是这个错误到处怀疑错误,一个小时在这搞笑,下次一定注意,不会手贱多打空格
完整Makefile
1CROSS_COMPILE ?= arm-linux-
2TARGET ?= name
3
4CC := $(CROSS_COMPILE)gcc
5LD := $(CROSS_COMPILE)ld
6OBJCOPY := $(CROSS_COMPILE)objcopy
7OBJDUMP := $(CROSS_COMPILE)objdump
8
9INCLUDE_DIR := imx6ul \
10 bsp/clk \
11 bsp/led \
12 bsp/delay
13
14SOURCE_DIR := project \
15 bsp/clk \
16 bsp/led \
17 bsp/delay
18
19INCLUDE := $(patsubst %, -I %, $(INCLUDE_DIR))
20
21S_FILE := $(foreach dir,$(SOURCE_DIR),$(wildcard $(dir)/*.S))
22C_FILE := $(foreach dir,$(SOURCE_DIR),$(wildcard $(dir)/*.c))
23
24S_FILE_NO_DIR := $(notdir $(S_FILE))
25C_FILE_NO_DIR := $(notdir $(C_FILE))
26
27S_OBJS := $(patsubst %, obj/%, $(S_FILE_NO_DIR:.S=.o))
28C_OBJS := $(patsubst %, obj/%, $(C_FILE_NO_DIR:.c=.o))
29OBJS := $(S_OBJS) $(C_OBJS)
30
31VPATH := $(SOURCE_DIR)
32
33.PHONY: clean
34
35$(TARGET).bin : $(OBJS)
36 $(LD) -Timx6ul.lds -o $(TARGET).elf $^
37 $(OBJCOPY) -O binary -S $(TARGET).elf $@
38 $(OBJDUMP) -D -m arm $(TARGET).elf > $(TARGET).dis
39
40$(S_OBJS) : obj/%.o : %.S
41 $(CC) -Wall -nostdlib -c -O2 $(INCLUDE) -o $@ $^
42
43$(C_OBJS) : obj/%.o : %.c
44 $(CC) -Wall -nostdlib -c -O2 $(INCLUDE) -o $@ $^
45
46clean:
47 rm -rf $(TARGET).elf $(TARGET).dis $(TARGET).bin $(OBJS)
48
49print :
50 @echo INCLUDE = $(INCLUDE)
51 @echo S_OBJS = $(S_OBJS)
52 @echo C_OBJS = $(C_OBJS)
53 @echo OBJS = $(OBJS)
吾心信其可行,
则移山填海之难,
终有成功之日!
——孙文
则移山填海之难,
终有成功之日!
——孙文
评论
0 评论