Makefile 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. GCC = gcc
  2. CFLAGS = -g -Wall -Wshadow
  3. OBJS = answer08.o pa08.o
  4. HDRS = pa08.h
  5. TARGET = pa08
  6. TESTN := $(shell seq 1 10)
  7. VALGRIND = valgrind --tool=memcheck --leak-check=full --verbose
  8. TESTS := $(addprefix test,${TESTN})
  9. .PHONY : all test clean environment help testall $(TESTS)
  10. pa08: $(OBJS) $(HDRS)
  11. $(GCC) $(CFLAGS) $(OBJS) -o $@
  12. help:
  13. @echo
  14. @echo "make build $(TARGET)"
  15. @echo "make testall run all testcases"
  16. @echo "make clean start from scratch"
  17. @echo
  18. @echo "make test01 normal case with fewer inputs"
  19. @echo "make test02 two empty array"
  20. @echo "make test03 arrays with value of 0"
  21. @echo "make test04 arrays with redundant index"
  22. @echo "make test05 identical arrays with inverse sign values"
  23. @echo "make test06 normal cases"
  24. @echo "make test07 normal cases"
  25. @echo "make test08 normal cases"
  26. @echo "make test09 normal cases"
  27. @echo "make test10 normal cases"
  28. testall: | $(TESTS)
  29. ${TESTS}: test%: $(TARGET) | environment
  30. @echo '***************************************'
  31. @echo "test$*"
  32. @echo '***************************************'
  33. ./$(TARGET) inputs/input$* outputs/output$* > debug_files/debug$*
  34. diff expected/output$* outputs/output$*
  35. $(VALGRIND) --log-file=outputs/memoutput$* ./$(TARGET) inputs/input$* outputs/output$* > /dev/null
  36. @echo
  37. @bin/valgrind-checker.sh outputs/memoutput$*
  38. @echo
  39. environment:
  40. @mkdir -p outputs
  41. @mkdir -p debug_files
  42. .c.o:
  43. $(GCC) $(CFLAGS) -c $*.c
  44. clean:
  45. rm -f $(TARGET) $(OBJS) outputs/output* outputs/memoutput* debug_files/*