|
1 |
| -examples: minimal basic modern animation nonblock xkcd quiver bar surface fill_inbetween fill update imshow |
2 | 1 |
|
3 |
| -minimal: examples/minimal.cpp matplotlibcpp.h |
4 |
| - cd examples && g++ -DWITHOUT_NUMPY minimal.cpp -I/usr/include/python2.7 -lpython2.7 -o minimal -std=c++11 |
| 2 | +# Use C++11 |
| 3 | +CXXFLAGS += -std=c++11 |
5 | 4 |
|
6 |
| -basic: examples/basic.cpp matplotlibcpp.h |
7 |
| - cd examples && g++ basic.cpp -I/usr/include/python2.7 -lpython2.7 -o basic -std=c++11 |
| 5 | +# Default to using system's default version of python |
| 6 | +PYTHON_BIN ?= python |
| 7 | +PYTHON_CONFIG := $(PYTHON_BIN)-config |
| 8 | +PYTHON_INCLUDE ?= $(shell $(PYTHON_CONFIG) --includes) |
| 9 | +CXXFLAGS += $(PYTHON_INCLUDE) |
| 10 | +LDFLAGS += $(shell $(PYTHON_CONFIG) --libs) |
8 | 11 |
|
9 |
| -modern: examples/modern.cpp matplotlibcpp.h |
10 |
| - cd examples && g++ modern.cpp -I/usr/include/python2.7 -lpython2.7 -o modern -std=c++11 |
| 12 | +# Either finds numpy or set -DWITHOUT_NUMPY |
| 13 | +CURRENT_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) |
| 14 | +CXXFLAGS += $(shell $(PYTHON_BIN) $(CURRENT_DIR)/numpy_flags.py) |
11 | 15 |
|
12 |
| -animation: examples/animation.cpp matplotlibcpp.h |
13 |
| - cd examples && g++ animation.cpp -I/usr/include/python2.7 -lpython2.7 -o animation -std=c++11 |
| 16 | +# Assume every *.cpp file is a separate example |
| 17 | +SOURCES ?= $(wildcard examples/*.cpp) |
| 18 | +EXECUTABLES := $(foreach exec,$(basename $(SOURCES)),$(exec)) |
14 | 19 |
|
15 |
| -nonblock: examples/nonblock.cpp matplotlibcpp.h |
16 |
| - cd examples && g++ nonblock.cpp -I/usr/include/python2.7 -lpython2.7 -o nonblock -std=c++11 |
| 20 | +.PHONY: examples |
17 | 21 |
|
18 |
| -quiver: examples/quiver.cpp matplotlibcpp.h |
19 |
| - cd examples && g++ quiver.cpp -I/usr/include/python2.7 -lpython2.7 -o quiver -std=c++11 |
20 |
| - |
21 |
| -xkcd: examples/xkcd.cpp matplotlibcpp.h |
22 |
| - cd examples && g++ xkcd.cpp -I/usr/include/python2.7 -lpython2.7 -o xkcd -std=c++11 |
23 |
| - |
24 |
| -bar: examples/bar.cpp matplotlibcpp.h |
25 |
| - cd examples && g++ bar.cpp -I/usr/include/python2.7 -lpython2.7 -o bar -std=c++11 |
26 |
| - |
27 |
| -surface: examples/surface.cpp matplotlibcpp.h |
28 |
| - cd examples && g++ surface.cpp -I/usr/include/python2.7 -lpython2.7 -o surface -std=c++11 |
29 |
| - |
30 |
| -fill_inbetween: examples/fill_inbetween.cpp matplotlibcpp.h |
31 |
| - cd examples && g++ fill_inbetween.cpp -I/usr/include/python2.7 -lpython2.7 -o fill_inbetween -std=c++11 |
32 |
| - |
33 |
| -fill: examples/fill.cpp matplotlibcpp.h |
34 |
| - cd examples && g++ fill.cpp -I/usr/include/python2.7 -lpython2.7 -o fill -std=c++11 |
35 |
| - |
36 |
| -update: examples/update.cpp matplotlibcpp.h |
37 |
| - cd examples && g++ update.cpp -I/usr/include/python2.7 -lpython2.7 -o update -std=c++11 |
38 |
| - |
39 |
| -imshow: examples/imshow.cpp matplotlibcpp.h |
40 |
| - cd examples && g++ imshow.cpp -I/usr/include/python2.7 -lpython2.7 -o imshow -std=c++11 |
| 22 | +examples: $(EXECUTABLES) |
41 | 23 |
|
42 | 24 | clean:
|
43 |
| - rm -f examples/{minimal,basic,modern,animation,nonblock,xkcd,quiver,bar,surface,fill_inbetween,fill,update,imshow} |
| 25 | + rm -f ${EXECUTABLES} |
0 commit comments