-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
59 lines (42 loc) · 1.54 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
# Set up variables
APP_NAME := mtconvy
DIST_DIR := dist
ifeq (${OS},Windows_NT)
BUILD_TIME := $(shell date)
else
BUILD_TIME := $(shell date +"%Y-%m-%d %H:%M:%S")
endif
MODULE_NAME := $(shell go list)
APP_VERSION := $(file < VERSION)
APP_COMMIT := $(shell git rev-list -1 HEAD)
LD_FLAGS := "-X '${MODULE_NAME}/app.BuildVersion=${APP_VERSION}' -X '${MODULE_NAME}/app.BuildCommit=${APP_COMMIT}' -X '${MODULE_NAME}/app.BuildTime=${BUILD_TIME}'"
fn_GO_BUILD = GOOS=$(1) GOARCH=$(2) go build -o ${DIST_DIR}/$(3) -ldflags=${LD_FLAGS} main.go ;\
7z a ${DIST_DIR}/${APP_NAME}-${APP_VERSION}-$(4).7z -mx9 ./${DIST_DIR}/$(3) ./${DIST_DIR}/.mtconvy.yml
all: clean build-dist
.PHONY: build-dist
build-dist: build-linux64 build-linux32 build-windows32 build-windows64
rm -f ${DIST_DIR}/.mtconvy.yml
rm -f ${DIST_DIR}/${APP_NAME}
rm -f ${DIST_DIR}/${APP_NAME}.exe
sha256sum ${DIST_DIR}/*.7z > ${DIST_DIR}/checksums.sha256
.PHONY: build-windows32
build-windows32: clean ${DIST_DIR}
$(call fn_GO_BUILD,windows,386,${APP_NAME}.exe,win32)
.PHONY: build-windows64
build-windows64: clean ${DIST_DIR}
$(call fn_GO_BUILD,windows,amd64,${APP_NAME}.exe,win64)
.PHONY: build-linux32
build-linux32: clean ${DIST_DIR}
$(call fn_GO_BUILD,linux,386,${APP_NAME},linux32)
.PHONY: build-linux64
build-linux64: clean ${DIST_DIR}
$(call fn_GO_BUILD,linux,amd64,${APP_NAME},linux64)
${DIST_DIR}:
mkdir ${DIST_DIR}
cp ./.mtconvy.DEFAULT.yml ./${DIST_DIR}/.mtconvy.yml
.PHONY: version
version:
@echo Version from 'VERSION' file: ${APP_VERSION}
.PHONY: clean
clean:
rm -rf ${DIST_DIR}