-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
54 lines (43 loc) · 1.39 KB
/
makefile
File metadata and controls
54 lines (43 loc) · 1.39 KB
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
CROSS = arm-linux-
CFLAGS = -nostdlib -nostdinc -Wall -g -O2
INCLUDE = -I$(shell pwd)/inc
#LFLAGS = #-L
export CROSS INCLUDE CFLAGS
#objs := start.o init.o main.o led.o key.o adc.o Nand.o timer.o uart.o
#模式匹配当前目录下所有.c 文件,wildcard为一个预定义的宏
C_sources_files = $(wildcard *.c)
S_sources_files = $(wildcard *.S)
#模式匹配,由当前目录下所有.c文件得到对应的.o文件
C_objs = $(patsubst %.c,%.o,$(C_sources_files))
S_objs = $(patsubst %.S,%.o,$(S_sources_files))
.PHONY :all
all:uCOS.bin
uCOS.bin: $(S_objs) $(C_objs) obj/libsys.a obj/libsrc.a obj/libucos.a
${CROSS}ld -Tlink.lds -o uCOS.elf $^
# ${CROSS}gcc -Tlink.lds $(LFLAGS) $(INCLUDE) -o fdapp.elf $^
${CROSS}objcopy -O binary -S uCOS.elf $@
${CROSS}objdump -D -m arm uCOS.elf > uCOS.dis
mv *.o ./obj
mv *.bin ./obj
mv *.elf ./obj
mv *.dis ./obj
.PHONY : obj/libsys.a
obj/libsys.a:
cd sys; make; cd ..
.PHONY : obj/libsrc.a
obj/libsrc.a:
cd src; make; cd ..
.PHONY : obj/libsrc.a
obj/libucos.a:
cd ucos; make; cd ..
%.o:%.c
${CROSS}gcc $(CFLAGS) $(INCLUDE) -c -o $@ $<
%.o:%.S
${CROSS}gcc $(CFLAGS) $(INCLUDE) -c -o $@ $<
.PHONY:clean
clean:
make clean -C sys
make clean -C src
make clean -C ucos
rm -f *.elf *.o *.bin *.dis
rm -f ./obj/*.elf ./obj/*.bin ./obj/*.dis ./obj/*.o ./obj/*.a