-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
39 lines (27 loc) · 839 Bytes
/
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
PREFIX = /usr/local/
SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
libPath = $(SELF_DIR)lib/
importBin = $(abspath $(libPath)import)
shPath = $(SELF_DIR)src/sh/
goSrcDir = $(SELF_DIR)src/go/initsh/
goCmdDir = $(goSrcDir)cmd/
binPath = $(SELF_DIR)/bin/
repoGoSrcs = $(wildcard $(goSrcDir)*.go $(goCmdDir)*.go)
repoBins = $(wildcard $(binPath)*)
repoShells = $(wildcard $(shPath)*)
sysBinDir = $(PREFIX)bin/
shebangs = $(patsubst $(binPath)%,$(sysBinDir)%,$(repoBins))
.PHONY: clean install
$(importBin): $(libPath) $(goCmdDir) $(repoGoSrcs)
cd $(goCmdDir) && go build -o $(importBin)
$(libPath):
mkdir -p $(libPath)
install: $(shebangs)
$(sysBinDir)%: $(binPath)% $(sysBinDir)
test -e $@ && rm $@ || true
test -L $@ && unlink $@ || true
ln -s ${CURDIR}/$< $@
$(sysBinDir):
mkdir -p $(sysBinDir)
clean:
rm -r $(libPath)