aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorJoe Richey <joerichey@google.com>2019-01-19 19:27:30 -0800
committerJoe Richey <joerichey@google.com>2019-01-19 19:27:30 -0800
commitae476d1f2354de43d656d0d3767c2a31017e5985 (patch)
treea164aa6ff3ada2ce3d9c4efea2bbe086a3d6e1e4 /Makefile
parent509bb4d450cdd923bf09d05a5622cb6e98646bce (diff)
Install pam modules/configs to the right location
Per the FHS, manually installed programs should go under /usr/local. This change also makes it easier to change the global installation prefix. For example, package managers should set PREFIX=/usr
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile29
1 files changed, 17 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 6e84df6..8c691a5 100644
--- a/Makefile
+++ b/Makefile
@@ -105,7 +105,7 @@ lint: $(BIN)/golint $(BIN)/staticcheck $(BIN)/misspell
misspell -source=text $(FILES)
clean:
- rm -f $(BIN)/$(NAME) $(PAM_MODULE) $(TOOLS) coverage.out $(COVERAGE_FILES)
+ rm -f $(BIN)/$(NAME) $(PAM_MODULE) $(TOOLS) coverage.out $(COVERAGE_FILES) $(PAM_CONFIG)
###### Testing Commands (setup/teardown require sudo) ######
.PHONY: test test-setup test-teardown
@@ -144,23 +144,28 @@ coverage.out: $(BIN)/gocovmerge $(COVERAGE_FILES)
.PHONY: install install-bin install-pam uninstall
install: install-bin install-pam
-INSTALL := sudo install
-DESTDIR := /usr/local/bin
-PAM_MODULE_DIR := /lib/security
-PAM_CONFIG_DIR := /usr/share/pam-configs
+PREFIX := /usr/local
+DESTDIR := $(PREFIX)/bin
install-bin: $(BIN)/$(NAME)
- $(INSTALL) -d $(DESTDIR)
- $(INSTALL) $< $(DESTDIR)
+ install -d $(DESTDIR)
+ install $< $(DESTDIR)
+
+PAM_MODULE_DIR := $(PREFIX)/lib/security
+PAM_INSTALL_PATH := $(PAM_MODULE_DIR)/$(PAM_NAME).so
+PAM_CONFIG := $(BIN)/config
+PAM_CONFIG_DIR := $(PREFIX)/share/pam-configs
install-pam: $(PAM_MODULE)
- $(INSTALL) -d $(PAM_MODULE_DIR)
- $(INSTALL) $< $(PAM_MODULE_DIR)
- $(INSTALL) -d $(PAM_CONFIG_DIR)
- $(INSTALL) $(PAM_NAME)/config $(PAM_CONFIG_DIR)/$(NAME)
+ install -d $(PAM_MODULE_DIR)
+ install $(PAM_MODULE) $(PAM_MODULE_DIR)
+
+ m4 --define=PAM_INSTALL_PATH=$(PAM_INSTALL_PATH) < $(PAM_NAME)/config > $(PAM_CONFIG)
+ install -d $(PAM_CONFIG_DIR)
+ install $(PAM_CONFIG) $(PAM_CONFIG_DIR)/$(NAME)
uninstall:
- rm -f $(DESTDIR)/$(NAME) $(PAM_MODULE_DIR)/$(PAM_MODULE) $(PAM_CONFIG_DIR)/$(NAME)
+ rm -f $(DESTDIR)/$(NAME) $(PAM_INSTALL_PATH) $(PAM_CONFIG_DIR)/$(NAME)
#### Tool Building Commands ####
TOOLS := $(addprefix $(BIN)/,protoc golint protoc-gen-go goimports staticcheck gocovmerge misspell)