]> xenbits.xensource.com Git - livepatch-build-tools.git/commitdiff
Support "make install"
authorRoss Lagerwall <ross.lagerwall@citrix.com>
Thu, 14 Jul 2016 08:34:26 +0000 (09:34 +0100)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Mon, 18 Jul 2016 13:53:30 +0000 (09:53 -0400)
Add rules to support using "make install".

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

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Makefile
livepatch-build

index aa5d5b0f324f27276fef703da7a9fb5bf55bdf6f..f96b150539d2f6cfb94d52475d058866331fe8b1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -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
index 29b8fc125e418c3c0924f56fbfa6bfdb3d220ba4..7395b49f9155580e5ae289c2b1594ec846f40c8f 100755 (executable)
@@ -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"
@@ -114,7 +126,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"
@@ -148,7 +160,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"
@@ -171,6 +183,8 @@ usage() {
     echo "        --prelink          Prelink" >&2
 }
 
+find_tools || die "can't find supporting tools"
+
 options=$(getopt -o hs:p:c:o:j:k:d -l "help,srcdir:patch:config:output:cpus:,skip:,debug,xen-debug,xen-syms:,depends:,prelink" -- "$@") || die "getopt failed"
 
 eval set -- "$options"