Makefile 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Use C++11, dont warn on long-to-float conversion
  2. CXXFLAGS += -std=c++11 -Wno-conversion
  3. # Default to using system's default version of python
  4. PYTHON_BIN ?= python3
  5. PYTHON_CONFIG := $(PYTHON_BIN)-config
  6. PYTHON_INCLUDE ?= $(shell $(PYTHON_CONFIG) --includes)
  7. EXTRA_FLAGS := $(PYTHON_INCLUDE)
  8. # NOTE: Since python3.8, the correct invocation is `python3-config --libs --embed`.
  9. # So of course the proper way to get python libs for embedding now is to
  10. # invoke that, check if it crashes, and fall back to just `--libs` if it does.
  11. LDFLAGS += $(shell if $(PYTHON_CONFIG) --ldflags --embed >/dev/null; then $(PYTHON_CONFIG) --ldflags --embed; else $(PYTHON_CONFIG) --ldflags; fi)
  12. # Either finds numpy or set -DWITHOUT_NUMPY
  13. EXTRA_FLAGS += $(shell $(PYTHON_BIN) $(CURDIR)/numpy_flags.py)
  14. WITHOUT_NUMPY := $(findstring $(EXTRA_FLAGS), WITHOUT_NUMPY)
  15. # Examples requiring numpy support to compile
  16. EXAMPLES_NUMPY := surface colorbar
  17. EXAMPLES := minimal basic modern animation nonblock xkcd quiver bar \
  18. fill_inbetween fill update subplot2grid lines3d \
  19. $(if $(WITHOUT_NUMPY),,$(EXAMPLES_NUMPY))
  20. # Prefix every example with 'examples/build/'
  21. EXAMPLE_TARGETS := $(patsubst %,examples/build/%,$(EXAMPLES))
  22. .PHONY: examples
  23. examples: $(EXAMPLE_TARGETS)
  24. docs:
  25. doxygen
  26. moxygen doc/xml --noindex -o doc/api.md
  27. # Assume every *.cpp file is a separate example
  28. $(EXAMPLE_TARGETS): examples/build/%: examples/%.cpp matplotlibcpp.h
  29. mkdir -p examples/build
  30. $(CXX) -o $@ $< $(EXTRA_FLAGS) $(CXXFLAGS) $(LDFLAGS)
  31. clean:
  32. rm -f ${EXAMPLE_TARGETS}