makefile 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. SHELL = /bin/bash
  2. # Variables used for compiling sources
  3. INC =$(wildcard inc/*.hpp)
  4. SRC =$(wildcard src/*.cpp)
  5. TSC =$(wildcard test/*.cpp)
  6. OBJ =$(SRC:src/%.cpp=obj/%.o)
  7. TST =$(TSC:test/%.cpp=bin/test-%)
  8. CC = g++-8
  9. LLVMOOPT=$(shell llvm-config --cxxflags)
  10. LLVMLOPT=$(shell llvm-config --ldflags --system-libs --link-static --libs x86codegen)
  11. OOPT =$(LLVMOOPT) -Iinc -std=gnu++17 -g -c -D__ALIOTH_DEBUG__
  12. LOPT =$(LLVMLOPT) -lpthread
  13. TOPT =$(shell llvm-config --cxxflags --ldflags --system-libs --link-static --libs x86codegen) -Iinc -std=gnu++17 -g
  14. TARGET = bin/alioth
  15. # link all object files to compiler
  16. $(TARGET):$(OBJ)
  17. $(CC) $(OBJ) $(LOPT) -o $@
  18. # compile every single source code document to object file
  19. $(OBJ):obj/%.o:src/%.cpp $(INC)
  20. $(CC) $(OOPT) -o $@ $<
  21. # test target
  22. test: $(TST)
  23. # compile all test units
  24. $(TST):bin/test-%:test/%.cpp
  25. $(CC) $< $(TOPT) -o $@
  26. # copy all configuration files to root .
  27. # copy program to root path .
  28. # copy completion file to bash-completion folder .
  29. install: $(TARGET) ./doc/alioth
  30. sudo cp doc/*.json /usr/lib/alioth/doc/
  31. sudo cp $(TARGET) /usr/bin/
  32. sudo cp ./doc/alioth /usr/share/bash-completion/completions/
  33. # initial project structure
  34. init:
  35. if ! [ -e obj ]; then mkdir obj; fi
  36. if ! [ -e bin ]; then mkdir bin; fi
  37. clean:
  38. rm -rf obj/*.o bin/*
  39. .PHONY: init clean install