Makefile 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Use C++11
  2. MATPLOTLIBCPP_CXXFLAGS = -std=c++11
  3. # Default to using system's default version of python
  4. PYTHON_BIN := python
  5. PYTHON_CONFIG := $(PYTHON_BIN)-config
  6. PYTHON_INCLUDE ?= $(shell $(PYTHON_CONFIG) --includes)
  7. MATPLOTLIBCPP_CXXFLAGS += $(PYTHON_INCLUDE)
  8. MATPLOTLIBCPP_LDFLAGS += $(shell $(PYTHON_CONFIG) --libs)
  9. # If these checks have false positives, please remove this check and file a github issue.
  10. $(if $(PYTHON_INCLUDE),,$(error \
  11. Could not auto-detect python development headers. \
  12. Please install python-dev or similar, or manually \
  13. specify PYTHON_INCLUDE=...))
  14. # If we have to add 1-2 more of these checks, I'll probably eventually bite the
  15. # bullet and switch to cmake/autoconf.
  16. test_matplotlib != $(PYTHON_BIN) -c 'import matplotlib'
  17. WITH_MATPLOTLIB = $(.SHELLSTATUS)
  18. $(ifeq $(WITH
  19. # Either finds numpy or set -DWITHOUT_NUMPY
  20. MATPLOTLIBCPP_CXXFLAGS += $(shell $(PYTHON_BIN) $(CURDIR)/numpy_flags.py)
  21. WITHOUT_NUMPY := $(findstring $(CXXFLAGS), WITHOUT_NUMPY)
  22. # Examples requiring numpy support to compile
  23. EXAMPLES_NUMPY := surface
  24. EXAMPLES := minimal basic modern animation nonblock xkcd quiver bar fill_inbetween fill update subplot2grid \
  25. $(if WITHOUT_NUMPY,,$(EXAMPLES_NUMPY))
  26. # Prefix every example with 'examples/build/'
  27. EXAMPLE_TARGETS := $(patsubst %,examples/build/%,$(EXAMPLES))
  28. .PHONY: examples
  29. examples: $(EXAMPLE_TARGETS)
  30. # Assume every *.cpp file is a separate example
  31. $(EXAMPLE_TARGETS): examples/build/%: examples/%.cpp
  32. mkdir -p examples/build
  33. $(CXX) -o $@ $< $(MATPLOTLIBCPP_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) $(MATPLOTLIBCPP_LDFLAGS)
  34. clean:
  35. rm -f ${EXAMPLE_TARGETS}
  36. install:
  37. cp matplotlibcpp.h $(DESTDIR)$(PREFIX)/include/matplotlibcpp.h