-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
89 lines (72 loc) · 2.78 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
.SILENT:
################################################################################
# Global defines
################################################################################
# COLORS http://invisible-island.net/xterm/xterm.faq.html#other_versions
RED := $(shell tput -Txterm setaf 1)
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
MAGENTA := $(shell tput -Txterm setaf 5)
CYAN := $(shell tput -Txterm setaf 6)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
# new line and tab
define NEWLINE
endef
define TAB
endef
################################################################################
# Output current makefile info
################################################################################
Function= ${YELLOW}IT IS Working ON my "LOCALHOST" ${MAGENTA}@ https://goo.gl/F3Y9xW${RESET}
RunRtfm = Run 'make rtfm' to see usage
RunHelp = Run 'make help' to see usage
$(info --------------------------------------------------------------------------------)
$(info ${RED}WHY:${RESET} ${GREEN}$(Function)$(NEWLINE)$(TAB)$(TAB)${GREEN}$(RunRtfm)${RESET})
$(info --------------------------------------------------------------------------------)
# get current folder name
# support call makefile from anywhere, not only from current path of makefile located
# MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
# CURRENT_DIR := $(notdir $(patsubst %/,%,$(MAKEFILE_DIR))
MAKEFILE_LIST_LASTWORD = $(lastword $(MAKEFILE_LIST))
MAKEFILE_PATH := $(abspath $(MAKEFILE_LIST_LASTWORD))
MAKEFILE_DIR := $(dir $(MAKEFILE_PATH))
MAKEFILE_DIR_PATSUBST := $(patsubst %/,%,$(MAKEFILE_DIR))
MAKEFILE_DIR_NOSLASH = $(MAKEFILE_DIR_PATSUBST)
CURRENT_DIR = $(MAKEFILE_DIR)
CURRENT_DIR_NOSLASH = $(MAKEFILE_DIR_NOSLASH)
CURRENT_DIR_NAME := $(notdir $(MAKEFILE_DIR_PATSUBST))
SHELL := $(shell which bash 2>/dev/null)
CURL := $(shell which curl 2>/dev/null)
PWD := $(shell pwd)
.DEFAULT_GOAL := help
.PHONY : help
## Docker compose down
down:
@docker-compose down
## Docker compose up
up:
@docker-compose up -d
## Docker ssh kill
ssh:
@ssh [email protected] -p 1310
################################################################################
# Help
################################################################################
TARGET_MAX_CHAR_NUM=25
## Show help
help:
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)