ref: a0a85448f88882e81a0adfc9bc67c761ccba2a95
parent: 6cd7862223d13fd0897c3fafc213dccf874b7101
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Oct 7 21:27:15 EDT 2021
build: Add support for DESTDIR PREFIX is used to mark what is going to be the final path where the program is going to be stored and where it will locate its resources. Package creators need a way to redirect all the installation to a directory that can be used as base doe a tar.gz file instead of installing all the files in the prefix destination.
--- a/Makefile
+++ b/Makefile
@@ -11,6 +11,7 @@
include $(PROJECTDIR)/scripts/rules.mk
PREFIX= $(HOME)
+ROOT=$(DESTDIR)$(PREFIX)
NODEP = 1
all:
@@ -36,10 +37,10 @@
+@$(MAKE) `$(SCRIPTDIR)/config` CONF=amd64-darwin libc libcrt
install-x86_64 install-amd64: amd64
- $(SCRIPTDIR)/install -p $(SCRIPTDIR)/proto.amd64 $(PREFIX)
+ $(SCRIPTDIR)/install -p $(SCRIPTDIR)/proto.amd64 $(ROOT)
uninstall-x86_64 uninstall-amd64:
- $(SCRIPTDIR)/uninstall -p $(SCRIPTDIR)/proto.amd64 $(PREFIX)
+ $(SCRIPTDIR)/uninstall -p $(SCRIPTDIR)/proto.amd64 $(ROOT)
#############################################################
# i386 rules
@@ -48,10 +49,10 @@
+@$(MAKE) `$(SCRIPTDIR)/config` CONF=i386-linux libc libcrt
install-i386: i386
- $(SCRIPTDIR)/install -p $(SCRIPTDIR)/proto.i386 $(PREFIX)
+ $(SCRIPTDIR)/install -p $(SCRIPTDIR)/proto.i386 $(ROOT)
uninstall-i386:
- $(SCRIPTDIR)/uninstall -p $(SCRIPTDIR)/proto.i386 $(PREFIX)
+ $(SCRIPTDIR)/uninstall -p $(SCRIPTDIR)/proto.i386 $(ROOT)
#############################################################
# ppc rules
@@ -60,10 +61,10 @@
+@$(MAKE) `$(SCRIPTDIR)/config` CONF=ppc-linux libc libcrt
install-ppc: ppc
- $(SCRIPTDIR)/install -p $(SCRIPTDIR)/proto.ppc $(PREFIX)
+ $(SCRIPTDIR)/install -p $(SCRIPTDIR)/proto.ppc $(ROOT)
uninstall-ppc:
- $(SCRIPTDIR)/uninstall -p $(SCRIPTDIR)/proto.ppc $(PREFIX)
+ $(SCRIPTDIR)/uninstall -p $(SCRIPTDIR)/proto.ppc $(ROOT)
#############################################################
# arm rules
@@ -72,10 +73,10 @@
+@$(MAKE) `$(SCRIPTDIR)/config` CONF=arm-linux libc libcrt
install-arm: arm
- $(SCRIPTDIR)/install -p $(SCRIPTDIR)/proto.arm $(PREFIX)
+ $(SCRIPTDIR)/install -p $(SCRIPTDIR)/proto.arm $(ROOT)
uninstall-arm:
- $(SCRIPTDIR)/uninstall -p $(SCRIPTDIR)/proto.arm $(PREFIX)
+ $(SCRIPTDIR)/uninstall -p $(SCRIPTDIR)/proto.arm $(ROOT)
#############################################################
# arm64 rules
@@ -84,10 +85,10 @@
+@$(MAKE) `$(SCRIPTDIR)/config` CONF=arm64-linux libc libcrt
install-arm64: arm64
- $(SCRIPTDIR)/install -p $(SCRIPTDIR)/proto.arm64 $(PREFIX)
+ $(SCRIPTDIR)/install -p $(SCRIPTDIR)/proto.arm64 $(ROOT)
uninstall-arm64:
- $(SCRIPTDIR)/uninstall -p $(SCRIPTDIR)/proto.arm64 $(PREFIX)
+ $(SCRIPTDIR)/uninstall -p $(SCRIPTDIR)/proto.arm64 $(ROOT)
toolchain: dirs src
libc: dirs src/libc
--- a/scripts/install
+++ b/scripts/install
@@ -10,22 +10,22 @@
shift 2
;;
-*)
- echo usage: install [-p proto] prefix >&2
+ echo usage: install [-p proto] root >&2
exit 1
;;
esac
done
-prefix=${1?'prefix missed'}
+root=${1?'root missed'}
while read type perm name
do
case $type in
d)
- mkdir -p $prefix/$name
+ mkdir -p $root/$name
;;
f)
- cp $name $prefix/$name
+ cp $name $root/$name
;;
*)
echo install: wrong entry type >&2
@@ -33,5 +33,5 @@
;;
esac
- chmod $perm $prefix/$name
+ chmod $perm $root/$name
done < ${proto:-scripts/proto.all}
--- a/scripts/uninstall
+++ b/scripts/uninstall
@@ -10,13 +10,13 @@
shift 2
;;
-*)
- echo usage: uninstall [-p proto] prefix >&2
+ echo usage: uninstall [-p proto] root >&2
exit 1
;;
esac
done
-prefix=${1?'prefix missed'}
+root=${1?'root missed'}
proto=${proto:-scripts/proto.all}
while read type perm name
@@ -27,7 +27,7 @@
continue
;;
f)
- rm -f $prefix/$name
+ rm -f $root/$name
;;
*)
echo install: wrong entry type >&2
@@ -40,7 +40,10 @@
do
case $type in
d)
- rmdir $prefix/$name || :
+ if test `ls $root/$name | wc -l` -eq 0
+ then
+ rmdir $root/$name
+ fi
;;
esac
done