1
0
forked from MTSR/mapserver
mapserver/Makefile

65 lines
1.6 KiB
Makefile
Raw Normal View History

2019-01-23 11:11:55 +03:00
OUT_DIR=output
2019-03-29 12:18:23 +03:00
VERSION=git-$(shell git rev-parse HEAD)
2019-01-23 11:11:55 +03:00
2019-06-13 09:04:32 +03:00
# -ldflags="-X mapserver/app.Version=1.0"
GO_LDFLAGS=-ldflags "-linkmode external -extldflags -static -X mapserver/app.Version=$(VERSION)"
GO_LDFLAGS_WIN=-ldflags "-X mapserver/app.Version=$(VERSION)"
GO_BUILD=CGO_ENABLED=1 go build
BINARIES = $(OUT_DIR)/mapserver-linux-x86_64
BINARIES += $(OUT_DIR)/mapserver-windows-x86-64.exe
BINARIES += $(OUT_DIR)/mapserver-linux-arm
2021-04-12 14:07:17 +03:00
JS_BUNDLE = public/js/bundle.js
2019-06-13 09:04:32 +03:00
all: $(JS_BUNDLE) $(OUT_DIR)/mapserver-linux-x86_64
2019-06-13 09:04:32 +03:00
$(OUT_DIR):
mkdir $@
fmt:
go fmt ./...
test: $(OUT_DIR)
go vet ./...
2021-04-12 12:56:28 +03:00
go test ./...
2019-06-13 09:04:32 +03:00
clean:
2021-04-12 14:07:17 +03:00
rm -rf $(JS_BUNDLE) test-output
2019-06-13 09:04:32 +03:00
rm -rf $(OUT_DIR)
jshint:
2021-04-12 14:07:17 +03:00
cd public/js && jshint .
2019-06-13 09:04:32 +03:00
2019-09-19 12:51:55 +03:00
$(JS_BUNDLE):
2021-04-12 14:07:17 +03:00
cd public/js && rollup -c rollup.config.js
2019-06-13 09:04:32 +03:00
$(OUT_DIR)/mapserver-linux-x86_64: $(OUT_DIR)
# native (linux x86_64)
2019-11-28 21:46:11 +03:00
GOOS=linux GOARCH=amd64 CC=gcc $(GO_BUILD) $(GO_LDFLAGS) -o $@
2019-06-13 09:04:32 +03:00
$(OUT_DIR)/mapserver-windows-x86-64.exe: $(OUT_DIR)
GOARCH=amd64 GOOS=windows CC=x86_64-w64-mingw32-gcc $(GO_BUILD) $(GO_LDFLAGS_WIN) -o $@
$(OUT_DIR)/mapserver-linux-arm: $(OUT_DIR)
# apt install gcc-5-arm-linux-gnueabihf
2021-01-05 16:10:43 +03:00
GOARCH=arm GOARM=7 CC=arm-linux-gnueabihf-gcc-8 $(GO_BUILD) $(GO_LDFLAGS) -o $@
2019-06-13 09:04:32 +03:00
release: builder_image $(OUT_DIR) $(MOD_ZIP)
2019-03-29 11:07:06 +03:00
# build all with the docker image
2019-11-28 15:02:15 +03:00
sudo docker run --rm -i \
-v $(shell pwd):/app \
-v mapserver-volume:/root/go \
-w /app \
mapserver-builder \
2019-06-13 09:04:32 +03:00
make test jshint release-all VERSION=$(VERSION)
2019-03-29 11:07:06 +03:00
# copy generated files to output dir
2019-01-23 11:11:55 +03:00
2019-04-02 20:12:53 +03:00
builder_image:
# build the docker image with all dependencies
$(MAKE) -C docker_builder build
release-all: $(JS_BUNDLE) $(BINARIES)