mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 13:46:41 +00:00
Refactor Makefile
This commit is contained in:
@@ -1,112 +1,7 @@
|
||||
.SILENT:
|
||||
include Makefile.core
|
||||
|
||||
install: \
|
||||
ext/grid.lua \
|
||||
inspect.lua \
|
||||
installSpoons \
|
||||
hs/_asm/undocumented/spaces
|
||||
update: \
|
||||
update_ext/grid.lua \
|
||||
update_inspect.lua \
|
||||
updateSpoons \
|
||||
update_hs/_asm/undocumented/spaces
|
||||
|
||||
#
|
||||
# Config
|
||||
#
|
||||
|
||||
SPOONS = RoundedCorners HeadphoneAutoPause
|
||||
INSPECT_VERSION = 3.1.0
|
||||
SPACES_VERSION = 0.5
|
||||
|
||||
SPOONS_DIR = Spoons
|
||||
SPOON_PATHS = $(foreach s,$(SPOONS),$(shell echo $(SPOONS_DIR)/$(s).spoon))
|
||||
|
||||
|
||||
#
|
||||
# Spoons
|
||||
#
|
||||
|
||||
.PHONY: installSpoons
|
||||
installSpoons: $(SPOON_PATHS)
|
||||
|
||||
.PHONY: removeSpoons
|
||||
removeSpoons:
|
||||
$(foreach dir,$(SPOON_PATHS),(test -d "$(dir)" && echo "removing $(dir)" && rm -rf "$(dir)") || exit 0;)
|
||||
|
||||
.PHONY: updateSpoons
|
||||
updateSpoons: removeSpoons installSpoons
|
||||
|
||||
$(SPOONS_DIR)/%.spoon:
|
||||
echo "fetching $@..." && \
|
||||
curl -s -L -o "$@.zip" \
|
||||
"https://github.com/Hammerspoon/Spoons/raw/master/$@.zip" && \
|
||||
unzip -d $(SPOONS_DIR) "$@.zip" && \
|
||||
rm "$@.zip" && \
|
||||
( test -f "$@.patch" && patch -p0 < "$@.patch" ) || exit 0
|
||||
|
||||
|
||||
#
|
||||
# Core extentions and patching
|
||||
#
|
||||
|
||||
ext/grid.lua:
|
||||
echo "fetching $@..." && \
|
||||
curl -s -L -o $@ \
|
||||
https://raw.githubusercontent.com/Hammerspoon/hammerspoon/master/extensions/grid/init.lua && \
|
||||
( test -f "$@.patch" && patch -p0 < "$@.patch" ) || exit 0
|
||||
|
||||
.PHONY: remove_ext/grid.lua
|
||||
remove_ext/grid.lua:
|
||||
( \
|
||||
test -f "ext/grid.lua" && rm "ext/grid.lua" && \
|
||||
echo "removed ext/grid.lua" \
|
||||
) || exit 0
|
||||
|
||||
.PHONY: update_ext/grid.lua
|
||||
update_ext/grid.lua: remove_ext/grid.lua ext/grid.lua
|
||||
|
||||
|
||||
#
|
||||
# Spaces module
|
||||
#
|
||||
|
||||
hs/_asm/undocumented/spaces:
|
||||
echo "fetching $@..." && \
|
||||
curl -s -L -o "spaces-v$(SPACES_VERSION).zip" \
|
||||
"https://github.com/asmagill/hs._asm.undocumented.spaces/releases/download/v0.5/spaces-v$(SPACES_VERSION).tar.gz" && \
|
||||
tar -xvzf "spaces-v$(SPACES_VERSION).zip" && \
|
||||
rm "spaces-v$(SPACES_VERSION).zip"
|
||||
|
||||
.PHONY: remove_hs/_asm/undocumented/spaces
|
||||
remove_hs/_asm/undocumented/spaces:
|
||||
( \
|
||||
test -d "hs/_asm/undocumented/spaces" && \
|
||||
rm -rf "hs/_asm/undocumented/spaces" && \
|
||||
echo "removed hs/_asm/undocumented/spaces" \
|
||||
) || exit 0
|
||||
|
||||
.PHONY: update_hs/_asm/undocumented/spaces
|
||||
update_hs/_asm/undocumented/spaces: \
|
||||
remove_hs/_asm/undocumented/spaces \
|
||||
hs/_asm/undocumented/spaces
|
||||
|
||||
|
||||
#
|
||||
# inspect.lua - useful for debugging
|
||||
#
|
||||
|
||||
inspect.lua:
|
||||
echo "fetching $@..." && \
|
||||
curl -s -L -o "$@" \
|
||||
"https://raw.githubusercontent.com/kikito/inspect.lua/v$(INSPECT_VERSION)/inspect.lua"
|
||||
|
||||
.PHONY: remove_inspect.lua
|
||||
remove_inspect.lua:
|
||||
( \
|
||||
test -f "inspect.lua" && rm "inspect.lua" && \
|
||||
echo "removed inspect.lua" \
|
||||
) || exit 0
|
||||
|
||||
.PHONY: update_inspect.lua
|
||||
update_inspect.lua: remove_inspect.lua inspect.lua
|
||||
# Specify Dependencies
|
||||
$(eval $(call dep-file,inspect.lua,"https://github.com/kikito/inspect.lua/raw/v3.1.0/inspect.lua"))
|
||||
$(eval $(call dep-file,ext/grid.lua,"https://github.com/Hammerspoon/hammerspoon/raw/master/extensions/grid/init.lua"))
|
||||
$(eval $(call dep-spoon,RoundedCorners,"https://github.com/Hammerspoon/Spoons/raw/master/RoundedCorners.zip"))
|
||||
$(eval $(call dep-spoon,HeadphoneAutoPause,"https://github.com/Hammerspoon/Spoons/raw/master/HeadphoneAutoPause.zip"))
|
||||
|
||||
56
hammerspoon/Makefile.core
Normal file
56
hammerspoon/Makefile.core
Normal file
@@ -0,0 +1,56 @@
|
||||
.SILENT:
|
||||
default: install
|
||||
|
||||
# Config
|
||||
SPOONS_DIR = Spoons
|
||||
DEP_PATHS =
|
||||
|
||||
define dep-file
|
||||
DEP_PATHS += $(1)
|
||||
$(1):
|
||||
echo "fetching $(1)..." && \
|
||||
curl -s -L -o $(1) "$(2)" && \
|
||||
( test -f "$(1).patch" && patch -p0 < "$(1).patch" ) || exit 0
|
||||
|
||||
.PHONY: remove_$(1)
|
||||
remove_$(1):
|
||||
( test -f "$(1)" && rm "$(1)" && echo "removed $(1)" ) || exit 0
|
||||
|
||||
.PHONY: update_$(1)
|
||||
update_$(1): remove_$(1) $(1)
|
||||
endef
|
||||
|
||||
define dep-spoon
|
||||
DEP_PATHS += $(SPOONS_DIR)/$(1).spoon
|
||||
$(SPOONS_DIR)/$(1).spoon:
|
||||
echo "fetching $(SPOONS_DIR)/$(1).spoon..." && \
|
||||
curl -s -L -o "$(SPOONS_DIR)/$(1).spoon.zip" \
|
||||
"https://github.com/Hammerspoon/Spoons/raw/master/$(SPOONS_DIR)/$(1).spoon.zip" && \
|
||||
unzip -d $(SPOONS_DIR) "$(SPOONS_DIR)/$(1).spoon.zip" && \
|
||||
rm "$(SPOONS_DIR)/$(1).spoon.zip" && \
|
||||
( \
|
||||
test -f "$(SPOONS_DIR)/$(1).spoon.patch" && \
|
||||
patch -p0 < "$(SPOONS_DIR)/$(1).spoon.patch" \
|
||||
) || exit 0
|
||||
|
||||
.PHONY: remove_$(SPOONS_DIR)/$(1).spoon
|
||||
remove_$(SPOONS_DIR)/$(1).spoon:
|
||||
( \
|
||||
test -d "$(SPOONS_DIR)/$(1).spoon" && \
|
||||
echo "removing $(SPOONS_DIR)/$(1).spoon" && \
|
||||
rm -rf "$(SPOONS_DIR)/$(1).spoon" \
|
||||
) || exit 0
|
||||
|
||||
.PHONY: update_$(SPOONS_DIR)/$(1).spoon
|
||||
update_$(SPOONS_DIR)/$(1).spoon: \
|
||||
remove_$(SPOONS_DIR)/$(1).spoon \
|
||||
$(SPOONS_DIR)/$(1).spoon
|
||||
endef
|
||||
|
||||
# Default tasks
|
||||
install:
|
||||
make $(DEP_PATHS)
|
||||
update:
|
||||
make $(foreach path,$(DEP_PATHS),$(shell echo "update_$(path)"))
|
||||
clean:
|
||||
make $(foreach path,$(DEP_PATHS),$(shell echo "remove_$(path)"))
|
||||
Reference in New Issue
Block a user