-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
191 lines (183 loc) · 4.63 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File: /Makefile
# Project: dotstow
# File Created: 22-05-2022 06:43:47
# Author: Clay Risser
# -----
# Last Modified: 27-02-2023 14:47:40
# Modified By: Clay Risser
# -----
# Risser Labs LLC (c) Copyright 2022
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
.DEFAULT_GOAL := help
export NOCOLOR=\033[0m
export RED=\033[0;31m
export GREEN=\033[0;32m
export ORANGE=\033[0;33m
export BLUE=\033[0;34m
export PURPLE=\033[0;35m
export CYAN=\033[0;36m
export LIGHTGRAY=\033[0;37m
export DARKGRAY=\033[1;30m
export LIGHTRED=\033[1;31m
export LIGHTGREEN=\033[1;32m
export YELLOW=\033[1;33m
export LIGHTBLUE=\033[1;34m
export LIGHTPURPLE=\033[1;35m
export LIGHTCYAN=\033[1;36m
export WHITE=\033[1;37m
export BANG := \!
export NOFAIL := 2>$(NULL) || $(TRUE)
export NOOUT := >$(NULL) 2>$(NULL)
export NULL := /dev/null
export CAT := cat
export CD := cd
export CHMOD := chmod
export CP := cp
export CUT := cut
export DU := du
export ECHO := echo
export EXIT := exit
export EXPORT := export
export FALSE := false
export HEAD := head
export MKDIR := mkdir
export RM := rm
export SORT := sort
export TOUCH := touch
export TR := tr
export TRUE := true
export UNIQ := uniq
export WHICH := command -v
export ARCH := unknown
export FLAVOR := unknown
export PKG_MANAGER := unknown
export PLATFORM := unknown
ifeq ($(OS),Windows_NT)
export HOME := $(HOMEDRIVE)$(HOMEPATH)
PLATFORM = win32
FLAVOR = win64
ARCH = $(PROCESSOR_ARCHITECTURE)
PKG_MANAGER = choco
ifeq ($(ARCH),AMD64)
ARCH = amd64
endif
ifeq ($(ARCH),ARM64)
ARCH = arm64
endif
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
ARCH = amd64
ifeq (,$(PROCESSOR_ARCHITEW6432))
ARCH = x86
FLAVOR := win32
endif
endif
else
PLATFORM = $(shell uname 2>$(NULL) | $(TR) '[:upper:]' '[:lower:]' 2>$(NULL))
ARCH = $(shell (dpkg --print-architecture 2>$(NULL) || uname -m 2>$(NULL) || arch 2>$(NULL) || echo unknown) | $(TR) '[:upper:]' '[:lower:]' 2>$(NULL))
ifeq ($(ARCH),i386)
ARCH = 386
endif
ifeq ($(ARCH),i686)
ARCH = 386
endif
ifeq ($(ARCH),x86_64)
ARCH = amd64
endif
ifeq ($(PLATFORM),linux) # LINUX
ifneq (,$(wildcard /system/bin/adb))
ifneq ($(shell getprop --help >$(NULL) 2>$(NULL) && echo 1 || echo 0),1)
PLATFORM = android
endif
endif
ifeq ($(PLATFORM),linux)
FLAVOR = $(shell lsb_release -si 2>$(NULL) | $(TR) '[:upper:]' '[:lower:]' 2>$(NULL))
ifeq (,$(FLAVOR))
FLAVOR = unknown
ifneq (,$(wildcard /etc/redhat-release))
FLAVOR = rhel
endif
ifneq (,$(wildcard /etc/SuSE-release))
FLAVOR = suse
endif
ifneq (,$(wildcard /etc/debian_version))
FLAVOR = debian
endif
ifeq ($(shell cat /etc/os-release 2>$(NULL) | grep -E "^ID=alpine$$"),ID=alpine)
FLAVOR = alpine
endif
endif
ifeq ($(FLAVOR),rhel)
PKG_MANAGER = $(call ternary,$(WHICH) microdnf,microdnf,$(call ternary,$(WHICH) dnf,dnf,yum))
endif
ifeq ($(FLAVOR),suse)
PKG_MANAGER = zypper
endif
ifeq ($(FLAVOR),debian)
PKG_MANAGER = apt-get
endif
ifeq ($(FLAVOR),ubuntu)
PKG_MANAGER = apt-get
endif
ifeq ($(FLAVOR),alpine)
PKG_MANAGER = apk
endif
endif
else
ifneq (,$(findstring CYGWIN,$(PLATFORM))) # CYGWIN
PLATFORM = win32
FLAVOR = cygwin
endif
ifneq (,$(findstring MINGW,$(PLATFORM))) # MINGW
PLATFORM = win32
FLAVOR = msys
PKG_MANAGER = mingw-get
endif
ifneq (,$(findstring MSYS,$(PLATFORM))) # MSYS
PLATFORM = win32
FLAVOR = msys
PKG_MANAGER = pacman
endif
endif
ifeq ($(PLATFORM),darwin)
PKG_MANAGER = brew
endif
endif
.PHONY: install
ifeq ($(PKG_MANAGER),brew)
install: /usr/local/bin/dotstow \
/usr/local/bin/stow
else
install: /usr/local/bin/dotstow \
/usr/bin/stow
endif
/usr/local/bin/dotstow: dotstow.sh
@sudo cp $< $@
@sudo chmod +x $@
/usr/local/bin/stow:
ifeq ($(PKG_MANAGER),brew)
@brew install stow
else
@echo "$(ORANGE)please install the stow command$(NOCOLOR)\n$(CYAN)https://www.gnu.org/software/stow$(NOCOLOR)" >&2
endif
/usr/bin/stow:
ifeq ($(PKG_MANAGER),apt-get)
@sudo apt-get install -y stow
else
@echo "$(ORANGE)please install the stow command$(NOCOLOR)\n$(CYAN)https://www.gnu.org/software/stow$(NOCOLOR)" >&2
endif
.PHONY: uninstall
uninstall:
@sudo rm /usr/local/bin/dotstow
.PHONY: help
help: ;