libguestfs/0001-golang-Fix-it-so-it-builds-if-libguestfs-is-not-inst.patch
2013-07-09 14:14:34 +01:00

62 lines
1.7 KiB
Diff

From 0bc729e85b11262e5c1a38aff1602c960277c2b4 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 9 Jul 2013 13:59:52 +0100
Subject: [PATCH] golang: Fix it so it builds if libguestfs is not installed.
It was using the installed copy of libguestfs not the local copy.
We can't encode the paths in guestfs.go, since this source file gets
copied into the install directory where those paths would not make
sense. Instead we have to use CGO_CFLAGS and CGO_LDFLAGS to
communicate the right flags to go when doing the local build and test.
---
generator/golang.ml | 6 +++---
run.in | 12 ++++++++++++
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/generator/golang.ml b/generator/golang.ml
index f7010bc..82c1a0d 100644
--- a/generator/golang.ml
+++ b/generator/golang.ml
@@ -37,11 +37,11 @@ let generate_golang_go () =
package guestfs
/*
-#cgo CFLAGS: -I../src -DGUESTFS_PRIVATE=1
-#cgo LDFLAGS: -L../src/.libs -lguestfs
+#cgo CFLAGS: -DGUESTFS_PRIVATE=1
+#cgo LDFLAGS: -lguestfs
#include <stdio.h>
#include <stdlib.h>
-#include <guestfs.h>
+#include \"guestfs.h\"
// cgo can't deal with variable argument functions.
static guestfs_h *
diff --git a/run.in b/run.in
index 46cd71f..5d9ad75 100755
--- a/run.in
+++ b/run.in
@@ -171,6 +171,18 @@ else
GOPATH="$b/golang:$GOPATH"
fi
export GOPATH
+if [ -z "$CGO_CFLAGS" ]; then
+ CGO_CFLAGS="-I$s/src"
+else
+ CGO_CFLAGS="$CGO_CFLAGS -I$s/src"
+fi
+export CGO_CFLAGS
+if [ -z "$CGO_LDFLAGS" ]; then
+ CGO_LDFLAGS="-L$b/src/.libs"
+else
+ CGO_LDFLAGS="$CGO_LDFLAGS -L$b/src/.libs"
+fi
+export CGO_LDFLAGS
# For GObject, Javascript and friends.
export GJS=@GJS@
--
1.8.3.1