Advertisement
Guest User

yet a trivial makefile

a guest
Feb 7th, 2014
1,476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 0.80 KB | None | 0 0
  1. # TODO: colorize unittest outputs
  2. # TODO: create .P for unittests
  3. # TODO: set include dir
  4.  
  5. .PHONY: all clean
  6.  
  7. empty =
  8. space = $(empty) $(empty)
  9.  
  10. CC := clang++
  11. CFLAGS := -std=c++0x -Wall
  12.  
  13. UNITTESTDIR = ./UnitTests
  14. ETCDIRS = ./Tools
  15. CPPS = $(shell find ./ \( -path $(subst $(space), -o -path ,$(ETCDIRS)) \) -prune -o -name "*.cpp" -print)
  16.  
  17. UNITTESTS = $(shell find $(UNITTESTDIR) -name "Makefile")
  18.  
  19. DEPS = $(CPPS:.cpp=.P)
  20. MAKEDEP = $(CC) $(CFLAGS) -E -MM -o $*.d $*.cpp
  21.  
  22. all: complete_test
  23.    
  24. complete_test:
  25.    
  26. %.o: %.P
  27.     $(CC) $(CFLAGS) -c -o $@ $*.cpp
  28.  
  29. %.P:
  30.     $(MAKEDEP)
  31.     @sed 's|\($(notdir $*)\)\.o|$@|g' < $*.d > $@; \
  32.         rm -f $*.d; [ -s $@ ] || rm -f $@
  33.  
  34. include $(UNITTESTS)
  35. ifneq "$(MAKECMDGOALS)" "clean"
  36.  -include $(DEPS)
  37. endif
  38.  
  39. clean:
  40.     rm -f $(OBJECTS)
  41.     rm -f $(DEPS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement