commit 48a7ec5cbcf8cc7d8e67efa88f2a82e65c9fdce9
parent 414cbd96e99624dbd6bdc7fe44e837654c375482
Author: vaplv <vaplv@free.fr>
Date: Fri, 5 May 2023 22:10:51 +0200
Update of the POSIX Makefile installation target
Use a hand-crafted installation function to install files only if they
are out of date. This avoids unnecessary updates, especially for header
files which, when reinstalled, would otherwise force the recompilation
of any library using them, even if only their timestamp has been
updated, not their contents.
Diffstat:
2 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/Makefile b/Makefile
@@ -125,20 +125,15 @@ pkg:
@sed -e 's#@PREFIX@#$(PREFIX)#g' -e 's#@VERSION@#$(VERSION)#g' rsys.pc.in > rsys.pc
install: build_library pkg
- mkdir -p $(DESTDIR)$(PREFIX)/lib
- mkdir -p $(DESTDIR)$(PREFIX)/lib/pkgconfig
- mkdir -p $(DESTDIR)$(PREFIX)/include/rsys
- mkdir -p $(DESTDIR)$(PREFIX)/share/doc/rsys
- cp librsys.so $(DESTDIR)$(PREFIX)/lib
- cp COPYING README.md $(DESTDIR)$(PREFIX)/share/doc/rsys
- cp rsys.pc $(DESTDIR)$(PREFIX)/lib/pkgconfig
- cp $(API) $(DESTDIR)$(PREFIX)/include/rsys
+ @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib" librsys.so
+ @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/doc/rsys" COPYING README.md
+ @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib/pkgconfig" rsys.pc
+ @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/include/rsys" $(API)
uninstall:
rm -f $(DESTDIR)$(PREFIX)/lib/librsys.so
rm -f $(DESTDIR)$(PREFIX)/lib/pkgconfig/rsys.pc
rm -f $(DESTDIR)$(PREFIX)/share/doc/rsys/COPYING
- rm -f $(DESTDIR)$(PREFIX)/share/doc/rsys/COPYING.LESSER
rm -f $(DESTDIR)$(PREFIX)/share/doc/rsys/README.md
rm -f $$(echo $(API) | sed 's,src\/,$(DESTDIR)$(PREFIX)\/include\/rsys\/,g')
diff --git a/make.sh b/make.sh
@@ -52,6 +52,23 @@ run_test()
fi
}
+install()
+{
+ prefix=$1
+ shift 1
+
+ mkdir -p "${prefix}"
+ for i in "$@"; do
+ dst="${prefix}/${i##*/}"
+ if cmp -s "${i}" "${dst}"; then
+ printf "Up to date %s\n" "${dst}"
+ else
+ printf "Installing %s\n" "${dst}"
+ cp "${i}" "${prefix}"
+ fi
+ done
+}
+
clean_test()
{
for i in "$@"; do