From ec6cabb9ac70bf5d5891a66138bff30dd83c9f99 Mon Sep 17 00:00:00 2001 From: Fadi Abbud Date: Mon, 31 Jan 2022 13:09:47 +0100 Subject: [PATCH] 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 --- Makefile | 29 +++++++++++++++++------------ README.md | 9 +++++---- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 867d0a5..02e3b20 100644 --- a/Makefile +++ b/Makefile @@ -2,22 +2,27 @@ SHELL=/bin/bash BUILD = go build -buildMsg = "Building binaries..." +MAKDIR = mkdir -p binaries .PHONY: build build_win build_tag clean 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: - @echo $(buildMsg) - @$(BUILD) -o ./ -v ./cmd/... +# Build the binaries for GNU/linux and place them under binaries/ directory. +build_linux: + @$(MKDIR) + @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: - @echo $(buildMsg) - @env GOOS=windows $(BUILD) -o ./ -v ./cmd/... + @$(MKDIR) + @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. TAG = $(shell git tag --sort=-version:refname | head -n 1) @@ -27,13 +32,13 @@ ifeq ($(TAG),) else @git checkout -q tags/${TAG}; @echo $(buildMsg) - @$(BUILD) -o ./ -v ./cmd/...; + @$(BUILD) -o ./binaries/ -v ./cmd/...; @env GOOS=windows $(BUILD) -o ./ -v ./cmd/... @git checkout -q main endif -# Remove binary files +# Remove binaries directory clean: - @rm -f csaf_checker csaf_provider csaf_uploader csaf_checker.exe csaf_provider.exe csaf_uploader.exe + @rm -rf binaries/ diff --git a/README.md b/README.md index 6928a5a..ec23906 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,12 @@ - Build Go components Makefile supplies the following builds: - - For Linux System (default build):`make build` - - For Windows System (cross build): `make build_win` - - Build from the last tag: `make build_tag` + - Build For 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 in the current directory. +These places the binaries under `binaries/` directory. - [Install](http://nginx.org/en/docs/install.html) **nginx** - To configure nginx see [docs/provider-setup.md](docs/provider-setup.md)