From 70f2826afec9a442912a999eb99afa82deef97e0 Mon Sep 17 00:00:00 2001 From: James Patrick Date: Sun, 28 Nov 2021 16:33:24 -0500 Subject: [PATCH] Refactored make targets. --- emacs/makefile | 33 ++++++++++++++++----------------- git/makefile | 6 ++---- jrnl/makefile | 6 ++---- kitty/makefile | 5 +++-- lib/makefile | 6 ++---- lib/post-merge | 8 +------- makefile | 20 +++++--------------- mako/makefile | 6 ++---- mbsync/makefile | 11 ++--------- pass/makefile | 9 ++------- rofi/makefile | 8 ++------ ssh/makefile | 20 +++++++++----------- sway/makefile | 43 +++++++++++++++++++++---------------------- tmux/makefile | 8 ++------ tridactyl/makefile | 15 ++++++--------- vim/makefile | 34 ++++++++++++++++------------------ waybar/makefile | 24 +++++++++++------------- zsh/makefile | 44 +++++++++++++++++++++----------------------- 18 files changed, 125 insertions(+), 181 deletions(-) diff --git a/emacs/makefile b/emacs/makefile index 455a7e6..c8f2009 100644 --- a/emacs/makefile +++ b/emacs/makefile @@ -6,12 +6,25 @@ EMACSD := ~/.emacs.d DOOMD := ~/.doom.d DOOM_URL := https://github.com/hlissner/doom-emacs - include ../lib/shared.mk -install: | init update +up: setup + if [ -e $(EMACSD)/bin/doom ] ; then + ~/.emacs.d/bin/doom --yes sync \ + ; $(report) "doom sync" + ~/.emacs.d/bin/doom --yes purge \ + ; $(report) "doom purge" + else + $(report) debug "doom not setup, so not updating." + fi -init: +down: + $(report) header "Removing Emacs configuration" + rm -rf $(EMACSD) ; $(report) "deleted $(EMACSD)" + $(rm_link) $(DOOMD) + + +setup: if (( ! $$+commands[emacs] )) ; then $(report) debug "Emacs not installed. Skipping install." elif [[ -v $$SSH_TTY ]] ; then @@ -33,17 +46,3 @@ doom_init: $(report) debug "emacsd already exists. Skipping" fi -update: - if [ -e $(EMACSD)/bin/doom ] ; then - ~/.emacs.d/bin/doom --yes sync \ - ; $(report) "doom sync" - ~/.emacs.d/bin/doom --yes purge \ - ; $(report) "doom purge" - else - $(report) debug "doom not setup, so not updating." - fi - -remove: - $(report) header "Removing Emacs configuration" - rm -rf $(EMACSD) ; $(report) "deleted $(EMACSD)" - $(rm_link) $(DOOMD) diff --git a/git/makefile b/git/makefile index b53cd09..6aed267 100644 --- a/git/makefile +++ b/git/makefile @@ -5,14 +5,12 @@ TARGET := ~/.gitconfig include ../lib/shared.mk -install: | init update - init: $(report) header "Setting up gitconfig" $(mk_link) $(SOURCE) $(TARGET) -update: +up: init -remove: +down: $(report) header "Removing gitconfig" $(rm_link) $(TARGET) diff --git a/jrnl/makefile b/jrnl/makefile index 1cc1a45..9eb2626 100644 --- a/jrnl/makefile +++ b/jrnl/makefile @@ -5,9 +5,7 @@ include ../lib/shared.mk CONFIG_DIR := $(XDG_DIR)/jrnl -install: | init update - -init: +up: if (( $$+commands[jrnl] )) ; then $(report) header "Setting up jrnl" mkdir $(CONFIG_DIR) @@ -16,5 +14,5 @@ init: $(report) debug "jrnl not installed. Skipping." fi -remove: +down: rm -rf $(CONFIG_DIR) diff --git a/kitty/makefile b/kitty/makefile index bece955..93fb395 100644 --- a/kitty/makefile +++ b/kitty/makefile @@ -1,13 +1,14 @@ # -*- mode: makefile-gmake; -*- SRC := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) +requires := kitty include ../lib/shared.mk CONFIG_DIR := $(XDG_DIR)/kitty install: | init update -init: +up: if (( $$+commands[kitty] )) ; then $(report) header "Setting up kitty" $(mk_link) $(SRC) $(CONFIG_DIR) @@ -15,6 +16,6 @@ init: $(report) debug "kitty not installed. Skipping." fi -remove: +down: $(report) header "removing up kitty" rm -r $(CONFIG_DIR) ; $(report) "removed dir" diff --git a/lib/makefile b/lib/makefile index 50e222a..fd22634 100644 --- a/lib/makefile +++ b/lib/makefile @@ -5,8 +5,6 @@ GIT_HOOK_TARGET = $(abspath $(SRC_DIR)/..)/.git/hooks/post-merge include ../lib/shared.mk -install: | init update - init: $(report) header "Setting up this stuff" $(report) pass "githook symlinked `ln -svf $(GIT_HOOK_SRC) $(GIT_HOOK_TARGET)`" @@ -21,8 +19,8 @@ fix_http_repo: $(report) debug "git repo deosn't start with http. So no need to reset remote." fi -update: +up: init -remove: +down: $(report) header "Removing githook" $(rm_link) $(GIT_HOOK_TARGET) diff --git a/lib/post-merge b/lib/post-merge index cb7c130..0caf503 100755 --- a/lib/post-merge +++ b/lib/post-merge @@ -1,9 +1,3 @@ #!/bin/zsh # -*- zsh -*- - -local_hook="$HOME"/.git_template.local/hooks/post-merge -[ -f "$local_hook" ] && . "$local_hook" - -.git/hooks/ctags >/dev/null 2>&1 & - -(($+commands[gmake])) && gmake update || make update +( ($+commands[gmake])) && gmake up || make update diff --git a/makefile b/makefile index 7853856..96e9227 100644 --- a/makefile +++ b/makefile @@ -6,23 +6,13 @@ include lib/shared.mk define recursive_make for i in */makefile; do echo "`dirname $$i` " - $(MAKE) -C $(SRC_DIR)/`dirname $$i` $1 + $(MAKE) --keep-going -C $(SRC_DIR)/`dirname $$i` $1 echo "" done endef -install: - $(info Initalizing) - $(call recursive_make,install) +up: + $(call recursive_make,up) -init: - $(info Initalizing) - $(call recursive_make,init) - -update: - $(info Updating) - $(call recursive_make,update) - -remove: - $(info Removing) - $(call recursive_make,remove) +down: + $(call recursive_make,down) diff --git a/mako/makefile b/mako/makefile index 499e83a..b3ca904 100644 --- a/mako/makefile +++ b/mako/makefile @@ -4,8 +4,6 @@ SRC := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) include ../lib/shared.mk TARGET := $(XDG_DIR)/mako -install: | init update - init: if (( $$+commands[mako] )) ; then $(report) header "Setting up mako" @@ -14,7 +12,7 @@ init: $(report) warn "mako not installed. Skipping." fi -update: +up: init if (( $$+commands[makoctl] )) ; then $(report) header "Updating mako" if [[ -n `pgrep mako` ]] ; then @@ -25,6 +23,6 @@ update: fi -remove: +down: $(report) header "Removing mako" $(rm_link) $(TARGET) diff --git a/mbsync/makefile b/mbsync/makefile index b406ba3..c58971d 100644 --- a/mbsync/makefile +++ b/mbsync/makefile @@ -6,10 +6,7 @@ TARGET := $(XDG_DIR)/mbsync RC_TARGET := ~/.mbsyncrc TRANSIENT_DIR := $(SRC)/transient - -install: | init update - -init: +up: if (( $$+commands[mbsync] )) ; then $(report) header "Setting up mbsync" $(mk_link) $(SRC) $(TARGET) @@ -34,11 +31,7 @@ update_cert: && $(report) pass "Cert from proton bridge downloaded." \ || $(report) error "Error while fetching cert. Is bridge running?" - - -update: - -remove: +down: $(report) header "Removing mbsync" $(rm_link) $(TARGET) rm -rf $(TRANSIENT_DIR) ; $(report) "Deleting $(TRANSIENT_DIR)" diff --git a/pass/makefile b/pass/makefile index cbd40f0..657c3ae 100644 --- a/pass/makefile +++ b/pass/makefile @@ -4,9 +4,7 @@ SRC := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) include ../lib/shared.mk TARGET := ~/.password-store -install: | init update - -init: +up: if (( $$+commands[pass] )) ; then $(report) header "Setting up pass" [ -e $(TARGET) ] \ @@ -16,9 +14,6 @@ init: $(report) debug " pass not installed. Skipping." fi -update: - - -remove: +down: $(report) header "Removing pass" $(rm_link) $(TARGET) diff --git a/rofi/makefile b/rofi/makefile index 956f97d..ea69901 100644 --- a/rofi/makefile +++ b/rofi/makefile @@ -7,9 +7,7 @@ TARGET := $(XDG_DIR)/rofi DESKTOP_SRC := $(SRC)/desktop DESKTOP_TARGET := ~/.local/share/applications -install: | init update - -init: +up: if (( $$+commands[rofi] )) ; then $(report) header "Setting up rofi" $(mk_link) $(SRC) $(TARGET) @@ -18,9 +16,7 @@ init: $(report) debug "rofi not installed. Skipping." fi -update: - -remove: +down: $(report) header "Removing rofi" $(rm_link) $(TARGET) $(MAKE) -C $(SRC) desktop_remove diff --git a/ssh/makefile b/ssh/makefile index 47172dc..7a650dd 100644 --- a/ssh/makefile +++ b/ssh/makefile @@ -7,16 +7,7 @@ GIT_KEY := ~/.ssh/git.jpatrick.io include ../lib/shared.mk -install: | init update - -init: - $(report) header "Setting up ssh" - $(mk_link) $(CONFIG_SRC) $(CONFIG_TRGT) - $(mk_link) $(SRC_DIR)/public_keys ~/.ssh/public_keys - $(mk_link) $(SRC_DIR)/config.d ~/.ssh/config.d - $(MAKE) -C $(SRC_DIR) init_git_key - -update: +up: init mkdir -p public_keys/`hostname` cd ~/.ssh $(report) header "Copying public keys" @@ -25,11 +16,18 @@ update: $(report) pass "Copied $$i" done -remove: +down: $(report) header "Removing ssh sym-links" $(rm_link) $(CONFIG_TRGT) $(report) warn "NOTE: All keys still remain." +init: + $(report) header "Setting up ssh" + $(mk_link) $(CONFIG_SRC) $(CONFIG_TRGT) + $(mk_link) $(SRC_DIR)/public_keys ~/.ssh/public_keys + $(mk_link) $(SRC_DIR)/config.d ~/.ssh/config.d + $(MAKE) -C $(SRC_DIR) init_git_key + init_git_key: if [[ -e $(GIT_KEY) ]] ; then $(report) debug "$(GIT_KEY) already installed." diff --git a/sway/makefile b/sway/makefile index 21979f5..3254374 100644 --- a/sway/makefile +++ b/sway/makefile @@ -7,7 +7,27 @@ TARGET := $(XDG_DIR)/sway PATH_ICON_BOSTON := "$$HOME/.icons/Boston" PATH_GTK_ANT_NEBULA := "$$HOME/.theme/Ant-Nebula" -install: | init update +up: init + if (( ! $$+commands[swaymsg] )) ; then + $(report) debug "swaymsg not installed. Skipping." + else + $(report) header "Reloading sway" + swaymsg reload ; $(report) "sway reload" + $(MAKE) -C $(SRC) update_icons + $(MAKE) -C $(SRC) update_theme + fi + +down: + $(report) header "Removing sway" + $(rm_link) $(TARGET) + if [ -e $(PATH_ICON_BOSTON) ] ; then + rm -rf $(PATH_ICON_BOSTON) \ + ; $(report) "Removed $(PATH_ICON_BOSTON)" + fi + if [ -e $(PATH_GTK_ANT_NEBULA) ] ; then + rm -rf $(PATH_GTK_ANT_NEBULA) \ + ; $(report) "Removed $(PATH_GTK_ANT_NEBULA)" + fi init: if (( ! $$+commands[sway] )) ; then @@ -42,16 +62,6 @@ init_theme: $(report) debug "gsettings not installed. Skipping" fi -update: - if (( ! $$+commands[swaymsg] )) ; then - $(report) debug "swaymsg not installed. Skipping." - else - $(report) header "Reloading sway" - swaymsg reload ; $(report) "sway reload" - $(MAKE) -C $(SRC) update_icons - $(MAKE) -C $(SRC) update_theme - fi - update_icons: if [ ! -e $(PATH_ICON_BOSTON) ] ; then cd $(PATH_ICON_BOSTON) @@ -64,14 +74,3 @@ update_theme: git pull ; $(report) "Updated Ant Nebula GTK." fi -remove: - $(report) header "Removing sway" - $(rm_link) $(TARGET) - if [ -e $(PATH_ICON_BOSTON) ] ; then - rm -rf $(PATH_ICON_BOSTON) \ - ; $(report) "Removed $(PATH_ICON_BOSTON)" - fi - if [ -e $(PATH_GTK_ANT_NEBULA) ] ; then - rm -rf $(PATH_GTK_ANT_NEBULA) \ - ; $(report) "Removed $(PATH_GTK_ANT_NEBULA)" - fi diff --git a/tmux/makefile b/tmux/makefile index 1dcaa3d..b46b364 100644 --- a/tmux/makefile +++ b/tmux/makefile @@ -6,9 +6,7 @@ TARGET := ~/.tmux.conf include ../lib/shared.mk -install: | init update - -init: +up: if (( ! $$+commands[tmux] )) ; then $(report) header "tmux not installed" else @@ -16,8 +14,6 @@ init: $(mk_link) $(SOURCE) $(TARGET) fi -update: - -remove: +down: $(report) header "Removing tmux config" $(rm_link) $(TARGET) diff --git a/tridactyl/makefile b/tridactyl/makefile index fd4ee86..47ab695 100644 --- a/tridactyl/makefile +++ b/tridactyl/makefile @@ -5,9 +5,7 @@ include ../lib/shared.mk RC_TARGET := $(XDG_DIR)/tridactyl SCRIPTS_TARGET := ~/.local/share/tridactyl/scripts -install: | init update - -init: +up: if [[ $$OSTYPE = darwin* ]] ; then $(MAKE) -C $(SRC_DIR) setup elif (( $$+commands[firefox] )) ; then @@ -16,14 +14,13 @@ init: $(report) debug "This doesn't seem to be an env for Tridactyl. Skipping." fi +down: + $(report) header "Removing Tridaycl" + $(rm_link) $(RC_TARGET) + $(rm_link) $(SCRIPTS_TARGET) + setup: $(report) header "Setting up Tridaycl" $(mk_link) $(SRC_DIR) $(RC_TARGET) $(mk_link) $(SRC_DIR)/scripts $(SCRIPTS_TARGET) -update: - -remove: - $(report) header "Removing Tridaycl" - $(rm_link) $(RC_TARGET) - $(rm_link) $(SCRIPTS_TARGET) diff --git a/vim/makefile b/vim/makefile index d997d9e..9492db5 100644 --- a/vim/makefile +++ b/vim/makefile @@ -5,7 +5,22 @@ PLUG_PATH := $(SRC_DIR)/autoload/plug.vim include ../lib/shared.mk -install: | init update +up: init + if (( $$+commands[vim] )) ; then + $(report) header "Upgrading vim" + curl -fsLo $(PLUG_PATH) $(PLUG_URL) \ + ; $(report) "vim plug setup" + vim +PlugInstall +PlugUpdate +PlugClean +qall \ + ; $(report) "downloading/updating plugins" + stty sane # dropping in & out causes some weird tty behavior. + else + $(report) warn "cannot find vim?" + fi + +down: + $(report) header "Removing vim config" + $(rm_link) ~/.vimrc + $(rm_link) $(TARGET_DIR) init: if (( $$+commands[vim] )) ; then @@ -22,20 +37,3 @@ init: $(report) warn "cannot find vim?" fi -update: - if (( $$+commands[vim] )) ; then - $(report) header "Upgrading vim" - curl -fsLo $(PLUG_PATH) $(PLUG_URL) \ - ; $(report) "vim plug setup" - vim +PlugInstall +PlugUpdate +PlugClean +qall \ - ; $(report) "downloading/updating plugins" - stty sane # dropping in & out causes some weird tty behavior. - else - $(report) warn "cannot find vim?" - fi - - -remove: - $(report) header "Removing vim config" - $(rm_link) ~/.vimrc - $(rm_link) $(TARGET_DIR) diff --git a/waybar/makefile b/waybar/makefile index 5e70a54..81a629a 100644 --- a/waybar/makefile +++ b/waybar/makefile @@ -4,7 +4,17 @@ SRC := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) include ../lib/shared.mk TARGET := $(XDG_DIR)/waybar -install: | init update +up: init + if (( $$+commands[swaymsg] )) ; then + $(report) header "Reloading waybar" + swaymsg reload ; $(report) "sway reload" + else + $(report) debug "swaymsg not installed. Skipping." + fi + +down: + $(report) header "Removing waybar" + $(rm_link) $(TARGET) init: if (( $$+commands[waybar] )) ; then @@ -13,15 +23,3 @@ init: else $(report) debug "waybar not installed. Skipping." fi - -update: - if (( $$+commands[swaymsg] )) ; then - $(report) header "Reloading waybar" - swaymsg reload ; $(report) "sway reload" - else - $(report) debug "swaymsg not installed. Skipping." - fi - -remove: - $(report) header "Removing waybar" - $(rm_link) $(TARGET) diff --git a/zsh/makefile b/zsh/makefile index c52976b..27cdd4f 100644 --- a/zsh/makefile +++ b/zsh/makefile @@ -5,7 +5,27 @@ include ../lib/shared.mk ZSH_DIR := ~/.zsh ZPLUG_DIR := ~/.zplug -install: | init update +up: init + if [ ! -d $(ZPLUG_DIR) ] ; then + $(report) error "$(ZPLUG_DIR) doesn't exist - run init first." + return + fi + $(report) header "Updating zplug" + source $(ZPLUG_DIR)/init.zsh + source $(ZSH_DIR)/zplug + export zplugs + zplug install + zplug update ; $(report) "zplug upate" + zplug clean ; $(report) "zplug cleaned" + +down: + rm -rf $(ZPLUG_DIR) ; $(report) "deleting zplug dir" + $(rm_link) ~/.zprofile + $(rm_link) ~/.zlogin + $(rm_link) ~/.zshrc + $(rm_link) ~/.zsh + $(rm_link) ~/.zshenv + $(rm_link) ~/.zlogout init: $(info => Setting up zsh) @@ -28,25 +48,3 @@ init_zplug: git clone https://github.com/zplug/zplug $(ZPLUG_DIR) \ ; $(report) "zplug installed" - -update: - if [ ! -d $(ZPLUG_DIR) ] ; then - $(report) error "$(ZPLUG_DIR) doesn't exist - run init first." - return - fi - $(report) header "Updating zplug" - source $(ZPLUG_DIR)/init.zsh - source $(ZSH_DIR)/zplug - export zplugs - zplug install - zplug update ; $(report) "zplug upate" - zplug clean ; $(report) "zplug cleaned" - -remove: - rm -rf $(ZPLUG_DIR) ; $(report) "deleting zplug dir" - $(rm_link) ~/.zprofile - $(rm_link) ~/.zlogin - $(rm_link) ~/.zshrc - $(rm_link) ~/.zsh - $(rm_link) ~/.zshenv - $(rm_link) ~/.zlogout