Skip to content

Commit

Permalink
Makefile improvements (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximbaz authored Mar 31, 2019
1 parent 07dc474 commit 2925002
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 48 deletions.
101 changes: 54 additions & 47 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
BIN ?= browserpass
VERSION ?= $(shell cat .version)

PREFIX ?= /usr
BIN_DIR = $(DESTDIR)$(PREFIX)/bin
LIB_DIR = $(DESTDIR)$(PREFIX)/lib
SHARE_DIR = $(DESTDIR)$(PREFIX)/share

GO_GCFLAGS := "all=-trimpath=${PWD}"
GO_ASMFLAGS := "all=-trimpath=${PWD}"
GO_LDFLAGS := "-extldflags ${LDFLAGS}"
Expand Down Expand Up @@ -65,30 +70,32 @@ dist: clean browserpass-linux64 browserpass-darwinx64 browserpass-openbsd64 brow
#######################
# For user installation

.PHONY: configure
configure:
sed -i "s|%%replace%%|$(BIN_DIR)/$(BIN)|" browser-files/chromium-host.json
sed -i "s|%%replace%%|$(BIN_DIR)/$(BIN)|" browser-files/firefox-host.json

.PHONY: install
install:
install -Dm755 -t "$(DESTDIR)/usr/bin/" $(BIN)
install -Dm644 -t "$(DESTDIR)/usr/lib/browserpass/" Makefile
install -Dm644 -t "$(DESTDIR)/usr/share/licenses/browserpass/" LICENSE
install -Dm644 -t "$(DESTDIR)/usr/share/doc/browserpass/" README.md

install -Dm644 browser-files/chromium-host.json "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json"
install -Dm644 browser-files/chromium-policy.json "$(DESTDIR)/usr/lib/browserpass/policies/chromium/$(APP_ID).json"
install -Dm644 browser-files/firefox-host.json "$(DESTDIR)/usr/lib/browserpass/hosts/firefox/$(APP_ID).json"
install -Dm755 -t "$(BIN_DIR)/" $(BIN)
install -Dm644 -t "$(LIB_DIR)/browserpass/" Makefile
install -Dm644 -t "$(SHARE_DIR)/licenses/browserpass/" LICENSE
install -Dm644 -t "$(SHARE_DIR)/doc/browserpass/" README.md

sed -i "s|%%replace%%|/usr/bin/$(BIN)|" "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json"
sed -i "s|%%replace%%|/usr/bin/$(BIN)|" "$(DESTDIR)/usr/lib/browserpass/hosts/firefox/$(APP_ID).json"
install -Dm644 browser-files/chromium-host.json "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json"
install -Dm644 browser-files/chromium-policy.json "$(LIB_DIR)/browserpass/policies/chromium/$(APP_ID).json"
install -Dm644 browser-files/firefox-host.json "$(LIB_DIR)/browserpass/hosts/firefox/$(APP_ID).json"

# Browser-specific hosts targets

.PHONY: hosts-chromium
hosts-chromium:
@case $(OS) in \
Linux) mkdir -p "/etc/chromium/native-messaging-hosts/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/etc/chromium/native-messaging-hosts/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "/etc/chromium/native-messaging-hosts/" \
;; \
Darwin) mkdir -p "/Library/Application Support/Chromium/NativeMessagingHosts/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Application Support/Chromium/NativeMessagingHosts/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Application Support/Chromium/NativeMessagingHosts/" \
;; \
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
esac
Expand All @@ -97,10 +104,10 @@ hosts-chromium:
hosts-chromium-user:
@case $(OS) in \
Linux|*BSD) mkdir -p "${HOME}/.config/chromium/NativeMessagingHosts/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/chromium/NativeMessagingHosts/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/chromium/NativeMessagingHosts/" \
;; \
Darwin) mkdir -p "${HOME}/Library/Application Support/Chromium/NativeMessagingHosts/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/Chromium/NativeMessagingHosts/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/Chromium/NativeMessagingHosts/" \
;; \
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
esac
Expand All @@ -109,10 +116,10 @@ hosts-chromium-user:
hosts-chrome:
@case $(OS) in \
Linux) mkdir -p "/etc/opt/chrome/native-messaging-hosts/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/etc/opt/chrome/native-messaging-hosts/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "/etc/opt/chrome/native-messaging-hosts/" \
;; \
Darwin) mkdir -p "/Library/Google/Chrome/NativeMessagingHosts/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Google/Chrome/NativeMessagingHosts/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Google/Chrome/NativeMessagingHosts/" \
;; \
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
esac
Expand All @@ -121,10 +128,10 @@ hosts-chrome:
hosts-chrome-user:
@case $(OS) in \
Linux|*BSD) mkdir -p "${HOME}/.config/google-chrome/NativeMessagingHosts/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/google-chrome/NativeMessagingHosts/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/google-chrome/NativeMessagingHosts/" \
;; \
Darwin) mkdir -p "${HOME}/Library/Application Support/Google/Chrome/NativeMessagingHosts/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/Google/Chrome/NativeMessagingHosts/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/Google/Chrome/NativeMessagingHosts/" \
;; \
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
esac
Expand All @@ -133,10 +140,10 @@ hosts-chrome-user:
hosts-vivaldi:
@case $(OS) in \
Linux) mkdir -p "/etc/opt/vivaldi/native-messaging-hosts/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/etc/opt/vivaldi/native-messaging-hosts/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "/etc/opt/vivaldi/native-messaging-hosts/" \
;; \
Darwin) mkdir -p "/Library/Application Support/Vivaldi/NativeMessagingHosts/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Application Support/Vivaldi/NativeMessagingHosts/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Application Support/Vivaldi/NativeMessagingHosts/" \
;; \
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
esac
Expand All @@ -145,10 +152,10 @@ hosts-vivaldi:
hosts-vivaldi-user:
@case $(OS) in \
Linux|*BSD) mkdir -p "${HOME}/.config/vivaldi/NativeMessagingHosts/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/vivaldi/NativeMessagingHosts/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/vivaldi/NativeMessagingHosts/" \
;; \
Darwin) mkdir -p "${HOME}/Library/Application Support/Vivaldi/NativeMessagingHosts/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/Vivaldi/NativeMessagingHosts/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/Vivaldi/NativeMessagingHosts/" \
;; \
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
esac
Expand All @@ -157,10 +164,10 @@ hosts-vivaldi-user:
hosts-brave:
@case $(OS) in \
Linux) mkdir -p "/etc/opt/brave/native-messaging-hosts/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/etc/opt/brave/native-messaging-hosts/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "/etc/opt/brave/native-messaging-hosts/" \
;; \
Darwin) mkdir -p "/Library/Application Support/BraveSoftware/Brave-Browser/NativeMessagingHosts/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Application Support/BraveSoftware/Brave-Browser/NativeMessagingHosts/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Application Support/BraveSoftware/Brave-Browser/NativeMessagingHosts/" \
;; \
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
esac
Expand All @@ -169,22 +176,22 @@ hosts-brave:
hosts-brave-user:
@case $(OS) in \
Linux|*BSD) mkdir -p "${HOME}/.config/BraveSoftware/Brave-Browser/NativeMessagingHosts/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/BraveSoftware/Brave-Browser/NativeMessagingHosts/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/BraveSoftware/Brave-Browser/NativeMessagingHosts/" \
;; \
Darwin) mkdir -p "${HOME}/Library/Application Support/BraveSoftware/Brave-Browser/NativeMessagingHosts/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/BraveSoftware/Brave-Browser/NativeMessagingHosts/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/BraveSoftware/Brave-Browser/NativeMessagingHosts/" \
;; \
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
esac

