diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9669417 --- /dev/null +++ b/Makefile @@ -0,0 +1,44 @@ +# Simple Make file to build csaf_distribution components + +SHELL=/bin/bash +BUILD = go build +MKDIR = mkdir -p bin + +.PHONY: build build_win build_tag clean + +all: + @echo choose a target from: build build_linux build_win build_tag clean + +# Build the binaries for GNU/linux and place them under binaries/ directory. +build_linux: + @$(MKDIR) + @echo "Bulding binaries for GNU/Linux ..." + @$(BUILD) -o ./bin/ -v ./cmd/... + +# Build the binaries for windows (cross build) and place them under binaries/ directory. +build_win: + @$(MKDIR) + @echo "Bulding binaries for windows (cross build) ..." + @env GOARCH=amd64 GOOS=windows $(BUILD) -o ./bin/ -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. +TAG = $(shell git tag --sort=-version:refname | head -n 1) +build_tag: +ifeq ($(TAG),) + @echo "No Tag found" +else + @git checkout -q tags/${TAG}; + @echo $(buildMsg) + @$(BUILD) -o ./binaries/ -v ./cmd/...; + @env GOOS=windows $(BUILD) -o ./ -v ./cmd/... + @git checkout -q main +endif + +# Remove binaries directory +clean: + @rm -rf bin/ + + diff --git a/README.md b/README.md index f058e58..1497e5f 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,13 @@ - Clone the repository `git clone https://github.com/csaf-poc/csaf_distribution.git ` - Build Go components - ``` bash - cd csaf_distribution - go build -v ./cmd/... -``` + Makefile supplies the following targets: + - Build For GNU/Linux System: `make build_linux` + - Build For Windows System (cross build): `make build_win` + - Build For both linux and windows: `make build` + - Build from the last github-tag: `make build_tag` + +These places the binaries under `bin/` directory. - [Install](http://nginx.org/en/docs/install.html) **nginx** - To configure nginx see [docs/provider-setup.md](docs/provider-setup.md)