-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
48 lines (40 loc) · 1.35 KB
/
Makefile
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
# Example Makefile
# Variables
VERSION := $(shell head -n 1 VERSION.txt)
DATE := $(shell date +%F)
DOCS := README.md INTERNALS.md HOOKS.md VERSION.txt
BIN_FILES := bin/grade
LIBEXEC_FILES := libexec/add_grade libexec/print_grade libexec/grade_utils.py libexec/grade_hooks
MAN_PAGE_MD := share/man/man1/grade.1.md
MAN_PAGE := share/man/man1/grade.1
MAN_PAGE_BUILD := pandoc -s -f markdown -t man <(sed "s/@DATE/$(DATE)/g; s/@VERSION/$(VERSION)/g" $(MAN_PAGE_MD)) -o $(MAN_PAGE)
DESTDIR ?= /
DIST_DIR := grade-$(VERSION)
distrib: DESTDIR := $(DIST_DIR)
TARBALL := $(DIST_DIR).tar.gz
# Default target
all: $(MAN_PAGE) $(SCRIPTS)
# Generate man page from markdown
$(MAN_PAGE): $(MAN_PAGE_MD)
$(MAN_PAGE_BUILD)
# Install target
install:
mkdir -p $(DESTDIR)/bin $(DESTDIR)/libexec
-@[ -f $(MAN_PAGE) ] || $(MAN_PAGE_BUILD)
@[ -f $(MAN_PAGE) ] && install -D -m 644 $(MAN_PAGE) $(DESTDIR)/$(MAN_PAGE)
@[ -f $(MAN_PAGE) ] || echo "Man page generation failed (probably due to missing pandoc)"
cp $(BIN_FILES) $(DESTDIR)/bin
cp -r $(LIBEXEC_FILES) $(DESTDIR)/libexec
# Distrib target
distrib: install
cp -r test Makefile $(DOCS) $(DESTDIR)
cp $(MAN_PAGE_MD) $(DESTDIR)/$(MAN_PAGE_MD)
tar -czf $(TARBALL) $(DESTDIR)
test:
test/test.sh
# Clean target
clean:
rm -f $(MAN_PAGE) $(TARBALL)
rm -rf $(DIST_DIR)
@echo "Clean complete."
.PHONY: all distrib install clean test