# Build all by default, even if it's not first

# ==============================================================================
# Packages used in scripts

VERSION := v1.0.0-$(shell date -u +'%Y%m%d%H%M%S')
GIT_COMMIT := unknown
GIT_TREE_STATE := clean
BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')

ROOT_PACKAGE=./
VERSION_PACKAGE=./pkg/version

# ==============================================================================
# Includes

include script/make/init.mk
include script/make/golang.mk
include script/make/pack.mk

# ==============================================================================
# Usage

define USAGE_OPTIONS

Options:
  TARGETENV        The target environment to build. Default is prod.
                   Valid values are: prod, staging, dev.
                   This option is available when using: make gen
                   Example: make gen TARGETENV=staging
  PLATFORMS        The multiple platforms(separated by spaces) to build. Default is linux_amd64.
                   This option is available when using: make build.multiarch
                   Example: make build.multiarch PLATFORMS="linux_amd64 linux_arm64"
  VERSION          The version information compiled into binaries.
                   The default is obtained from gsemver or git.
  V                Set to 1 enable verbose build. Default is 0.
endef
export USAGE_OPTIONS

## build: Build source code for host platform.
.PHONY: build
build:
	@$(MAKE) go.build

## build: Pack executable programs into docker images and push.
.PHONY: pack
pack:
	@$(MAKE) pack.all
