Makefile.ori 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. CC = g++
  2. CCFLAGS = -g -ansi -Wall -W -ansi # -pedantic
  3. SED = sed
  4. MV = mv
  5. RM = rm
  6. .SUFFIXES: .o .cpp
  7. lib = libUnitTest++.a
  8. test = TestUnitTest++
  9. src = src/AssertException.cpp \
  10. src/Test.cpp \
  11. src/Checks.cpp \
  12. src/TestRunner.cpp \
  13. src/TestResults.cpp \
  14. src/TestReporter.cpp \
  15. src/TestReporterStdout.cpp \
  16. src/ReportAssert.cpp \
  17. src/TestList.cpp \
  18. src/TimeConstraint.cpp \
  19. src/TestDetails.cpp \
  20. src/MemoryOutStream.cpp \
  21. src/DeferredTestReporter.cpp \
  22. src/DeferredTestResult.cpp \
  23. src/XmlTestReporter.cpp
  24. ifeq ($(MSYSTEM), MINGW32)
  25. src += src/Win32/TimeHelpers.cpp
  26. else
  27. src += src/Posix/SignalTranslator.cpp \
  28. src/Posix/TimeHelpers.cpp
  29. endif
  30. test_src = src/tests/Main.cpp \
  31. src/tests/TestAssertHandler.cpp \
  32. src/tests/TestChecks.cpp \
  33. src/tests/TestUnitTest++.cpp \
  34. src/tests/TestTest.cpp \
  35. src/tests/TestTestResults.cpp \
  36. src/tests/TestTestRunner.cpp \
  37. src/tests/TestCheckMacros.cpp \
  38. src/tests/TestTestList.cpp \
  39. src/tests/TestTestMacros.cpp \
  40. src/tests/TestTimeConstraint.cpp \
  41. src/tests/TestTimeConstraintMacro.cpp \
  42. src/tests/TestMemoryOutStream.cpp \
  43. src/tests/TestDeferredTestReporter.cpp \
  44. src/tests/TestXmlTestReporter.cpp
  45. objects = $(patsubst %.cpp, %.o, $(src))
  46. test_objects = $(patsubst %.cpp, %.o, $(test_src))
  47. dependencies = $(subst .o,.d,$(objects))
  48. test_dependencies = $(subst .o,.d,$(test_objects))
  49. define make-depend
  50. $(CC) $(CCFLAGS) -M $1 | \
  51. $(SED) -e 's,\($(notdir $2)\) *:,$(dir $2)\1: ,' > $3.tmp
  52. $(SED) -e 's/#.*//' \
  53. -e 's/^[^:]*: *//' \
  54. -e 's/ *\\$$//' \
  55. -e '/^$$/ d' \
  56. -e 's/$$/ :/' $3.tmp >> $3.tmp
  57. $(MV) $3.tmp $3
  58. endef
  59. all: $(test)
  60. $(lib): $(objects)
  61. @echo Creating $(lib) library...
  62. @ar cr $(lib) $(objects)
  63. $(test): $(lib) $(test_objects)
  64. @echo Linking $(test)...
  65. @$(CC) -o $(test) $(test_objects) $(lib)
  66. @echo Running unit tests...
  67. @./$(test)
  68. clean:
  69. -@$(RM) $(objects) $(test_objects) $(dependencies) $(test_dependencies) $(test) $(lib) 2> /dev/null
  70. %.o : %.cpp
  71. @echo $<
  72. @$(call make-depend,$<,$@,$(subst .o,.d,$@))
  73. @$(CC) $(CCFLAGS) -c $< -o $(patsubst %.cpp, %.o, $<)
  74. ifneq "$(MAKECMDGOALS)" "clean"
  75. -include $(dependencies)
  76. -include $(test_dependencies)
  77. endif