-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
62 lines (51 loc) · 1.44 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
name = ionosphere
config = config/config.yml
ifndef $(GOPATH)
GOPATH=$(shell go env GOPATH)
export GOPATH
endif
define build_arch
$(1) go build -o bin/$(2)/ionosphere main.go
mkdir bin/$(2)/config
mkdir bin/$(2)/logs
touch bin/$(2)/logs/PLACEHOLDER
cp $(config) bin/$(2)/$(config)
cp README.md bin/$(2)/README.md
cp LICENSE bin/$(2)/LICENSE.md
endef
define tarball_distro
tar -zcvf $(1).tar.gz $(1)/
endef
define zip_distro
zip -r $(1).zip $(1)/
endef
test:
go test ./... -v
build:
GOOS=linux GOARCH=amd64 go build -o bin/$(linuxamd64)/ionosphere main.go
run:
go run main.go
clean:
rm -rf ./bin
macosarm64 = $(name)-macos-arm64
macosamd64 = $(name)-macos-amd64
linuxamd64 = $(name)-linux-amd64
freebsdamd64 = $(name)-freebsd-amd64
raspberrypi = $(name)-raspberry-pi
windowsamd64 = $(name)-windows-amd64
.ONESHELL:
compile:
rm -rf ./bin
$(call build_arch,GOOS=darwin GOARCH=amd64,$(macosamd64))
$(call build_arch,GOOS=darwin GOARCH=arm64,$(macosarm64))
$(call build_arch,GOOS=linux GOARCH=amd64,$(linuxamd64))
$(call build_arch,GOOS=linux GOARCH=arm GOARM=5,$(raspberrypi))
$(call build_arch,GOOS=freebsd GOARCH=amd64,$(freebsdamd64))
$(call build_arch,GOOS=windows GOARCH=amd64,$(windowsamd64))
cd bin/
$(call tarball_distro,$(macosamd64))
$(call tarball_distro,$(macosarm64))
$(call tarball_distro,$(linuxamd64))
$(call tarball_distro,$(raspberrypi))
$(call tarball_distro,$(freebsdamd64))
$(call zip_distro,$(windowsamd64))