Makefile 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # A Makefile for fusing Google Test and building a sample test against it.
  2. #
  3. # SYNOPSIS:
  4. #
  5. # make [all] - makes everything.
  6. # make TARGET - makes the given target.
  7. # make check - makes everything and runs the built sample test.
  8. # make clean - removes all files generated by make.
  9. # Points to the root of fused Google Test, relative to where this file is.
  10. FUSED_GTEST_DIR = output
  11. # Paths to the fused gtest files.
  12. FUSED_GTEST_H = $(FUSED_GTEST_DIR)/gtest/gtest.h
  13. FUSED_GTEST_ALL_CC = $(FUSED_GTEST_DIR)/gtest/gtest-all.cc
  14. # Where to find the sample test.
  15. SAMPLE_DIR = ../../samples
  16. # Where to find gtest_main.cc.
  17. GTEST_MAIN_CC = ../../src/gtest_main.cc
  18. # Flags passed to the preprocessor.
  19. # We have no idea here whether pthreads is available in the system, so
  20. # disable its use.
  21. CPPFLAGS += -I$(FUSED_GTEST_DIR) -DGTEST_HAS_PTHREAD=0
  22. # Flags passed to the C++ compiler.
  23. CXXFLAGS += -g
  24. all : sample1_unittest
  25. check : all
  26. ./sample1_unittest
  27. clean :
  28. rm -rf $(FUSED_GTEST_DIR) sample1_unittest *.o
  29. $(FUSED_GTEST_H) :
  30. ../fuse_gtest_files.py $(FUSED_GTEST_DIR)
  31. $(FUSED_GTEST_ALL_CC) :
  32. ../fuse_gtest_files.py $(FUSED_GTEST_DIR)
  33. gtest-all.o : $(FUSED_GTEST_H) $(FUSED_GTEST_ALL_CC)
  34. $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(FUSED_GTEST_DIR)/gtest/gtest-all.cc
  35. gtest_main.o : $(FUSED_GTEST_H) $(GTEST_MAIN_CC)
  36. $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(GTEST_MAIN_CC)
  37. sample1.o : $(SAMPLE_DIR)/sample1.cc $(SAMPLE_DIR)/sample1.h
  38. $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1.cc
  39. sample1_unittest.o : $(SAMPLE_DIR)/sample1_unittest.cc \
  40. $(SAMPLE_DIR)/sample1.h $(FUSED_GTEST_H)
  41. $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1_unittest.cc
  42. sample1_unittest : sample1.o sample1_unittest.o gtest-all.o gtest_main.o
  43. $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@