GNUmakefile 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
  2. ALL_TARGETS := all base check install preinstall package rpm clean tutorial example
  3. MAKE_FILE := Makefile
  4. DEFAULT_BUILD_DIR := build
  5. BUILD_DIR := $(shell if [ -f $(MAKE_FILE) ]; then echo "."; else echo $(DEFAULT_BUILD_DIR); fi)
  6. CMAKE3 := $(shell if which cmake3>/dev/null ; then echo cmake3; else echo cmake; fi;)
  7. .PHONY: $(ALL_TARGETS)
  8. all: base
  9. make -C $(BUILD_DIR) -f Makefile
  10. base:
  11. make -C workflow
  12. mkdir -p $(BUILD_DIR)
  13. ifeq ($(DEBUG),y)
  14. cd $(BUILD_DIR) && $(CMAKE3) -D CMAKE_BUILD_TYPE=Debug $(ROOT_DIR)
  15. else ifneq ("${INSTALL_PREFIX}install_prefix", "install_prefix")
  16. cd $(BUILD_DIR) && $(CMAKE3) -DCMAKE_INSTALL_PREFIX:STRING=${INSTALL_PREFIX} $(ROOT_DIR)
  17. else
  18. cd $(BUILD_DIR) && $(CMAKE3) $(ROOT_DIR)
  19. endif
  20. tutorial: all
  21. make -C tutorial
  22. example: all
  23. make -C example
  24. check: all
  25. make -C test check
  26. install preinstall package: base
  27. mkdir -p $(BUILD_DIR)
  28. cd $(BUILD_DIR) && $(CMAKE3) $(ROOT_DIR)
  29. make -C $(BUILD_DIR) -f Makefile $@
  30. rpm: package
  31. ifneq ($(BUILD_DIR),.)
  32. mv $(BUILD_DIR)/*.rpm ./
  33. endif
  34. clean:
  35. ifeq (build, $(wildcard build))
  36. -make -C build clean
  37. endif
  38. -make -C workflow clean
  39. -make -C test clean
  40. -make -C benchmark clean
  41. -make -C example clean
  42. -make -C tutorial clean
  43. rm -rf $(DEFAULT_BUILD_DIR)
  44. rm -rf _include
  45. rm -rf _lib
  46. rm -rf _bin
  47. rm -f SRCINFO SRCNUMVER SRCVERSION
  48. rm -f ./*.rpm
  49. rm -f src/message/*.pb.h src/message/*.pb.cc
  50. find . -name CMakeCache.txt | xargs rm -f
  51. find . -name Makefile | xargs rm -f
  52. find . -name "*.cmake" | xargs rm -f
  53. find . -name CMakeFiles | xargs rm -rf