Chinaunix首页 | 论坛 | 博客
  • 博客访问: 9848
  • 博文数量: 8
  • 博客积分: 260
  • 博客等级: 二等列兵
  • 技术积分: 90
  • 用 户 组: 普通用户
  • 注册时间: 2009-10-20 15:49
文章分类
文章存档

2011年(2)

2010年(5)

2009年(1)

我的朋友
最近访客

分类: LINUX

2011-07-28 11:45:57

  1. #this make file can auto maticly make all c and cpp files in a folder.
  2. #no need to modify this file, it can work well.
  3. #autor: Chunrui Wang
  4. #date: 2011-07-28



  5. # The executeable file name
  6. APP = test

  7. # source file name . include C and Cpp
  8. SRCS = $(wildcard *.cpp) $(wildcard *.c)

  9. #object files
  10. OBJS = $(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(SRCS)))

  11. #header depandence files.
  12. DEPS = $(patsubst %.cpp,%.d~,$(patsubst %.c,%.d~,$(SRCS)))




  13. #support mutiple target here.
  14. .PHONY : all
  15. all : $(APP)

  16. $(APP):$(OBJS)
  17.     $(CXX) $(CFLAGS) -o $(APP) $(OBJS) $(LDFLAGS)



  18. #generate the header depandence for each cpp file.
  19. #Delete the hint rule of makefile for Cpp file.
  20. .SUFFIXES : .cpp
  21. .cpp.o:
  22.     $(CXX) $(CFLGAS) -MMD -MF $*.d~ -c -o $@ $<


  23. #generate the header depandence for each c file.
  24. #Delete the hint rule of makefile for C file.
  25. .SUFFIXES : .c
  26. .c.o:
  27.     $(CXX) $(CFLGAS) -MMD -MF $*.d~ -c -o $@ $<


  28. #this is very important
  29. -include $(DEPS)



  30. #Deleting some files to make the project clean.
  31. .PHONY : clean
  32. clean :
  33.     rm -rf *.o
  34.     rm -rf $(APP)
  35.     rm -rf *~
阅读(361) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~