-
-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathMakefile
66 lines (53 loc) · 1.77 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
GOCMD=go
BINARY?=gitin
GITIN_SOURCE_DIR=cmd/gitin/main.go
GITIN_BUILD_FLAGS=--tags static
GITIN_DIR:=$(dir $(realpath $(lastword $(MAKEFILE_LIST))))
GOPATH_DIR?=$(shell go env GOPATH | cut -d: -f1)
GOBIN_DIR:=$(GOPATH_DIR)/bin
GIT2GO_VERSION=33
PARENT_DIR=$(realpath $(GITIN_DIR)../)
GIT2GO_DIR:=$(PARENT_DIR)/git2go
LIBGIT2_DIR=$(GIT2GO_DIR)/vendor/libgit2
GIT2GO_PATCH=patch/git2go.v$(GIT2GO_VERSION).patch
all: $(BINARY)
$(BINARY): build-libgit2
$(GOCMD) build $(GITIN_BUILD_FLAGS) -o $(BINARY) $(GITIN_SOURCE_DIR)
.PHONY: build-only
build-only:
make -C $(GIT2GO_DIR) install-static
$(GOCMD) build $(GITIN_BUILD_FLAGS) -o $(BINARY) $(GITIN_SOURCE_DIR)
.PHONY: build-libgit2
build-libgit2: apply-patches
make -C $(GIT2GO_DIR) install-static
.PHONY: install
install: $(BINARY)
install -m755 -d $(GOBIN_DIR)
install -m755 $(BINARY) $(GOBIN_DIR)
.PHONY: update
update: check-git2go
git clone https://github.com/libgit2/git2go.git $(GIT2GO_DIR)
cd $(GIT2GO_DIR) && git checkout v30.0.9
cd $(GIT2GO_DIR) && git submodule -q foreach --recursive git reset -q --hard
cd $(GIT2GO_DIR) && git submodule update --init --recursive
check-git2go:
@if [ "$(GITIN_FORCE_INSTALL)" == "YES" ]; then \
echo "removing by force"; \
rm -rf $(GIT2GO_DIR); \
elif [ -d "$(GIT2GO_DIR)" ]; then \
echo "$(GIT2GO_DIR) will be deleted, are you sure? [y/N] " && read ans && [ $${ans:-N} = y ]; \
if [ $$ans = y ] || [ $$ans = Y ] ; then \
rm -rf $(GIT2GO_DIR); \
fi; \
fi; \
.PHONY: apply-patches
apply-patches: update
if patch --dry-run -N -d $(GIT2GO_DIR) -p1 < $(GIT2GO_PATCH) >/dev/null; then \
patch -d $(GIT2GO_DIR) -p1 < $(GIT2GO_PATCH); \
fi
.PHONY: static
static: build-libgit2
$(GOCMD) build $(GITIN_BUILD_FLAGS) -o $(BINARY) $(GITIN_SOURCE_DIR)
.PHONY: clean
clean:
rm -f $(BINARY)