Skip to contentSkip to conversation

Support "make install"

PATCH New Ross Lagerwall 1 participant 1 message Jul 14, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Support "make install"

Add rules to support using "make install".

Use "make install DESTDIR=... PREFIX=..." to customize the installation path.

---
 Makefile        | 10 ++++++++++
 livepatch-build | 20 +++++++++++++++++---
 2 files changed, 27 insertions(+), 3 deletions(-)
Makefile +10 -0
index aa5d5b0..f96b150 100644
@@ -1,5 +1,9 @@
 SHELL = /bin/sh
 CC    = gcc
+INSTALL = install
+PREFIX ?= /usr/local
+BINDIR = $(DESTDIR)$(PREFIX)/bin
+LIBEXECDIR = $(DESTDIR)$(PREFIX)/libexec/livepatch-build-tools
 
 .PHONY: all install clean
 .DEFAULT: all
@@ -25,5 +29,11 @@ create-diff-object: $(CREATE_DIFF_OBJECT_OBJS)
 prelink: $(PRELINK_OBJS)
 	$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
 
+install: all
+	$(INSTALL) -d $(LIBEXECDIR)
+	$(INSTALL) $(TARGETS) livepatch-gcc $(LIBEXECDIR)
+	$(INSTALL) -d $(BINDIR)
+	$(INSTALL) livepatch-build $(BINDIR)
+
 clean:
 	$(RM) $(TARGETS) $(CREATE_DIFF_OBJECT_OBJS) $(PRELINK_OBJS) *.d insn/*.d
livepatch-build +17 -3
index 8dc8889..5ef2c88 100755
@@ -49,6 +49,18 @@ die() {
     exit 1
 }
 
+find_tools() {
+    if [[ -e "$SCRIPTDIR/create-diff-object" ]]; then
+        # Running from source tree
+        TOOLSDIR="$SCRIPTDIR"
+    elif [[ -e "$SCRIPTDIR/../libexec/livepatch-build-tools/create-diff-object" ]]; then
+        # Running installed
+        TOOLSDIR="$(readlink -f $SCRIPTDIR/../libexec/livepatch-build-tools)"
+    else
+        return 1
+    fi
+}
+
 function make_patch_name()
 {
     PATCHNAME=$(basename "$1")
@@ -78,7 +90,7 @@ function build_special()
     cd "${SRCDIR}" || die
 
     # Capture .o files from the patched build
-    export CROSS_COMPILE="${SCRIPTDIR}/livepatch-gcc "
+    export CROSS_COMPILE="${TOOLSDIR}/livepatch-gcc "
     export LIVEPATCH_BUILD_DIR="$(pwd)/"
     export LIVEPATCH_CAPTURE_DIR="$OUTPUT/${name}"
     mkdir -p "$LIVEPATCH_CAPTURE_DIR"
@@ -112,7 +124,7 @@ function create_patch()
         mkdir -p "output/$(dirname $i)" || die
         echo "Processing ${i}"
         echo "Run create-diff-object on $i" >> "${OUTPUT}/create-diff-object.log"
-        "${SCRIPTDIR}"/create-diff-object $debugopt $PRELINK "original/$i" "patched/$i" "$XENSYMS" "output/$i" &>> "${OUTPUT}/create-diff-object.log"
+        "${TOOLSDIR}"/create-diff-object $debugopt $PRELINK "original/$i" "patched/$i" "$XENSYMS" "output/$i" &>> "${OUTPUT}/create-diff-object.log"
         rc="${PIPESTATUS[0]}"
         if [[ $rc = 139 ]]; then
             warn "create-diff-object SIGSEGV"
@@ -146,7 +158,7 @@ function create_patch()
         chmod +x "${PATCHNAME}.livepatch"
     else
         ld -r -o output.o --build-id=sha1 $(find output -type f -name "*.o") || die
-        "${SCRIPTDIR}"/prelink $debugopt output.o "${PATCHNAME}.livepatch" "$XENSYMS" &>> "${OUTPUT}/prelink.log" || die
+        "${TOOLSDIR}"/prelink $debugopt output.o "${PATCHNAME}.livepatch" "$XENSYMS" &>> "${OUTPUT}/prelink.log" || die
     fi
 
     objcopy --add-section .livepatch.depends=depends.bin "${PATCHNAME}.livepatch"
@@ -168,6 +180,8 @@ usage() {
     echo "        --prelink          Prelink" >&2
 }
 
+find_tools || die "can't find supporting tools"
+
 options=$(getopt -o hs:p:o:j:k:d -l "help,srcdir:patch:output:cpus:,skip:,debug,xen-debug,xen-syms:,depends:,prelink" -- "$@") || die "getopt failed"
 
 eval set -- "$options"
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel