From e1fad581791a1dff7bd141f8a63f8d8fad16d527 Mon Sep 17 00:00:00 2001 From: Benno Evers Date: Fri, 31 Jan 2020 19:05:24 +0100 Subject: [PATCH] WIP: install target --- Makefile | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 4faeb0e..02a8412 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,28 @@ # Use C++11 -CXXFLAGS += -std=c++11 +MATPLOTLIBCPP_CXXFLAGS = -std=c++11 # Default to using system's default version of python -PYTHON_BIN ?= python -PYTHON_CONFIG := $(PYTHON_BIN)-config -PYTHON_INCLUDE ?= $(shell $(PYTHON_CONFIG) --includes) -CXXFLAGS += $(PYTHON_INCLUDE) -LDFLAGS += $(shell $(PYTHON_CONFIG) --libs) +PYTHON_BIN := python +PYTHON_CONFIG := $(PYTHON_BIN)-config +PYTHON_INCLUDE ?= $(shell $(PYTHON_CONFIG) --includes) +MATPLOTLIBCPP_CXXFLAGS += $(PYTHON_INCLUDE) +MATPLOTLIBCPP_LDFLAGS += $(shell $(PYTHON_CONFIG) --libs) + +# If these checks have false positives, please remove this check and file a github issue. +$(if $(PYTHON_INCLUDE),,$(error \ +Could not auto-detect python development headers. \ +Please install python-dev or similar, or manually \ +specify PYTHON_INCLUDE=...)) + +# If we have to add 1-2 more of these checks, I'll probably eventually bite the +# bullet and switch to cmake/autoconf. +test_matplotlib != $(PYTHON_BIN) -c 'import matplotlib' +WITH_MATPLOTLIB = $(.SHELLSTATUS) +$(ifeq $(WITH # Either finds numpy or set -DWITHOUT_NUMPY -CXXFLAGS += $(shell $(PYTHON_BIN) $(CURDIR)/numpy_flags.py) -WITHOUT_NUMPY := $(findstring $(CXXFLAGS), WITHOUT_NUMPY) +MATPLOTLIBCPP_CXXFLAGS += $(shell $(PYTHON_BIN) $(CURDIR)/numpy_flags.py) +WITHOUT_NUMPY := $(findstring $(CXXFLAGS), WITHOUT_NUMPY) # Examples requiring numpy support to compile EXAMPLES_NUMPY := surface @@ -27,7 +39,10 @@ examples: $(EXAMPLE_TARGETS) # Assume every *.cpp file is a separate example $(EXAMPLE_TARGETS): examples/build/%: examples/%.cpp mkdir -p examples/build - $(CXX) -o $@ $< $(CXXFLAGS) $(LDFLAGS) + $(CXX) -o $@ $< $(MATPLOTLIBCPP_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) $(MATPLOTLIBCPP_LDFLAGS) clean: rm -f ${EXAMPLE_TARGETS} + +install: + cp matplotlibcpp.h $(DESTDIR)$(PREFIX)/include/matplotlibcpp.h