Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1673963
  • 博文数量: 782
  • 博客积分: 2455
  • 博客等级: 大尉
  • 技术积分: 4140
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-06 21:37
个人简介

Linux ,c/c++, web,前端,php,js

文章分类

全部博文(782)

文章存档

2015年(8)

2014年(28)

2013年(110)

2012年(307)

2011年(329)

分类:

2011-07-29 18:26:06

原文地址:通用makefile 作者:wangwader

  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 *~
阅读(535) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~