Skip to content

Commit

Permalink
Set LIB_REL_BIN in mlton script when installing
Browse files Browse the repository at this point in the history
See a3cccd8.

Some systems (e.g., x86_64 Fedora) will set `libdir` to `/usr/lib64`, so it is
necessary to compute and set the relative path from `TBIN` to `TLIB` when
installing `$(TBIN)/mlton`.

While GNU `realpath` would suffice, it does not exist on MacOS (and
other *BSD?).  A small, probably not entirely robust, shell command is
constructed to compute relative paths.
  • Loading branch information
MatthewFluet committed Feb 15, 2018
1 parent fac53ab commit c652a62
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Makefile.binary
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ RM := rm -rf

######################################################################

TGT_REL_SRC = ref="$(1)" pos="$(2)" down=; ref="$${ref%%/}" pos="$${pos%%/}"; while :; do test "$$pos" = '/' && break ; case "$$ref" in "$$pos"/*) break;; esac; down="../$$down"; pos="$${pos%/*}"; done; echo "$$down$${ref\#\#$$pos/}"

SBIN := $(ROOT)/bin
SLIB := $(ROOT)/lib/mlton
SMAN := $(ROOT)/share/man/man1
SDOC := $(ROOT)/share/doc/mlton

SLIB_REL_SBIN := $(shell $(call TGT_REL_SRC,$(SLIB),$(SBIN)))

prefix := $(PREFIX)
exec_prefix := $(prefix)
bindir := $(exec_prefix)/bin
Expand All @@ -45,10 +49,16 @@ TMAN := $(man1dir)
TDOC := $(docdir)
TEXM := $(TDOC)/examples

TLIB_REL_TBIN := $(shell $(call TGT_REL_SRC,$(TLIB),$(TBIN)))

.PHONY: install
install:
$(MKDIR) "$(TBIN)" "$(TLIB)" "$(TMAN)" "$(TDOC)"
$(CP) "$(SBIN)/." "$(TBIN)/"
$(SED) \
-e "s;^LIB_REL_BIN=.*;LIB_REL_BIN=\"$(TLIB_REL_TBIN)\";" \
< "$(SBIN)/mlton" > "$(TBIN)/mlton"
chmod a+x "$(TBIN)/mlton"
$(CP) "$(SLIB)/." "$(TLIB)/"
$(CP) "$(SMAN)/." "$(TMAN)/"
if [ -d "$(SDOC)" ]; then $(CP) "$(SDOC)/." "$(TDOC)/"; fi
Expand Down

0 comments on commit c652a62

Please sign in to comment.