diff --git a/Makefile b/Makefile index cc67b2e7..56e5d714 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,14 @@ ifndef PKGDOCDIR export PKGDOCDIR := $(DESTDIR)/share/doc/$(PKGNAME)/ endif +# Command aliases for homebrew and non-gnu compatibilities +ifndef GETOPT_CMD + export GETOPT_CMD := getopt +endif +ifndef READLINK_CMD + export READLINK_CMD := readlink +endif + SUBDIRS := src build: diff --git a/src/Makefile b/src/Makefile index 3515f23e..96ca9d0d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -44,6 +44,12 @@ MODULES=journal.sh\ FILES=$(MODULES) beakerlib.sh DEFDOCS=dictionary.vim docsman +define portable_sed + # See comment inside https://unix.stackexchange.com/a/92907 + sed -e $(1) $(2) > $(2).tmp + mv $(2).tmp $(2) +endef + .PHONY: install clean test ya.sh: @@ -65,6 +71,10 @@ install: build install -p profiling.sh $(DESTDIR)/share/beakerlib install -p -m 644 dictionary.vim $(DESTDIR)/share/beakerlib +# Patch installed beakerlib.sh + @$(call portable_sed, "s|declare -r __INTERNAL_GETOPT_CMD=\"getopt\"|declare -r __INTERNAL_GETOPT_CMD=\"${GETOPT_CMD}\"|", $(DESTDIR)/share/beakerlib/beakerlib.sh) + @$(call portable_sed, "s|declare -r __INTERNAL_READLINK_CMD=\"readlink\"|declare -r __INTERNAL_READLINK_CMD=\"${READLINK_CMD}\"|", $(DESTDIR)/share/beakerlib/beakerlib.sh) + install -p -m 644 xslt-templates/* $(DESTDIR)/share/beakerlib/xslt-templates install -p -m 644 vim/ftdetect/beakerlib.vim $(DESTDIR)/share/vim/vimfiles/after/ftdetect