-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathMakefile
93 lines (76 loc) · 3.23 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
GIT_VERSION=$(shell git describe --tags | sed s/-g/+g/g | sed s/-/~/g)
TARGET_DIR=./BUILD
NFPM_VERSION = 2.10.0
# This uses the somewhat confusing but standardized GNU architecture naming
# scheme to be consistent with Debian (which can handle the complex case of
# building compilers for different architectures). Build refers to the
# architecure of the platform doing this build. Host refers to the architecture
# we are building the binary to run on. Target refers to the architecture that
# built binary emits, if it's a compiler.
BUILD_ARCH=$(shell uname -m)
ifeq ($(BUILD_ARCH),aarch64)
NFPM_ARCH=arm64
else ifeq ($(BUILD_ARCH),x86_64)
NFPM_ARCH=x86_64
else
$(error Unsupported build platform arch $(BUILD_ARCH))
endif
all: build package
.PHONY: all build package \
build_common_models build_webgui build_webadmin build_arm64 build_x86_64 \
package_arm64 packagex86_64 \
test test_webgui \
get_nfpm install_apt_deps install_deps \
clean
# Define the basic build and package targets for the native build architecture.
ifeq ($(BUILD_ARCH),aarch64)
build: build_arm64
package: package_arm64
else ifeq ($(BUILD_ARCH),x86_64)
build: build_x86_64
package: package_x86_64
else
$(error Unsupported build platform architecture $(BUILD_ARCH))
endif
build_common_models:
cd colte-common-models; npm ci
build_webgui: build_common_models
cd webgui; rm -rf node_modules; rm package-lock.json; npm i; npm ci
build_webadmin: build_common_models
cd webadmin; rm -rf node_modules; rm package-lock.json; npm i; npm ci
build_arm64 build_x86_64: build_webgui build_webadmin
package_arm64: export HOST_ARCHITECTURE=arm64
package_arm64: build_arm64 get_nfpm
package_x86_64: export HOST_ARCHITECTURE=amd64
package_x86_64: build_x86_64 get_nfpm
package_arm64 package_x86_64: export VERSION := $(GIT_VERSION)
package_arm64 package_x86_64:
mkdir -p $(TARGET_DIR)
cat nfpm-colte.yaml | \
envsubst '$${HOST_ARCHITECTURE} $${VERSION} $${DISTRO_RELEASE_VERSION}' | \
$(TARGET_DIR)/nfpm/nfpm pkg --packager deb --config /dev/stdin --target $(TARGET_DIR)
cat nfpm-colte-cn-4g.yaml | \
envsubst '$${HOST_ARCHITECTURE} $${VERSION} $${DISTRO_RELEASE_VERSION}' | \
$(TARGET_DIR)/nfpm/nfpm pkg --packager deb --config /dev/stdin --target $(TARGET_DIR)
cat nfpm-colte-prepaid.yaml | \
envsubst '$${HOST_ARCHITECTURE} $${VERSION} $${DISTRO_RELEASE_VERSION}' | \
$(TARGET_DIR)/nfpm/nfpm pkg --packager deb --config /dev/stdin --target $(TARGET_DIR)
cat nfpm-colte-essential.yaml | \
envsubst '$${HOST_ARCHITECTURE} $${VERSION} $${DISTRO_RELEASE_VERSION}' | \
$(TARGET_DIR)/nfpm/nfpm pkg --packager deb --config /dev/stdin --target $(TARGET_DIR)
test: test_webgui
test_webgui: build_webgui
cd webgui; npm run test
clean:
rm -rf $(TARGET_DIR)
rm -rf webadmin/node_modules
rm -rf webguid/node_modules
rm -rf colte-common-models/node_modules
# Helper rules for installing build dependencies and tooling.
get_nfpm: $(TARGET_DIR)/nfpm/nfpm
$(TARGET_DIR)/nfpm/nfpm:
mkdir -p $(@D)
curl -L https://github.com/goreleaser/nfpm/releases/download/v$(NFPM_VERSION)/nfpm_$(NFPM_VERSION)_Linux_$(NFPM_ARCH).tar.gz | tar -xz --directory "$(TARGET_DIR)/nfpm"
install_apt_deps:
apt-get install --yes build-essential default-mysql-client default-mysql-server nodejs npm curl
install_deps: install_apt_deps get_nfpm