.PHONY: hosts-firefox
hosts-firefox:
@case $(OS) in \
Linux) mkdir -p "/usr/lib/mozilla/native-messaging-hosts/"; \
ln -sf "/usr/lib/browserpass/hosts/firefox/$(APP_ID).json" "/usr/lib/mozilla/native-messaging-hosts/" \
Linux) mkdir -p "$(LIB_DIR)/mozilla/native-messaging-hosts/"; \
ln -sf "$(LIB_DIR)/browserpass/hosts/firefox/$(APP_ID).json" "/usr/lib/mozilla/native-messaging-hosts/" \
;; \
Darwin) mkdir -p "/Library/Application Support/Mozilla/NativeMessagingHosts/"; \
ln -sf "/usr/lib/browserpass/hosts/firefox/$(APP_ID).json" "/Library/Application Support/Mozilla/NativeMessagingHosts/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/firefox/$(APP_ID).json" "/Library/Application Support/Mozilla/NativeMessagingHosts/" \
;; \
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
esac
Expand All @@ -193,10 +200,10 @@ hosts-firefox:
hosts-firefox-user:
@case $(OS) in \
Linux|*BSD) mkdir -p "${HOME}/.mozilla/native-messaging-hosts/"; \
ln -sf "/usr/lib/browserpass/hosts/firefox/$(APP_ID).json" "${HOME}/.mozilla/native-messaging-hosts/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/firefox/$(APP_ID).json" "${HOME}/.mozilla/native-messaging-hosts/" \
;; \
Darwin) mkdir -p "${HOME}/Library/Application Support/Mozilla/NativeMessagingHosts/"; \
ln -sf "/usr/lib/browserpass/hosts/firefox/$(APP_ID).json" "${HOME}/Library/Application Support/Mozilla/NativeMessagingHosts/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/firefox/$(APP_ID).json" "${HOME}/Library/Application Support/Mozilla/NativeMessagingHosts/" \
;; \
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
esac
Expand All @@ -207,10 +214,10 @@ hosts-firefox-user:
policies-chromium:
@case $(OS) in \
Linux) mkdir -p "/etc/chromium/policies/managed/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/etc/chromium/policies/managed/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "/etc/chromium/policies/managed/" \
;; \
Darwin) mkdir -p "/Library/Application Support/Chromium/policies/managed/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Application Support/Chromium/policies/managed/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Application Support/Chromium/policies/managed/" \
;; \
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
esac
Expand All @@ -219,10 +226,10 @@ policies-chromium:
policies-chromium-user:
@case $(OS) in \
Linux|*BSD) mkdir -p "${HOME}/.config/chromium/policies/managed/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/chromium/policies/managed/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/chromium/policies/managed/" \
;; \
Darwin) mkdir -p "${HOME}/Library/Application Support/Chromium/policies/managed/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/Chromium/policies/managed/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/Chromium/policies/managed/" \
;; \
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
esac
Expand All @@ -231,10 +238,10 @@ policies-chromium-user:
policies-chrome:
@case $(OS) in \
Linux) mkdir -p "/etc/opt/chrome/policies/managed/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/etc/opt/chrome/policies/managed/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "/etc/opt/chrome/policies/managed/" \
;; \
Darwin) mkdir -p "/Library/Google/Chrome/policies/managed/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Google/Chrome/policies/managed/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Google/Chrome/policies/managed/" \
;; \
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
esac
Expand All @@ -243,10 +250,10 @@ policies-chrome:
policies-chrome-user:
@case $(OS) in \
Linux|*BSD) mkdir -p "${HOME}/.config/google-chrome/policies/managed/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/google-chrome/policies/managed/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/google-chrome/policies/managed/" \
;; \
Darwin) mkdir -p "${HOME}/Library/Application Support/Google/Chrome/policies/managed/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/Google/Chrome/policies/managed/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/Google/Chrome/policies/managed/" \
;; \
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
esac
Expand All @@ -255,10 +262,10 @@ policies-chrome-user:
policies-vivaldi:
@case $(OS) in \
Linux) mkdir -p "/etc/opt/vivaldi/policies/managed/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/etc/opt/vivaldi/policies/managed/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "/etc/opt/vivaldi/policies/managed/" \
;; \
Darwin) mkdir -p "/Library/Application Support/Vivaldi/policies/managed/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Application Support/Vivaldi/policies/managed/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Application Support/Vivaldi/policies/managed/" \
;; \
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
esac
Expand All @@ -267,10 +274,10 @@ policies-vivaldi:
policies-vivaldi-user:
@case $(OS) in \
Linux|*BSD) mkdir -p "${HOME}/.config/vivaldi/policies/managed/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/vivaldi/policies/managed/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/vivaldi/policies/managed/" \
;; \
Darwin) mkdir -p "${HOME}/Library/Application Support/Vivaldi/policies/managed/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/Vivaldi/policies/managed/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/Vivaldi/policies/managed/" \
;; \
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
esac
Expand All @@ -279,10 +286,10 @@ policies-vivaldi-user:
policies-brave:
@case $(OS) in \
Linux) mkdir -p "/etc/opt/brave/policies/managed/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/etc/opt/brave/policies/managed/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "/etc/opt/brave/policies/managed/" \
;; \
Darwin) mkdir -p "/Library/Application Support/BraveSoftware/Brave-Browser/policies/managed/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Application Support/BraveSoftware/Brave-Browser/policies/managed/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Application Support/BraveSoftware/Brave-Browser/policies/managed/" \
;; \
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
esac
Expand All @@ -291,10 +298,10 @@ policies-brave:
policies-brave-user:
@case $(OS) in \
Linux|*BSD) mkdir -p "${HOME}/.config/BraveSoftware/Brave-Browser/policies/managed/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/BraveSoftware/Brave-Browser/policies/managed/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/BraveSoftware/Brave-Browser/policies/managed/" \
;; \
Darwin) mkdir -p "${HOME}/Library/Application Support/BraveSoftware/Brave-Browser/policies/managed/"; \
ln -sf "/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/BraveSoftware/Brave-Browser/policies/managed/" \
ln -sf "$(LIB_DIR)/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/BraveSoftware/Brave-Browser/policies/managed/" \
;; \
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
esac
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Primary key fingerprint: EB4F 9E5A 60D3 2232 BB52 150C 12C8 7A28 FEAC 6B20

Unpack the archive. If you decided to compile the application yourself, refer to the [Building the app](#building-the-app) section on how to do so. Once complete, continue with the steps below.

Install the app using `sudo make install` (if you compiled it using `make browserpass`) or `sudo make BIN=browserpass-XXXX install` (if you downloaded a release with pre-built binary).
Configure the hosts json files using `make configure` and then install the app using `sudo make install` (if you compiled it using `make browserpass`) or `sudo make BIN=browserpass-XXXX install` (if you downloaded a release with pre-built binary). Both `configure` and `install` targets respect `PREFIX` and `DESTDIR` parameters if you want to customize the install location (e.g. to avoid `sudo`).

Finally proceed to the [Configure browsers](#configure-browsers) section.

Expand Down

0 comments on commit 2925002

Please sign in to comment.