-
Mark Meredith authoredMark Meredith authored
GNUmakefile 1.29 KiB
###
### Makefile for building libcsgeb.a with GNU Make.
### Only works with GCC compiler
### Expects to find paths for dependencies defined in: BOOST_HOME, CATCH2_HOME, CGAL_HOME, PEGTL_HOME
###
TARGET ?= libcsgeb.a
BUILD_DIR ?= ./build
SRCFILENAMES := csg.cpp \
levelset_2d.cpp \
levelset_3d.cpp \
matrix_functions.cpp \
parser.cpp \
exception.cpp \
$(if $(ENABLE_CGAL),cgal_helper_polygon.cpp,) \
$(if $(ENABLE_CGAL),cgal_helper_polyhedron.cpp,)
SRCS := $(SRCFILENAMES:%=./src/csg/%)
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
DEPS := $(OBJS:.o=.d)
INC_DIRS := src include
INC_DIRS += $(BOOST_HOME)/include
INC_DIRS += $(CATCH2_HOME)/include
INC_DIRS += $(CGAL_HOME)/include
INC_DIRS += $(PEGTL_HOME)/include
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
CPPFLAGS ?= $(INC_FLAGS) -MMD -MP
ifdef $(ENABLE_CGAL)
CPPFLAGS += -DUSE_CGAL
endif
$(TARGET): $(OBJS)
@ar rcs $(TARGET) $(OBJS)
$(BUILD_DIR)/$(TARGET): $(OBJS)
$(CXX) $(OBJS) -o $@ $(LDFLAGS)
$(BUILD_DIR)/%.cpp.o: %.cpp
$(MKDIR_P) $(dir $@)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -std=c++17 -c $< -o $@
.PHONY: install
install: $(TARGET)
@$(MKDIR_P) $(DESTDIR)/lib $(DESTDIR)/include
install -m 0755 $< $(DESTDIR)/lib
install -m 0755 include/*.hpp $(DESTDIR)/include
.PHONY: clean
clean:
$(RM) -r $(BUILD_DIR)
-include $(DEPS)
MKDIR_P ?= mkdir -p