由于自己的板子(mini2440)的开发环境是ubuntu+(arm-linux-gcc)+minicom+dnw,每次编译都需要自己一条条命令去敲,所以干脆就写个 相对于自己来说是万能的makefile(仅限于裸奔人士使用),小弟不才,,,望各makefile资深大神点化点化。就几行东西,所以就不打注释了
- #/**************************************************
- #Author:青葱岁月
- #Date:today...
- #Version:1
- #**************************************************/
- source:=$(shell ls *.*)
- target:=target.bin
- address:=0x0000000
- obj_asm:=$(filter %.o,$(patsubst %.S,%.o,$(filter %.s %.S,$(source))))
- obj_asm+=$(filter %.o,$(patsubst %.s,%.o,$(filter %.s %.S,$(source))))
- obj_c:=$(filter %.o,$(patsubst %.C,%.o,$(filter %.c %.C,$(source))))
- obj_c+=$(filter %.o,$(patsubst %.c,%.o,$(filter %.c %.C,$(source))))
- obj:=$(obj_asm) $(obj_c)
- temp_file:=$(obj) $(target) $(target)_elf $(patsubst %.bin,%.dis,$(target))
- CC:=arm-linux-
- AT:=@
- test:= $(AT)echo source:$(source)\
- target:$(target)\
- obj_asm:$(obj_asm)\
- obj_c:$(obj_c)\
- asm:$(filter %.s %.S,$(source))\
- obj:$(obj)
- #display:
- # $(test)
- $(target):$(obj)
- $(AT)$(CC)ld -Ttext $(address) -g $^ -o $(target)_elf
- $(AT)$(CC)objcopy -O binary -S $(target)_elf $@
- $(AT)$(CC)objdump -D -m arm $(target)_elf > $(patsubst %.bin,%.dis,$(target))
- %.o:%.C
- $(AT)$(CC)gcc -c -o $@ $<
- %.o:%.S
- $(AT)$(CC)gcc -c -o $@ $<
- %.o:%.c
- $(AT)$(CC)gcc -c -o $@ $<
- %.o:%.s
- $(AT)$(CC)gcc -c -o $@ $<
- .PHONY:clean
- clean:
- $(AT)-rm -rf $(temp_file)
转载于:https://blog.51cto.com/shmi1y2006/938901