Browse Source

Adds a Makefile to produce distribution

Yann Weber 11 months ago
parent
commit
e870190ae8
1 changed files with 39 additions and 0 deletions
  1. 39
    0
      Makefile

+ 39
- 0
Makefile View File

@@ -0,0 +1,39 @@
1
+VERSION=1.1
2
+NAME=shcheck
3
+
4
+CHECKS=$(wildcard checks/*.sh)
5
+DIST=$(NAME).sh
6
+DIST_EXAMPLE=$(NAME)_example.sh
7
+PKG=$(NAME)-$(VERSION)
8
+PKG_GZ=$(PKG).tar.gz
9
+PKG_BZ2=$(PKG).tar.bz2
10
+PKGS=$(PKG_GZ) $(PKG_BZ2)
11
+
12
+all: lint
13
+
14
+$(PKGS): $(DIST) $(DIST_EXAMPLE) README
15
+	tar --xform='s|^|./$(NAME)-$(VERSION)/|' -acvf "$@" $^
16
+
17
+$(DIST).bz2: $(DIST)
18
+	tar -acvf 
19
+
20
+$(DIST_EXAMPLE): example.sh
21
+	sed 's|^\. \./check.sh$$|. ./$(DIST)|' < $^ > $@; \
22
+		chmod +x $@; \
23
+		$(MAKE) lint_dist
24
+
25
+$(DIST): check.sh $(CHECKS)
26
+	grep -Ev '^\. \./checks/.*\.sh$$' > $@ < $<; \
27
+		cat $(CHECKS) | grep -v '^#' >> $@;
28
+
29
+lint_dist: $(DIST) $(DIST_EXAMPLE)
30
+	shellcheck $^
31
+
32
+lint: example.sh check.sh $(CHECKS)
33
+	shellcheck -x example.sh check.sh && \
34
+		[ -f "$(DIST)" ] && $(MAKE) lint_dist
35
+
36
+.PHONY: clean
37
+
38
+clean:
39
+	-rm -vf $(DIST) $(DIST_EXAMPLE) $(PKGS)

Loading…
Cancel
Save