-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
97 lines (89 loc) · 2.34 KB
/
Makefile
File metadata and controls
97 lines (89 loc) · 2.34 KB
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
MAKEFLAGS+=--no-builtin-rules
SHELL:=/usr/bin/env bash
# Default list of exclude modules
ifndef EXCLUDE
EXCLUDE:=go,java
endif
# Functions
packages_from_file=\
$(patsubst %/$1,%$(if $2,/$2,),\
$(filter $(wildcard */$1),$(addsuffix /$1,$(packages))))
# Search for packages, ensuring that OS packages are first with any filters
# http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html
# [backup] http://archive.is/XYuEV
,:=,
space:=
space+=
$(space):=
$(space)+=
os:=$(shell source helpers && echo $$OS)
gui:=$(shell source helpers && echo $$GUI)
os_packages:=debian macos ubuntu void
packages:=\
$(filter $(os_packages),$(os))\
$(filter-out $(os_packages),$(subst /,,$(wildcard */)))
ifdef EXCLUDE
packages:=$(filter-out $(subst $(,),$( ),$(EXCLUDE)),$(packages))
endif
ifdef INCLUDE
packages:=$(filter $(subst $(,),$( ),$(INCLUDE)),$(packages))
endif
ifeq ($(os),macos)
packages:=$(filter-out awesome,$(packages))
endif
ifeq ($(gui),)
packages:=$(filter-out awesome,$(packages))
endif
# Search for specific files based on package
installers:=$(call packages_from_file,install.sh)
stows:=$(call packages_from_file,.stow-local-ignore)
envs:=\
$(foreach p,$(packages),\
$(sort\
$(patsubst %/,%,$(dir\
$(wildcard $p/*.zsh)))))
# Establish rules
installer_rules:=$(addsuffix /install.sh,$(installers))
.PHONY: help clean auto install symlink update $(installer_rules)
.SUFFIXES:
#
# Tasks
# https://blog.sneawo.com/blog/2017/06/13/makefile-help-target/
# [backup] http://archive.is/XFLAz
#
help:
@echo
@echo '=== OS'
@echo "$(os)"
@echo
@echo '=== Packages'
@echo "Install - $(sort $(installers))"
@echo "Symlink - $(sort $(stows))"
@echo "Shell - $(sort $(envs))"
@echo
@echo '=== Variables'
@echo 'INCLUDE - Packages to only include: $(INCLUDE)'
@echo 'EXCLUDE - Packages to exclude: $(EXCLUDE)'
@echo
@echo '=== Commands'
@egrep '^(.+)\:\ .*##\ (.+)' ${MAKEFILE_LIST} | sed 's/:.*## / - /'
@echo
clean: ## Clean up
@printf '==> '
stow -D $(stows)
auto: update install symlink ## Run update, install, and symlink
install: $(installer_rules) ## Install required dependencies
symlink: ## Symlink configuration files
@printf '==> '
stow $(stows)
update: ## Update dotfiles
@printf '==> '
git pull --rebase --autostash
@printf '==> '
git submodule update --init --remote
#
# Internal tasks
#
$(installer_rules): %/install.sh:
@printf '==> '
$@