-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated Makefile to easier build for different platforms (#24)
* Added build targets for most common platforms * Added a clean target --------- Co-authored-by: thenktor <[email protected]>
- Loading branch information
Showing
2 changed files
with
70 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ _obj | |
_test | ||
.idea | ||
.vscode | ||
bin | ||
|
||
# Architecture specific extensions/prefixes | ||
*.[568vq] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,73 @@ | ||
.DEFAULT_GOAL := build | ||
.PHONY: fmt vet build | ||
fmt: | ||
go fmt ./... | ||
|
||
vet: fmt | ||
go vet ./... | ||
NAME := dir2opds | ||
SRCS := $(wildcard *.go) $(wildcard */*.go) | ||
|
||
build: vet | ||
go build . | ||
fmt: $(SRCS) | ||
go fmt ./... | ||
|
||
vet: $(SRCS) fmt | ||
go vet ./... | ||
|
||
build: $(SRCS) vet | ||
go build . | ||
|
||
build-all: darwin freebsd illumos linux netbsd openbsd windows | ||
|
||
darwin: bin/${NAME}-darwin-arm64 | ||
freebsd: bin/${NAME}-freebsd-amd64 | ||
illumos: bin/${NAME}-illumos-amd64 | ||
linux: bin/${NAME}-linux-amd64 bin/${NAME}-linux-arm64 bin/${NAME}-linux-armv7 | ||
netbsd: bin/${NAME}-netbsd-amd64 | ||
openbsd: bin/${NAME}-openbsd-amd64 | ||
windows: bin/${NAME}-windows-amd64.exe | ||
|
||
bin/${NAME}-darwin-arm64: $(SRCS) vet | ||
@mkdir -p bin/darwin-arm64/ | ||
@echo "Building darwin-arm64..." | ||
env GOOS=darwin GOARCH=arm64 go build -o bin/darwin-arm64/${NAME} | ||
|
||
bin/${NAME}-freebsd-amd64: $(SRCS) vet | ||
@mkdir -p bin/freebsd-amd64/ | ||
@echo "Building freebsd-amd64..." | ||
env GOOS=freebsd GOARCH=amd64 go build -o bin/freebsd-amd64/${NAME} | ||
|
||
bin/${NAME}-illumos-amd64: $(SRCS) vet | ||
@mkdir -p bin/illumos-amd64/ | ||
@echo "Building illumos-amd64..." | ||
env GOOS=illumos GOARCH=amd64 go build -o bin/illumos-amd64/${NAME} | ||
|
||
bin/${NAME}-linux-amd64: $(SRCS) vet | ||
@mkdir -p bin/linux-amd64/ | ||
@echo "Building linux-amd64..." | ||
env GOOS=linux GOARCH=amd64 go build -o bin/linux-amd64/${NAME} | ||
|
||
bin/${NAME}-linux-arm64: $(SRCS) vet | ||
@mkdir -p bin/linux-arm64/ | ||
@echo "Building linux-arm64..." | ||
env GOOS=linux GOARCH=arm64 go build -o bin/linux-arm64/${NAME} | ||
|
||
bin/${NAME}-linux-armv7: $(SRCS) vet | ||
@mkdir -p bin/linux-armv7/ | ||
@echo "Building linux-armv7..." | ||
env GOOS=linux GOARCH=arm GOARM=7 go build -o bin/linux-armv7/${NAME} | ||
|
||
bin/${NAME}-netbsd-amd64: $(SRCS) vet | ||
@mkdir -p bin/netbsd-amd64/ | ||
@echo "Building netbsd-amd64..." | ||
env GOOS=netbsd GOARCH=amd64 go build -o bin/netbsd-amd64/${NAME} | ||
|
||
bin/${NAME}-openbsd-amd64: $(SRCS) vet | ||
@mkdir -p bin/openbsd-amd64/ | ||
@echo "Building openbsd-amd64..." | ||
env GOOS=openbsd GOARCH=amd64 go build -o bin/openbsd-amd64/${NAME} | ||
|
||
bin/${NAME}-windows-amd64.exe: $(SRCS) vet | ||
@mkdir -p bin/windows-amd64/ | ||
@echo "Building windows-amd64..." | ||
env GOOS=windows GOARCH=amd64 go build -o bin/windows-amd64/${NAME}.exe | ||
|
||
clean: | ||
go clean | ||
rm -r bin/ |