summaryrefslogtreecommitdiff
path: root/system/gettext-tiny/m4-installation.patch
blob: f55a03b0837502e98e53d5d2032a40da6d6bc28d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
From 7698cca6d5634ce0de4bb382e0535e1f02d7fb17 Mon Sep 17 00:00:00 2001
From: xhe <xw897002528@gmail.com>
Date: Sat, 14 Jul 2018 18:45:45 +0800
Subject: [PATCH] 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.
---
 Makefile   | 22 ++++++++++++---------
 install.sh | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+), 9 deletions(-)
 create mode 100644 install.sh

diff --git a/Makefile b/Makefile
index 7842c0f..927d02e 100644
--- a/Makefile
+++ b/Makefile
@@ -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 100755
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