-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
33 lines (26 loc) · 859 Bytes
/
Makefile
File metadata and controls
33 lines (26 loc) · 859 Bytes
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
TARGET_FILE = "dru"
PRJ_SRC = "${PWD}/src/main.sh"
PRJ_LIB = $(shell find -L lib -type f -name "*sh")
VERSION = $(shell git tag | tail -n1 | sed -e 's/^v//')
export PRJ_LIB
SHELL := /bin/bash
all: define_main add_dependencies invoke_main
define_main:
echo -e "#!/usr/bin/env bash\n" > ${TARGET_FILE}
echo -e "VERSION=${VERSION}\n" >> ${TARGET_FILE}
echo -e "function main() {\n" >> ${TARGET_FILE}
cat "${PRJ_SRC}" | sed -e 's/^/ /g' >> ${TARGET_FILE}
echo -e "\n}\n" >> ${TARGET_FILE}
invoke_main:
echo "main \$$@" >> ${TARGET_FILE}
add_dependencies:
for filename in $${PRJ_LIB[*]}; do cat $${filename} >> ${TARGET_FILE}; echo >> ${TARGET_FILE}; done
test:
cd spec; \
for filename in ./*; do \
bash $$filename; \
if [[ $$? -ne 0 ]]; then \
echo "Spec $$filename failed"; \
exit 1; \
fi; \
done && echo "All tests passed!"