dotfiles/lib/shared.mk
James Patrick e49934c99d Adding shared makefile logic and helper scripts
Shared logic can be imported via `include ../lib/shared.mk`
Helper functions include 3 current opperations

1. mk_link:: This will create a symbolic link if the file doesn't already exist.
2. rm_link:: Will remove the link if it is a symlink.
3. report :: This color codes the status of a message and adds a leading symbol.

report also can be called with `LAST_RETURN=$? report "message"`
and will expand this to be either `report info "message"` Or `report error
"message"` based on the last return value.
Current status are info, warn, and error.
2019-04-27 18:09:36 -04:00

33 lines
976 B
Makefile

# This will make heavy use of the "$+commands[cmd]" function in bash. Make sure its installed.
_SHELL := $(shell which zsh )
ifndef _SHELL
$(error ZSH is not installed on this machine. This makefile requires ZSH features)
endif
SHELL := $(_SHELL)
# Helper scripts for setting up and taking down links.
LIB_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
mk_link := $(LIB_DIR)/helper/mk_link
rm_link := $(LIB_DIR)/helper/rm_link
report := LAST_RETURN=$$? $(LIB_DIR)/helper/report
cmd_exist = $(shell (($$+commands[$1])) && echo true || echo false )
# Shortcut for the XDG dir if it exist. default to ~/.confg
XDG_DIR := $${XDG_CONFIG_DIR:-~/.config}
# Some things will OS specific.
# With this you can use `$(IS_MAC) && echo "I'm a Mac" || echo "I'm not a Mac"`
ifeq ($(shell uname), Darwin)
IS_MAC=true
else
IS_LINUX=true
endif
IS_MAC?=false
IS_LINUX?=false
# TURN THIS OFF FOR DEBUGGING
MAKEFLAGS += --silent
.PHONY: install update init remove