diff --git a/Makefile b/Makefile index cec58b2..474d287 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,12 @@ IMAGE=h44z/wg-portal all: dep build -build: dep $(addprefix $(BUILDDIR)/,$(BINARIES)) +build: dep $(addsuffix -amd64,$(addprefix $(BUILDDIR)/,$(BINARIES))) + cp -r assets $(BUILDDIR) + cp scripts/wg-portal.service $(BUILDDIR) + cp scripts/wg-portal.env $(BUILDDIR) + +build-cross-plat: dep build $(addsuffix -arm,$(addprefix $(BUILDDIR)/,$(BINARIES))) $(addsuffix -arm64,$(addprefix $(BUILDDIR)/,$(BINARIES))) cp -r assets $(BUILDDIR) cp scripts/wg-portal.service $(BUILDDIR) cp scripts/wg-portal.env $(BUILDDIR) @@ -45,8 +50,13 @@ docker-build: docker-push: docker push $(IMAGE) -# For arch install: arm-linux-gnueabihf-gcc and aarch64-linux-gnu-gcc to crosscompile for arm -$(BUILDDIR)/%: cmd/%/main.go dep phony - GOOS=linux GOARCH=amd64 $(GOCMD) build -o $@-amd64 $< - CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc GOOS=linux GOARCH=arm64 $(GOCMD) build -ldflags "-linkmode external -extldflags -static" -o $@-arm64 $< - CGO_ENABLED=1 CC=arm-linux-gnueabihf-gcc GOOS=linux GOARCH=arm GOARM=7 $(GOCMD) build -ldflags "-linkmode external -extldflags -static" -o $@-arm $< \ No newline at end of file +$(BUILDDIR)/%-amd64: cmd/%/main.go dep phony + GOOS=linux GOARCH=amd64 $(GOCMD) build -o $@ $< + +# On arch-linux install aarch64-linux-gnu-gcc to crosscompile for arm64 +$(BUILDDIR)/%-arm64: cmd/%/main.go dep phony + CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc GOOS=linux GOARCH=arm64 $(GOCMD) build -ldflags "-linkmode external -extldflags -static" -o $@ $< + +# On arch-linux install arm-linux-gnueabihf-gcc to crosscompile for arm +$(BUILDDIR)/%-arm: cmd/%/main.go dep phony + CGO_ENABLED=1 CC=arm-linux-gnueabihf-gcc GOOS=linux GOARCH=arm GOARM=7 $(GOCMD) build -ldflags "-linkmode external -extldflags -static" -o $@ $< \ No newline at end of file diff --git a/README-RASPBERRYPI.md b/README-RASPBERRYPI.md index 5474cf9..a8b6914 100644 --- a/README-RASPBERRYPI.md +++ b/README-RASPBERRYPI.md @@ -13,7 +13,7 @@ To compile the final binary, use the Makefile provided in the repository. As WireGuard Portal is written in Go, **golang >= 1.14** must be installed prior to building. ``` -make +make build-cross-plat ``` The compiled binary and all necessary assets will be located in the dist folder. diff --git a/README.md b/README.md index 6d582f2..be99d3c 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,9 @@ For a standalone application, use the Makefile provided in the repository to bui ``` make + +# To build for arm architecture as well use: +make build-cross-plat ``` The compiled binary and all necessary assets will be located in the dist folder.