Skip to content

Commit 7698cca

Browse files
committed
install: symlink m4 files to $(dataroot)/aclocal
follow #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.
1 parent 4d6a0a2 commit 7698cca

File tree

2 files changed

+80
-9
lines changed

2 files changed

+80
-9
lines changed

Makefile

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ bindir=$(prefix)/bin
33
includedir=$(prefix)/include
44
libdir=$(prefix)/lib
55
sysconfdir=$(prefix)/etc
6-
datadir=$(prefix)/share/gettext-tiny
6+
datarootdir=$(prefix)/share
7+
datadir=$(datarootdir)/gettext-tiny
8+
acdir=$(datarootdir)/aclocal
79

810
ifeq ($(LIBINTL), MUSL)
911
LIBSRC = libintl/libintl-musl.c
@@ -36,13 +38,15 @@ AR ?= $(CROSS_COMPILE)ar
3638
RANLIB ?= $(CROSS_COMPILE)ranlib
3739
CC ?= $(CROSS_COMPILE)cc
3840

41+
INSTALL ?= ./install.sh
42+
3943
-include config.mak
4044

4145
BUILDCFLAGS=$(CFLAGS)
4246

4347
all: $(ALL_LIBS) $(ALL_TOOLS)
4448

45-
install: $(ALL_LIBS:lib%=$(DESTDIR)$(libdir)/lib%) $(ALL_INCLUDES:%=$(DESTDIR)$(includedir)/%) $(ALL_TOOLS:%=$(DESTDIR)$(bindir)/%) $(ALL_M4S:%=$(DESTDIR)$(datadir)/%) $(ALL_DATA:%=$(DESTDIR)$(datadir)/%)
49+
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)/%)
4650

4751
clean:
4852
rm -f $(ALL_LIBS)
@@ -70,18 +74,18 @@ autopoint: src/autopoint.in
7074
cat $< | sed 's,@datadir@,$(datadir),' > $@
7175

7276
$(DESTDIR)$(libdir)/%.a: %.a
73-
install -D -m 755 $< $@
77+
$(INSTALL) -D -m 755 $< $@
7478

7579
$(DESTDIR)$(includedir)/%.h: include/%.h
76-
install -D -m 644 $< $@
80+
$(INSTALL) -D -m 644 $< $@
7781

7882
$(DESTDIR)$(bindir)/%: %
79-
install -D -m 755 $< $@
83+
$(INSTALL) -D -m 755 $< $@
8084

8185
$(DESTDIR)$(datadir)/%: %
82-
install -D -m 644 $< $@
83-
84-
.PHONY: all clean install
85-
86+
$(INSTALL) -D -m 644 $< $@
8687

88+
$(DESTDIR)$(acdir)/%: %
89+
$(INSTALL) -D -l ../$(subst $(datarootdir)/,,$(datadir))/$< $(subst m4/,,$@)
8790

91+
.PHONY: all clean install

install.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/sh
2+
#
3+
# Written by Rich Felker, originally as part of musl libc.
4+
# Multi-licensed under MIT, 0BSD, and CC0.
5+
#
6+
# This is an actually-safe install command which installs the new
7+
# file atomically in the new location, rather than overwriting
8+
# existing files.
9+
#
10+
11+
usage() {
12+
printf "usage: %s [-D] [-l] [-m mode] src dest\n" "$0" 1>&2
13+
exit 1
14+
}
15+
16+
mkdirp=
17+
symlink=
18+
mode=755
19+
20+
while getopts Dlm: name ; do
21+
case "$name" in
22+
D) mkdirp=yes ;;
23+
l) symlink=yes ;;
24+
m) mode=$OPTARG ;;
25+
?) usage ;;
26+
esac
27+
done
28+
shift $(($OPTIND - 1))
29+
30+
test "$#" -eq 2 || usage
31+
src=$1
32+
dst=$2
33+
tmp="$dst.tmp.$$"
34+
35+
case "$dst" in
36+
*/) printf "%s: %s ends in /\n", "$0" "$dst" 1>&2 ; exit 1 ;;
37+
esac
38+
39+
set -C
40+
set -e
41+
42+
if test "$mkdirp" ; then
43+
umask 022
44+
case "$2" in
45+
*/*) mkdir -p "${dst%/*}" ;;
46+
esac
47+
fi
48+
49+
trap 'rm -f "$tmp"' EXIT INT QUIT TERM HUP
50+
51+
umask 077
52+
53+
if test "$symlink" ; then
54+
ln -s "$1" "$tmp"
55+
else
56+
cat < "$1" > "$tmp"
57+
chmod "$mode" "$tmp"
58+
fi
59+
60+
mv -f "$tmp" "$2"
61+
test -d "$2" && {
62+
rm -f "$2/$tmp"
63+
printf "%s: %s is a directory\n" "$0" "$dst" 1>&2
64+
exit 1
65+
}
66+
67+
exit 0

0 commit comments

Comments
 (0)