File size: 1,989 Bytes
079c32c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
PYTHON := $(shell which python)

SOURCE         ?= .
PYTHON_DEMOS   := $(shell find ${SOURCE} -name *.demo.py)
PYTHON_DEMOXS  := $(shell find ${SOURCE} -name *.demox.py)
PYTHON_RESULTS := $(addsuffix .py.txt, $(basename ${PYTHON_DEMOS} ${PYTHON_DEMOXS}))

SHELL_DEMOS    := $(shell find ${SOURCE} -name *.demo.sh)
SHELL_DEMOXS   := $(shell find ${SOURCE} -name *.demox.sh)
SHELL_RESULTS  := $(addsuffix .sh.txt, $(basename ${SHELL_DEMOS} ${SHELL_DEMOXS}))

%.demo.py.txt: %.demo.py
	cd "$(shell dirname $(shell readlink -f $<))" && \
		PYTHONPATH="$(shell dirname $(shell readlink -f $<)):${PYTHONPATH}" \
		$(PYTHON) "$(shell readlink -f $<)" > "$(shell readlink -f $@)"

%.demox.py.txt: %.demox.py
	cd "$(shell dirname $(shell readlink -f $<))" && \
		PYTHONPATH="$(shell dirname $(shell readlink -f $<)):${PYTHONPATH}" \
		$(PYTHON) "$(shell readlink -f $<)" 1> "$(shell readlink -f $@)" \
		2> "$(shell readlink -f $(addsuffix .err, $(basename $@)))"; \
		echo $$? > "$(shell readlink -f $(addsuffix .exitcode, $(basename $@)))"

%.demo.sh.txt: %.demo.sh
	cd "$(shell dirname $(shell readlink -f $<))" && \
		PYTHONPATH="$(shell dirname $(shell readlink -f $<)):${PYTHONPATH}" \
		$(SHELL) "$(shell readlink -f $<)" > "$(shell readlink -f $@)"

%.demox.sh.txt: %.demox.sh
	cd "$(shell dirname $(shell readlink -f $<))" && \
		PYTHONPATH="$(shell dirname $(shell readlink -f $<)):${PYTHONPATH}" \
		$(SHELL) "$(shell readlink -f $<)" 1> "$(shell readlink -f $@)" \
		2> "$(shell readlink -f $(addsuffix .err, $(basename $@)))"; \
		echo $$? > "$(shell readlink -f $(addsuffix .exitcode, $(basename $@)))"

build: ${PYTHON_RESULTS} ${SHELL_RESULTS}

all: build

clean:
	rm -rf \
		$(shell find ${SOURCE} -name *.py.txt) \
		$(shell find ${SOURCE} -name *.py.err) \
		$(shell find ${SOURCE} -name *.py.exitcode) \
		$(shell find ${SOURCE} -name *.sh.txt) \
		$(shell find ${SOURCE} -name *.sh.err) \
		$(shell find ${SOURCE} -name *.sh.exitcode) \
		$(shell find ${SOURCE} -name *.dat.*)