diff options
author | xhe <xw897002528@gmail.com> | 2018-07-14 18:45:45 +0800 |
---|---|---|
committer | xhe <xw897002528@gmail.com> | 2018-07-14 18:55:04 +0800 |
commit | 7698cca6d5634ce0de4bb382e0535e1f02d7fb17 (patch) | |
tree | d892f4b2bd2de76957ec3e4aa706520e66caa589 | |
parent | 4d6a0a214304e463706704df177a5c8fe83d9ce9 (diff) | |
download | gettext-tiny-7698cca6d5634ce0de4bb382e0535e1f02d7fb17.tar.gz |
install: symlink m4 files to $(dataroot)/aclocal
follow https://github.com/sabotage-linux/gettext-tiny/issues/27.
According to @awilfox, GNU gettext will install m4 files to aclocal dir.
But gettext-tiny did not. So autoreconf just stops working and complains
that it can not find needed macros.
Suggested by rofl0r, symlinking all m4 files into $(dataroot)/aclocal is
a good idea. Save a little disk space.
-rw-r--r-- | Makefile | 22 | ||||
-rw-r--r-- | install.sh | 67 |
2 files changed, 80 insertions, 9 deletions
@@ -3,7 +3,9 @@ bindir=$(prefix)/bin includedir=$(prefix)/include libdir=$(prefix)/lib sysconfdir=$(prefix)/etc -datadir=$(prefix)/share/gettext-tiny +datarootdir=$(prefix)/share +datadir=$(datarootdir)/gettext-tiny +acdir=$(datarootdir)/aclocal ifeq ($(LIBINTL), MUSL) LIBSRC = libintl/libintl-musl.c @@ -36,13 +38,15 @@ AR ?= $(CROSS_COMPILE)ar RANLIB ?= $(CROSS_COMPILE)ranlib CC ?= $(CROSS_COMPILE)cc +INSTALL ?= ./install.sh + -include config.mak BUILDCFLAGS=$(CFLAGS) all: $(ALL_LIBS) $(ALL_TOOLS) -install: $(ALL_LIBS:lib%=$(DESTDIR)$(libdir)/lib%) $(ALL_INCLUDES:%=$(DESTDIR)$(includedir)/%) $(ALL_TOOLS:%=$(DESTDIR)$(bindir)/%) $(ALL_M4S:%=$(DESTDIR)$(datadir)/%) $(ALL_DATA:%=$(DESTDIR)$(datadir)/%) +install: $(ALL_LIBS:lib%=$(DESTDIR)$(libdir)/lib%) $(ALL_INCLUDES:%=$(DESTDIR)$(includedir)/%) $(ALL_TOOLS:%=$(DESTDIR)$(bindir)/%) $(ALL_M4S:%=$(DESTDIR)$(datadir)/%) $(ALL_M4S:%=$(DESTDIR)$(acdir)/%) $(ALL_DATA:%=$(DESTDIR)$(datadir)/%) clean: rm -f $(ALL_LIBS) @@ -70,18 +74,18 @@ autopoint: src/autopoint.in cat $< | sed 's,@datadir@,$(datadir),' > $@ $(DESTDIR)$(libdir)/%.a: %.a - install -D -m 755 $< $@ + $(INSTALL) -D -m 755 $< $@ $(DESTDIR)$(includedir)/%.h: include/%.h - install -D -m 644 $< $@ + $(INSTALL) -D -m 644 $< $@ $(DESTDIR)$(bindir)/%: % - install -D -m 755 $< $@ + $(INSTALL) -D -m 755 $< $@ $(DESTDIR)$(datadir)/%: % - install -D -m 644 $< $@ - -.PHONY: all clean install - + $(INSTALL) -D -m 644 $< $@ +$(DESTDIR)$(acdir)/%: % + $(INSTALL) -D -l ../$(subst $(datarootdir)/,,$(datadir))/$< $(subst m4/,,$@) +.PHONY: all clean install diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..0410883 --- /dev/null +++ b/install.sh @@ -0,0 +1,67 @@ +#!/bin/sh +# +# Written by Rich Felker, originally as part of musl libc. +# Multi-licensed under MIT, 0BSD, and CC0. +# +# This is an actually-safe install command which installs the new +# file atomically in the new location, rather than overwriting +# existing files. +# + +usage() { +printf "usage: %s [-D] [-l] [-m mode] src dest\n" "$0" 1>&2 +exit 1 +} + +mkdirp= +symlink= +mode=755 + +while getopts Dlm: name ; do +case "$name" in +D) mkdirp=yes ;; +l) symlink=yes ;; +m) mode=$OPTARG ;; +?) usage ;; +esac +done +shift $(($OPTIND - 1)) + +test "$#" -eq 2 || usage +src=$1 +dst=$2 +tmp="$dst.tmp.$$" + +case "$dst" in +*/) printf "%s: %s ends in /\n", "$0" "$dst" 1>&2 ; exit 1 ;; +esac + +set -C +set -e + +if test "$mkdirp" ; then +umask 022 +case "$2" in +*/*) mkdir -p "${dst%/*}" ;; +esac +fi + +trap 'rm -f "$tmp"' EXIT INT QUIT TERM HUP + +umask 077 + +if test "$symlink" ; then +ln -s "$1" "$tmp" +else +cat < "$1" > "$tmp" +chmod "$mode" "$tmp" +fi + +mv -f "$tmp" "$2" +test -d "$2" && { +rm -f "$2/$tmp" +printf "%s: %s is a directory\n" "$0" "$dst" 1>&2 +exit 1 +} + +exit 0 |