dotfiles/zsh/makefile
James Patrick a3b2955e60 Fixed issue stemming from eval order in make if statement.
So I found a rather weird issue. The makefile was evaling the
conditional of a target before that target is called.

`make install` is a empty target with a ordered dependency: `init` and
`update`. In the `init` script section it will install the `~/.zplug`
zsh dependency, and the update script checks to see if that target
exist, aborting if it doesn't. The issue is that running `make install`
will install the `~/.zplug` dir, then report that the dir doesn't exist.
Where running `make init && make update` will work as expected.

There is probably some flag in make to resolve this, but I was unable to
to find any documentation for this.
2019-09-05 15:21:41 +00:00

40 lines
1.1 KiB
Makefile

SRC := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
include ../lib/shared.mk
ZSH_DIR := ~/.zsh
ZPLUG_DIR := ~/.zplug
install: | init update
init:
$(info => Setting up zsh)
ifeq ($(shell [ ! -e $(ZPLUG_DIR) ] $(return_val_truthy) ), true)
export ZPLUG_HOME=$(ZPLUG_DIR) \
; git clone https://github.com/zplug/zplug $(ZPLUG_DIR) \
; $(report) "zplug installed"
endif
$(mk_link) $(SRC) ~/.zsh
$(mk_link) $(ZSH_DIR)/zshrc ~/.zshrc
$(mk_link) $(ZSH_DIR)/zlogin ~/.zlogin
$(mk_link) $(ZSH_DIR)/zprofile ~/.zprofile
$(mk_link) $(ZSH_DIR)/zshenv ~/.zshenv
chmod 700 $(ZSH_DIR)/transient
update:
[ -e $(ZPLUG_DIR) ] \
&& ( echo "=> Updating zplug" \
source $(ZPLUG_DIR)/init.zsh ; source $(ZSH_DIR)/zplug ; zplug install ; zplug update ) \
|| $(report) warn "No zplug install detected. Skipping."
remove:
ifeq ($(shell [ -e $(ZPLUG_DIR) ] $(return_val_truthy) ), true)
$(report) warn "Leaving $(ZPLUG_DIR) directory."
endif
$(info => Removing zsh)
$(rm_link) ~/.zprofile
$(rm_link) ~/.zlogin
$(rm_link) ~/.zshrc
$(rm_link) ~/.zsh
$(rm_link) ~/.zshenv