blob: 67b5ac35e1e8361ba2728c7a9b848b715c769f4a [file] [log] [blame]
Austin Schuhab802d52020-07-03 18:11:11 -07001# Use C++11, dont warn on long-to-float conversion
2CXXFLAGS += -std=c++11 -Wno-conversion
Austin Schuh6c8ec4c2018-01-23 11:18:57 -08003
Austin Schuhab802d52020-07-03 18:11:11 -07004# Default to using system's default version of python
5PYTHON_BIN ?= python3
6PYTHON_CONFIG := $(PYTHON_BIN)-config
7PYTHON_INCLUDE ?= $(shell $(PYTHON_CONFIG) --includes)
8EXTRA_FLAGS := $(PYTHON_INCLUDE)
9# NOTE: Since python3.8, the correct invocation is `python3-config --libs --embed`.
10# So of course the proper way to get python libs for embedding now is to
11# invoke that, check if it crashes, and fall back to just `--libs` if it does.
12LDFLAGS += $(shell if $(PYTHON_CONFIG) --ldflags --embed >/dev/null; then $(PYTHON_CONFIG) --ldflags --embed; else $(PYTHON_CONFIG) --ldflags; fi)
Austin Schuh6c8ec4c2018-01-23 11:18:57 -080013
Austin Schuhab802d52020-07-03 18:11:11 -070014# Either finds numpy or set -DWITHOUT_NUMPY
15EXTRA_FLAGS += $(shell $(PYTHON_BIN) $(CURDIR)/numpy_flags.py)
16WITHOUT_NUMPY := $(findstring $(EXTRA_FLAGS), WITHOUT_NUMPY)
Austin Schuh6c8ec4c2018-01-23 11:18:57 -080017
Austin Schuhab802d52020-07-03 18:11:11 -070018# Examples requiring numpy support to compile
19EXAMPLES_NUMPY := surface colorbar
20EXAMPLES := minimal basic modern animation nonblock xkcd quiver bar \
21 fill_inbetween fill update subplot2grid lines3d \
22 $(if $(WITHOUT_NUMPY),,$(EXAMPLES_NUMPY))
Austin Schuh6c8ec4c2018-01-23 11:18:57 -080023
Austin Schuhab802d52020-07-03 18:11:11 -070024# Prefix every example with 'examples/build/'
25EXAMPLE_TARGETS := $(patsubst %,examples/build/%,$(EXAMPLES))
Austin Schuh6c8ec4c2018-01-23 11:18:57 -080026
Austin Schuhab802d52020-07-03 18:11:11 -070027.PHONY: examples
Austin Schuh6c8ec4c2018-01-23 11:18:57 -080028
Austin Schuhab802d52020-07-03 18:11:11 -070029examples: $(EXAMPLE_TARGETS)
30
31docs:
32 doxygen
33 moxygen doc/xml --noindex -o doc/api.md
34
35# Assume every *.cpp file is a separate example
36$(EXAMPLE_TARGETS): examples/build/%: examples/%.cpp matplotlibcpp.h
37 mkdir -p examples/build
38 $(CXX) -o $@ $< $(EXTRA_FLAGS) $(CXXFLAGS) $(LDFLAGS)
Austin Schuh6c8ec4c2018-01-23 11:18:57 -080039
40clean:
Austin Schuhab802d52020-07-03 18:11:11 -070041 rm -f ${EXAMPLE_TARGETS}