-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathexamples.mk
41 lines (34 loc) · 1.27 KB
/
examples.mk
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
# Get the path to this file from wherever it is included.
# See https://stackoverflow.com/questions/18136918/how-to-get-current-relative-directory-of-your-makefile
MCCOLE:=$(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/lib/mccole)
# How to reformat output.
COLUMNS:=68
REFORMAT:=python ${MCCOLE}/bin/reformat.py --home /sdx --columns ${COLUMNS}
# The including file must define a variable TARGETS with the names of everything
# to be created.
all: ${TARGETS}
# Show the targets defined by the including file.
targets:
@echo ${TARGETS}
# Create HTML or text from a shell script that runs some Python.
# Normally used when there are parameters to the Python file but no extra
# dependencies.
%.html: %.sh %.py
bash $< 2>&1 | ${REFORMAT} > $@
%.out: %.sh %.py
bash $< 2>&1 | ${REFORMAT} > $@
# Create HTML or text when there is only a shell script.
# Normally used when the output depends on multiple .py files, in which case the
# including file must define dependencies.
%.html: %.sh
bash $< 2>&1 | ${REFORMAT} > $@
%.out: %.sh
bash $< 2>&1 | ${REFORMAT} > $@
# Create HTML or text by running Python without parameters.
%.html: %.py
python $< 2>&1 | ${REFORMAT} > $@
%.out: %.py
python $< 2>&1 | ${REFORMAT} > $@
# Get rid of all generated files.
erase:
rm -f ${TARGETS}