diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b886ac0 --- /dev/null +++ b/Makefile @@ -0,0 +1,146 @@ +# Makefile +# Eryn Wells +# + +.MAIN : essentials +essentials : git-dotfiles nvim-dotfiles tmux-dotfiles zsh-dotfiles +extras : emacs-dotfiles fish-dotfiles hg-dotfiles mutt-dotfiles nethack-dotfiles +all : essentials extras + +DOTFILES_ROOT ?= $(.PARSEDIR) + +INSTALL != which install +INSTALL_FLAGS := -ls + +XDG_BIN_HOME ?= $(HOME)/.local/bin +XDG_CONFIG_HOME ?= $(HOME)/.config +XDG_STATE_HOME ?= $(HOME)/.local/state + +# Colors +BLUE = \\x1b[1;34m +WHITE = \\x1b[1;37m +RESET = \\x1b[0m + + +link-dotfile : .USE + @echo " [Linking] $(.TARGET)" + $(INSTALL) $(INSTALL_FLAGS) $(.ALLSRC) $(.TARGET) + +link-config-dir : .USE + @echo " [Linking] $(.TARGET)" + $(INSTALL) $(INSTALL_FLAGS) $(.ALLSRC) $(.TARGET) + +mk-state-dir : .USE + @echo " [Making] $(.TARGET)" + $(INSTALL) -d $(.TARGET) + +dotfile-group : .USE + +missing-binary : .USE + @echo "$(BLUE)==> $(WHITE)$(.TARGET:S/-dotfiles//)$(RESET)" + @echo "binary not found" + + +# +# Essentials +# +# This are always linked because they're core utilities for my daily terminal +# use. +# + +GIT_HOME := $(XDG_CONFIG_HOME)/git +git-config-home : $(GIT_HOME) +$(GIT_HOME) : link-config-dir $(DOTFILES_ROOT)/git + + +$(HOME)/.nethackrc : link-dotfile $(DOTFILES_ROOT)/nethackrc + + +NVIM_HOME := $(XDG_CONFIG_HOME)/nvim +nvim-config-home : $(NVIM_HOME) +$(NVIM_HOME) : link-config-dir $(DOTFILES_ROOT)/nvim + +NVIM_STATE_DIR := $(XDG_STATE_HOME)/nvim +NVIM_STATE_DIRS := \ + $(NVIM_STATE_DIR)/backup \ + $(NVIM_STATE_DIR)/shada \ + $(NVIM_STATE_DIR)/swap \ + $(NVIM_STATE_DIR)/undo + +$(NVIM_STATE_DIRS) : mk-state-dir +nvim-state-dirs : $(NVIM_STATE_DIRS) + + +TMUX_HOME := $(XDG_CONFIG_HOME)/tmux +tmux-config-home : $(TMUX_HOME) +$(TMUX_HOME) : link-config-dir $(DOTFILES_ROOT)/tmux + + +ZSH_CONFIG_FILES := $(HOME)/.zshenv $(HOME)/.zshrc $(HOME)/.zprofile +$(HOME)/.zshenv : link-dotfile $(DOTFILES_ROOT)/zsh/zshenv +$(HOME)/.zshrc : link-dotfile $(DOTFILES_ROOT)/zsh/zshrc +$(HOME)/.zprofile : link-dotfile $(DOTFILES_ROOT)/zsh/zprofile + + +git-dotfiles : dotfile-group git-config-home +nvim-dotfiles : dotfile-group nvim-config-home nvim-state-dirs +tmux-dotfiles : dotfile-group tmux-config-home +zsh-dotfiles : dotfile-group $(ZSH_CONFIG_FILES) + + +# +# Extras +# +# These are only installed if the binaries already exist on the system. +# + +HAS_EMACS != which emacs >/dev/null && echo YES || echo NO +HAS_FISH != which fish >/dev/null && echo YES || echo NO +HAS_HG != which hg >/dev/null && echo YES || echo NO +HAS_MUTT != which mutt >/dev/null && echo YES || echo NO +HAS_NETHACK != which nethack >/dev/null && echo YES || echo NO + + +.if $(HAS_EMACS) == "YES" +EMACS_HOME := $(XDG_CONFIG_HOME)/emacs +emacs-config-home : $(EMACS_HOME) +$(EMACS_HOME) : link-config-dir $(DOTFILES_ROOT)/emacs +emacs-dotfiles : dotfile-group emacs-config-home +.else +emacs-dotfiles : missing-binary +.endif + + +.if $(HAS_FISH) == "YES" +FISH_HOME := $(XDG_CONFIG_HOME)/fish +fish-config-home : $(FISH_HOME) +$(FISH_HOME) : link-config-dir $(DOTFILES_ROOT)/fish +fish-dotfiles : dotfile-group fish-config-home +.else +fish-dotfiles : missing-binary +.endif + + +.if $(HAS_HG) == "YES" +$(HOME)/.hgrc : link-dotfile $(DOTFILES_ROOT)/hgrc +hg-dotfiles : dotfile-group $(HOME)/.hgrc +.else +hg-dotfiles : missing-binary +.endif + + +.if $(HAS_MUTT) == "YES" +MUTT_HOME := $(XDG_CONFIG_HOME)/mutt +mutt-config-home : $(MUTT_HOME) +$(MUTT_HOME) : link-config-dir $(DOTFILES_ROOT)/mutt +mutt-dotfiles : dotfile-group mutt-config-home +.else +mutt-dotfiles : missing-binary +.endif + + +.if $(HAS_NETHACK) == "YES" +nethack-dotfiles : print-heading $(HOME)/.nethackrc +.else +nethack-dotfiles : missing-binary +.endif