-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.mk
63 lines (53 loc) · 1.74 KB
/
common.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# `make` with no arguments executes the first rule in the file.
.PHONY: install
install:
# Clear implicit suffix rules
.SUFFIXES:
# Homebrew, `mkdir -p` aren't safe to run in parallel
.NOTPARALLEL:
MAKEFLAGS = Lr
# -L = check symlinks' mtime and not their destinations'
# -r = don't use implicit rules
GNUMAKEFLAGS = --output-sync
# XDG base directories
XDG_CONFIG_HOME ?= $(wildcard ~/.config)
XDG_DATA_HOME ?= $(wildcard ~/.local/share)
XDG_CACHE_HOME ?= $(wildcard ~/.cache)
XDG_STATE_HOME ?= $(wildcard ~/.local/state)
XDG_BIN_HOME ?= $(abspath $(wildcard $(XDG_DATA_HOME)/../bin))
# Installation directories
prefix ?= $(HOME)
exec_prefix ?= $(prefix)
bindir ?= $(XDG_BIN_HOME)
datarootdir ?= $(XDG_DATA_HOME)
datadir ?= $(datarootdir)
libdir ?= $(exec_prefix)/lib
sbindir ?= $(exec_prefix)/sbin
sysconfdir ?= $(prefix)/etc
# Other important directories
GIT_STAGING := $(wildcard ~/src/github.com)
# Use Homebrew tools on macOS
OS = $(shell uname -s)
ifeq ($(OS),Darwin)
ifeq ($(shell command -v brew),/usr/local/bin/brew)
SHELL := /usr/local/bin/bash
GNUBIN := /usr/local/opt/coreutils/libexec/gnubin
else
SHELL := /bin/bash
GNUBIN := /usr/bin
endif
else
SHELL := /bin/bash
GNUBIN := /usr/bin
endif
# Every Makefile should define the variable INSTALL, which is the basic command
# for installing a file into the system.
INSTALL := $(GNUBIN)/install
# Every Makefile should also define the variables INSTALL_PROGRAM and
# INSTALL_DATA. Then it should use those variables as the commands for actual
# installation, for executables and non-executables respectively.
INSTALL_PROGRAM := $(INSTALL) -D --compare
INSTALL_DATA := $(INSTALL) -D --compare -m 644
# Additional commands
MKDIR := $(GNUBIN)/mkdir -p
LN := $(GNUBIN)/ln -s -r -f