makefile 773 B

1234567891011121314151617181920212223242526272829
  1. CXX=/usr/bin/g++
  2. FLAGS = -g -Wall -pthread -std=c++11
  3. TF_CFLAGS=$(shell python3 -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))' 2>/dev/null)
  4. TF_LFLAGS=$(shell python3 -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))' 2>/dev/null)
  5. SRC_DIR=.
  6. INC_DIR=.
  7. BUILD_DIR=.
  8. SRCS=$(wildcard $(SRC_DIR)/*.cpp)
  9. OBJS=$(patsubst $(SRC_DIR)/%.cpp,$(BUILD_DIR)/%.o,$(SRCS))
  10. EXECUTABLE=matMul.so
  11. all: dir $(BUILD_DIR)/$(EXECUTABLE)
  12. dir:
  13. mkdir -p $(BUILD_DIR)
  14. $(BUILD_DIR)/$(EXECUTABLE): $(OBJS)
  15. $(CXX) -shared $(TF_LFLAGS) -Wall -o $@ $^
  16. $(OBJS): $(BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp $(INC_DIR)/%.hpp
  17. $(CXX) $(FLAGS) -fPIC -c $(TF_CFLAGS) -I$(INC_DIR) -o $@ $< -O2
  18. clean:
  19. rm -f $(BUILD_DIR)/*.o $(BUILD_DIR)/$(EXECUTABLE)