-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
56 lines (49 loc) · 2.35 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Define the default shell
# @see https://stackoverflow.com/a/14777895/413531 for the OS detection logic
OS?=undefined
ifeq ($(OS),Windows_NT)
# Windows requires the .exe extension, otherwise the entry is ignored
# @see https://stackoverflow.com/a/60318554/413531
SHELL := bash.exe
# make sure that MinGW / MSYSY does not automatically convert paths starting with /
# @see https://stackoverflow.com/a/48348531
export MSYS_NO_PATHCONV=1
else
SHELL := bash
endif
# @see https://tech.davis-hansson.com/p/make/ for some make best practices
# use bash strict mode @see http://redsymbol.net/articles/unofficial-bash-strict-mode/
# -e - instructs bash to immediately exit if any command has a non-zero exit status
# -u - a reference to any variable you haven't previously defined - with the exceptions of $* and $@ - is an error
# -o pipefail - if any command in a pipeline fails, that return code will be used as the return code
# of the whole pipeline. By default, the pipeline's return code is that of the last command - even if it succeeds.
# https://unix.stackexchange.com/a/179305
# -c - Read and execute commands from string after processing the options. Otherwise, arguments are treated as filed. Example:
# bash -c "echo foo" # will excecute "echo foo"
# bash "echo foo" # will try to open the file named "echo foo" and execute it
.SHELLFLAGS := -euo pipefail -c
# display a warning if variables are used but not defined
MAKEFLAGS += --warn-undefined-variables
# remove some "magic make behavior"
MAKEFLAGS += --no-builtin-rules
-include .make/.env
# Common variable to pass arbitrary options to targets
ARGS?=
# @see https://www.thapaliya.com/en/writings/well-documented-makefiles/
DEFAULT_GOAL := help
help:
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-40s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
include .make/*.mk
##@ [Make]
## Usage:
## init
##
## init ENVS="KEY_1=value1 KEY_2=value2"
.PHONY: init
init: ENVS= ## Initializes the deployment make environment variables (.make/.env)
init:
@cp .make/.env.example .make/.env
@for variable in $(ENVS); do \
echo $$variable | tee -a .make/.env; \
done
@echo "Please update your .make/.env file with your settings"