1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 11:55:40 +01:00

Add one target to Makefile

* "build_linux": building for GNU/linux
* "build": Building for both linux and windows (cross build)
* Place the generate binaries under "binaries/" directory
* Improve echo messages
This commit is contained in:
Fadi Abbud 2022-01-31 13:09:47 +01:00
parent 84c3a108d0
commit ec6cabb9ac
2 changed files with 22 additions and 16 deletions

View file

@ -2,22 +2,27 @@
SHELL=/bin/bash SHELL=/bin/bash
BUILD = go build BUILD = go build
buildMsg = "Building binaries..." MAKDIR = mkdir -p binaries
.PHONY: build build_win build_tag clean .PHONY: build build_win build_tag clean
all: all:
@echo choose a target from: build build_win build_tag clean @echo choose a target from: build build_linux build_win build_tag clean
# Build all the binaries and place them in the current directory level. # Build the binaries for GNU/linux and place them under binaries/ directory.
build: build_linux:
@echo $(buildMsg) @$(MKDIR)
@$(BUILD) -o ./ -v ./cmd/... @echo "Bulding binaries for GNU/Linux ..."
@$(BUILD) -o ./binaries/ -v ./cmd/...
# Build the binaries for windows (cross build) and place them in the current directory level. # Build the binaries for windows (cross build) and place them under binaries/ directory.
build_win: build_win:
@echo $(buildMsg) @$(MKDIR)
@env GOOS=windows $(BUILD) -o ./ -v ./cmd/... @echo "Bulding binaries for windows (cross build) ..."
@env GOOS=windows $(BUILD) -o ./binaries/ -v ./cmd/...
# Build the binaries for both GNU/linux and Windows and place them under binaries/ directory.
build: build_linux build_win
# Build the binaries from the latest github tag. # Build the binaries from the latest github tag.
TAG = $(shell git tag --sort=-version:refname | head -n 1) TAG = $(shell git tag --sort=-version:refname | head -n 1)
@ -27,13 +32,13 @@ ifeq ($(TAG),)
else else
@git checkout -q tags/${TAG}; @git checkout -q tags/${TAG};
@echo $(buildMsg) @echo $(buildMsg)
@$(BUILD) -o ./ -v ./cmd/...; @$(BUILD) -o ./binaries/ -v ./cmd/...;
@env GOOS=windows $(BUILD) -o ./ -v ./cmd/... @env GOOS=windows $(BUILD) -o ./ -v ./cmd/...
@git checkout -q main @git checkout -q main
endif endif
# Remove binary files # Remove binaries directory
clean: clean:
@rm -f csaf_checker csaf_provider csaf_uploader csaf_checker.exe csaf_provider.exe csaf_uploader.exe @rm -rf binaries/

View file

@ -11,11 +11,12 @@
- Build Go components - Build Go components
Makefile supplies the following builds: Makefile supplies the following builds:
- For Linux System (default build):`make build` - Build For Linux System:`make build_linux`
- For Windows System (cross build): `make build_win` - Build For Windows System (cross build): `make build_win`
- Build from the last tag: `make build_tag` - Build For both linux and windows: `make build`
- Build from the last github-tag: `make build_tag`
These places the binaries in the current directory. These places the binaries under `binaries/` directory.
- [Install](http://nginx.org/en/docs/install.html) **nginx** - [Install](http://nginx.org/en/docs/install.html) **nginx**
- To configure nginx see [docs/provider-setup.md](docs/provider-setup.md) - To configure nginx see [docs/provider-setup.md](docs/provider-setup.md)