dotfiles/lib/shared.mk
James Patrick cc1893d6b5 Added SSH awareness.
This should be used with

```
ifndef IS_SSH
```

I will try and move IS_MAC and IS_LINUX to work with this as well. Issue I'm
having is or statements.
2019-05-16 20:13:40 -04:00

36 lines
1.0 KiB
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
return_val_truthy := && echo true || echo false
cmd_exist = $(shell (($$+commands[$1])) $(return_val_truthy) )
# 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
IS_SSH=${SSH_TTY}
# TURN THIS OFF FOR DEBUGGING
MAKEFLAGS += --silent
.PHONY: install update init remove