-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
153 lines (123 loc) · 4.71 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
.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 rtfm
.PHONY : brew install upgrade prepare up
.PHONY : clean rmdata down stop kill debug_dir
.PHONY : create-vbox create-xhyve rm-machine
## SEE RTFM @ https://en.wikipedia.org/wiki/RTFM
rtfm:
## Install brew and taps
brew:
@${CURL} -o ./_makescript/tmp/brew-install -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install
@/usr/bin/ruby ./_makescript/tmp/brew-install
@brew tap homebrew/dupes
@brew tap homebrew/php
## Install brew php, ruby, git and needed packages
install:
@brew install git ruby php72 || true
## Upgrade brew packages
upgrade:
@brew upgrade git ruby php72 || true
## Prepare dev-machine / nfs mounting, hosts file, etc...
prepare:
@sudo ./_makescript/prepare.sh
## Clean all docker data / reset all symlinks, etc..
clean:
@./_makescript/clean.sh
## Remove docker data folder
rmdata:
@docker-compose -f dc-php72.yml down
@docker volume rm -f devmachine_medev-data-volume
## Docker compose down
down:
@docker-compose -f dc-php72.yml down
## Docker compose stop
stop:
@docker-compose -f dc-php72.yml stop
## Docker compose kill
kill:
@docker-compose -f dc-php72.yml kill
## Docker compose up
up:
@docker-machine start dev || true
@docker-compose -f dc-php72.yml up
## Create dev-machine "boot2docker" driver virtualbox
create-vbox:
@docker-machine create --driver virtualbox --virtualbox-cpu-count 4 --virtualbox-memory "8096" --virtualbox-disk-size "20000" dev
## Create dev-machine "boot2docker" driver xhyve
create-xhyve:
@docker-machine create --driver xhyve --xhyve-cpu-count 4 --xhyve-memory-size "8096" --xhyve-disk-size "20000" dev
## Remove dev-machine "boot2docker"
rm-machine:
@docker-machine rm -f -y dev
## Print current directory related info
debug_dir:
@echo MAKEFILE_LIST=$(MAKEFILE_LIST)
@echo MAKEFILE_LIST=$(value MAKEFILE_LIST)
@echo MAKEFILE_LIST_LASTWORD=$(MAKEFILE_LIST_LASTWORD)
@echo MAKEFILE_PATH=$(MAKEFILE_PATH)
@echo MAKEFILE_DIR=$(MAKEFILE_DIR)
@echo MAKEFILE_DIR_PATSUBST=$(MAKEFILE_DIR_PATSUBST)
@echo CURRENT_DIR=$(CURRENT_DIR)
@echo CURRENT_DIR_NOSLASH=$(CURRENT_DIR_NOSLASH)
@echo CURRENT_DIR_NAME=$(CURRENT_DIR_NAME)
################################################################################
# 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)