由于自己的板子(mini2440)的开发环境是ubuntu+(arm-linux-gcc)+minicom+dnw,每次编译都需要自己一条条命令去敲,所以干脆就写个 相对于自己来说是万能的makefile(仅限于裸奔人士使用),小弟不才,,,望各makefile资深大神点化点化。就几行东西,所以就不打注释了

 
  
  1. #/************************************************** 
  2. #Author:青葱岁月 
  3. #Date:today... 
  4. #Version:1 
  5. #**************************************************/ 
  6. source:=$(shell ls *.*) 
  7. target:=target.bin 
  8. address:=0x0000000 
  9. obj_asm:=$(filter %.o,$(patsubst %.S,%.o,$(filter %.s %.S,$(source)))) 
  10. obj_asm+=$(filter %.o,$(patsubst %.s,%.o,$(filter %.s %.S,$(source)))) 
  11. obj_c:=$(filter %.o,$(patsubst %.C,%.o,$(filter %.c %.C,$(source)))) 
  12. obj_c+=$(filter %.o,$(patsubst %.c,%.o,$(filter %.c %.C,$(source)))) 
  13. obj:=$(obj_asm) $(obj_c) 
  14. temp_file:=$(obj) $(target) $(target)_elf $(patsubst %.bin,%.dis,$(target)) 
  15. CC:=arm-linux- 
  16. AT:=@ 
  17.      
  18.  
  19. test:=  $(AT)echo source:$(source)\ 
  20.     target:$(target)\ 
  21.     obj_asm:$(obj_asm)\ 
  22.     obj_c:$(obj_c)\ 
  23.     asm:$(filter %.s %.S,$(source))\ 
  24.     obj:$(obj) 
  25.  
  26. #display: 
  27. #   $(test) 
  28.  
  29.  
  30. $(target):$(obj) 
  31.     $(AT)$(CC)ld -Ttext $(address) -g $^ -o $(target)_elf    
  32.     $(AT)$(CC)objcopy -O binary -S $(target)_elf  $@ 
  33.     $(AT)$(CC)objdump -D -m arm $(target)_elf > $(patsubst %.bin,%.dis,$(target)) 
  34.  
  35.  
  36. %.o:%.C 
  37.     $(AT)$(CC)gcc -c -o $@ $< 
  38. %.o:%.S 
  39.     $(AT)$(CC)gcc -c -o $@ $< 
  40.  
  41. %.o:%.c 
  42.     $(AT)$(CC)gcc -c -o $@ $< 
  43. %.o:%.s 
  44.     $(AT)$(CC)gcc -c -o $@ $< 
  45.  
  46. .PHONY:clean 
  47. clean: 
  48.     $(AT)-rm -rf $(temp_file) 
  49.