~nilium/dotfiles

ref: a0073a163f054307bde7df89a4f49371539bbe08 dotfiles/Makefile -rw-r--r-- 2.2 KiB
a0073a16Noel Cower Add utils section, update `git s`, adjust INSTALL 3 months ago
                                                                                
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
PREFIX    ?= ${HOME}
BIN_DIR   ?= ${PREFIX}/bin

HERE := ${.PARSEDIR:tA}
.ifndef PLATFORM
PLATFORM != uname -s | tr A-Z a-z
.endif

# Any variable names in FACTS will be printed as part of the help text. This can
# be useful for debugging and just for making it clear where something's going
# to end up before it's run.
FACTS += PLATFORM PREFIX BIN_DIR

SYMLINK ?= ln -snf
FACTS += SYMLINK
VERSION_CONTROL ?= numbered
.export-env VERSION_CONTROL
INSTALL ?= install
GMAKE   ?= make
FACTS += GMAKE

.if ${PLATFORM} == darwin
INSTALL_FILE ?= ${INSTALL}
.else
INSTALL_FILE ?= ${INSTALL} -T
.endif
FACTS += INSTALL
FACTS += INSTALL_FILE

help::
all::

# This structure is based on katef's Makefiles: https://github.com/katef/kmkf
# It's not quite as nice because the original structure was refactored to act
# more like it.
#
# Essentially, every subdir listed here has a Makefile that's included, defines
# its own targets, and sets both the HELP and TARGET variables. These are used
# to construct the `help` target. A target to be installed by `all` should add
# its target to the TARGETS variable.
SUBDIRS += brew
SUBDIRS += dunst
SUBDIRS += git
SUBDIRS += herbstluftwm
SUBDIRS += kitty
SUBDIRS += pact
SUBDIRS += polybar
SUBDIRS += tmux
SUBDIRS += utils
SUBDIRS += vim
SUBDIRS += zsh

.for dir in ${SUBDIRS}
.include "${dir}/Makefile"
HELP_install-${dir} := ${HELP}
TARGET.${dir} := ${TARGET}
CONF_TARGETS += ${TARGET.${dir}}
.endfor

CONF_TARGETS += init
CONF_TARGETS += submodules

# Init
HELP_init := Initialize the repository
TARGET_init := init

init:: submodules

# Submodules
HELP_submodules := Initialize submodules
TARGET_submodules := submodules

submodules::
	git submodule update --init --reference=${HERE:Q}

# All targets for the current platform.
all:: init .WAIT ${TARGETS}

help::
	@echo "Install one or more configs from dotfiles using bmake."
	@echo ""
	@echo "Targets:"
	@echo "  * help: Print this help text (default)"
	@echo "  * all: Install all config for the current platform (${PLATFORM:Q})"
	@echo "  * facts: Print computed variables for the Makefile"
.for target in ${CONF_TARGETS:O}
	@echo "  * ${target:Q}: ${HELP_${target}}"
.endfor

facts::
.for fact in ${FACTS:O}
	@echo "  ${fact:Q}=${${fact}:Q}"
.endfor