makefile 739 B

1234567891011121314151617181920212223242526272829303132
  1. CXX=/usr/bin/g++
  2. CFLAGS=-g -Wall -pthread -std=c++11
  3. LFLAGS=-shared -Wl,--no-as-needed
  4. SRC_DIR=./src
  5. INC_DIR=./src
  6. BUILD_DIR=./build
  7. TF_CFLAGS=$(shell cat $(BUILD_DIR)/TF_CFLAGS)
  8. TF_LFLAGS=$(shell cat $(BUILD_DIR)/TF_LFLAGS)
  9. SRCS=$(wildcard $(SRC_DIR)/*.cpp)
  10. OBJS=$(patsubst $(SRC_DIR)/%.cpp,$(BUILD_DIR)/%.o,$(SRCS))
  11. EXECUTABLE=op_lib.so
  12. all: config $(BUILD_DIR)/$(EXECUTABLE)
  13. config:
  14. @if [ ! -d "$(BUILD_DIR)" ]; then ./configure $(BUILD_DIR) || exit 1; fi
  15. $(BUILD_DIR)/$(EXECUTABLE): $(OBJS)
  16. $(CXX) $(LFLAGS) $(TF_LFLAGS) -o $@ $^
  17. $(OBJS): $(BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp $(INC_DIR)/%.hpp
  18. $(CXX) $(CFLAGS) -fPIC -c $(TF_CFLAGS) -I$(INC_DIR) -o $@ $<
  19. tf_cflags:
  20. clean:
  21. rm -f $(BUILD_DIR)/*.o $(BUILD_DIR)/$(EXECUTABLE)