[lxc-devel] [lxd/master] Tweak Makefile
stgraber on Github
lxc-bot at linuxcontainers.org
Wed Aug 1 17:32:03 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180801/ed5098f7/attachment.bin>
-------------- next part --------------
From ae2a856b58092d135da9b138e82c92516244937d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 1 Aug 2018 12:23:00 -0400
Subject: [PATCH 1/9] Makefile: Respect CGO_CFLAGS
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 7efb277fbc..efdb745ddd 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@ POTFILE=po/$(DOMAIN).pot
# TODO: use git describe for versioning
VERSION=$(shell grep "var Version" shared/version/flex.go | cut -d'"' -f2)
ARCHIVE=lxd-$(VERSION).tar
-TAGS=$(shell printf "\#include <sqlite3.h>\nvoid main(){int n = SQLITE_IOERR_NOT_LEADER;}" | $(CC) -o /dev/null -xc - >/dev/null 2>&1 && echo "-tags libsqlite3")
+TAGS=$(shell printf "\#include <sqlite3.h>\nvoid main(){int n = SQLITE_IOERR_NOT_LEADER;}" | $(CC) ${CGO_CFLAGS} -o /dev/null -xc - >/dev/null 2>&1 && echo "-tags libsqlite3")
.PHONY: default
default:
From 2f07f822374b12a2ae8bbff10f1852b34b082da0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 1 Aug 2018 12:24:56 -0400
Subject: [PATCH 2/9] Makefile: Fix typo in .PHONY
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index efdb745ddd..df4e298c79 100644
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,7 @@ update:
go get -t -v -d -u ./...
@echo "Dependencies updated"
-.PHONY: update
+.PHONY: update-schema
update-schema:
go run -v $(TAGS) ./lxd/schema.go
@echo "Schema source code updated"
From 97ac04e91fe6dbf9eb2868ebb2923351b657fde3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 1 Aug 2018 12:25:54 -0400
Subject: [PATCH 3/9] Makefile: Rename protobuf to update-protobuf
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
Makefile | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
index df4e298c79..3e1c5dc73b 100644
--- a/Makefile
+++ b/Makefile
@@ -28,6 +28,10 @@ update:
go get -t -v -d -u ./...
@echo "Dependencies updated"
+.PHONY: update-protobuf
+update-protobuf:
+ protoc --go_out=. ./lxd/migration/migrate.proto
+
.PHONY: update-schema
update-schema:
go run -v $(TAGS) ./lxd/schema.go
@@ -39,13 +43,6 @@ debug:
go install -v $(TAGS) -tags logdebug $(DEBUG) ./...
@echo "LXD built successfully"
-# This only needs to be done when migrate.proto is actually changed; since we
-# commit the .pb.go in the tree and it's not expected to change very often,
-# it's not a default build step.
-.PHONY: protobuf
-protobuf:
- protoc --go_out=. ./lxd/migration/migrate.proto
-
.PHONY: check
check: default
go get -v -x github.com/rogpeppe/godeps
From 8d2593983df6b8c4ea0dca04e54041932a0df856 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 1 Aug 2018 12:28:07 -0400
Subject: [PATCH 4/9] Makefile: Drop gccgo
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
Makefile | 4 ----
1 file changed, 4 deletions(-)
diff --git a/Makefile b/Makefile
index 3e1c5dc73b..5521d7fd18 100644
--- a/Makefile
+++ b/Makefile
@@ -51,10 +51,6 @@ check: default
go test -v $(TAGS) $(DEBUG) ./...
cd test && ./main.sh
-gccgo:
- go build -v $(TAGS) $(DEBUG) -compiler gccgo ./...
- @echo "LXD built successfully with gccgo"
-
.PHONY: dist
dist:
# Cleanup
From 9cbc97e23e62f06a98cca5064b1246974d5fc53a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 1 Aug 2018 12:30:28 -0400
Subject: [PATCH 5/9] Makefile: Drop outdated comment
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
Makefile | 4 ----
1 file changed, 4 deletions(-)
diff --git a/Makefile b/Makefile
index 5521d7fd18..a291ab186d 100644
--- a/Makefile
+++ b/Makefile
@@ -3,10 +3,6 @@ POFILES=$(wildcard po/*.po)
MOFILES=$(patsubst %.po,%.mo,$(POFILES))
LINGUAS=$(basename $(POFILES))
POTFILE=po/$(DOMAIN).pot
-
-# dist is primarily for use when packaging; for development we still manage
-# dependencies via `go get` explicitly.
-# TODO: use git describe for versioning
VERSION=$(shell grep "var Version" shared/version/flex.go | cut -d'"' -f2)
ARCHIVE=lxd-$(VERSION).tar
TAGS=$(shell printf "\#include <sqlite3.h>\nvoid main(){int n = SQLITE_IOERR_NOT_LEADER;}" | $(CC) ${CGO_CFLAGS} -o /dev/null -xc - >/dev/null 2>&1 && echo "-tags libsqlite3")
From 567cc425c36fb97c0ecbc4d0821ccb71a82fd823 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 1 Aug 2018 12:42:03 -0400
Subject: [PATCH 6/9] Makefile: Fix tags handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
Makefile | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
index a291ab186d..4fbfcf70b3 100644
--- a/Makefile
+++ b/Makefile
@@ -5,18 +5,18 @@ LINGUAS=$(basename $(POFILES))
POTFILE=po/$(DOMAIN).pot
VERSION=$(shell grep "var Version" shared/version/flex.go | cut -d'"' -f2)
ARCHIVE=lxd-$(VERSION).tar
-TAGS=$(shell printf "\#include <sqlite3.h>\nvoid main(){int n = SQLITE_IOERR_NOT_LEADER;}" | $(CC) ${CGO_CFLAGS} -o /dev/null -xc - >/dev/null 2>&1 && echo "-tags libsqlite3")
+TAG_SQLITE3=$(shell printf "\#include <sqlite3.h>\nvoid main(){int n = SQLITE_IOERR_NOT_LEADER;}" | $(CC) ${CGO_CFLAGS} -o /dev/null -xc - >/dev/null 2>&1 && echo "libsqlite3")
.PHONY: default
default:
go get -t -v -d ./...
- go install -v $(TAGS) $(DEBUG) ./...
+ go install -v -tags "$(TAG_SQLITE3)" $(DEBUG) ./...
@echo "LXD built successfully"
.PHONY: client
client:
go get -t -v -d ./...
- go install -v $(TAGS) $(DEBUG) ./lxc
+ go install -v -tags "$(TAG_SQLITE3)" $(DEBUG) ./lxc
@echo "LXD client built successfully"
.PHONY: update
@@ -30,13 +30,13 @@ update-protobuf:
.PHONY: update-schema
update-schema:
- go run -v $(TAGS) ./lxd/schema.go
+ go run -v -tags "$(TAG_SQLITE3)" ./lxd/schema.go
@echo "Schema source code updated"
.PHONY: debug
debug:
go get -t -v -d ./...
- go install -v $(TAGS) -tags logdebug $(DEBUG) ./...
+ go install -v -tags "$(TAG_SQLITE3) logdebug" $(DEBUG) ./...
@echo "LXD built successfully"
.PHONY: check
@@ -44,7 +44,7 @@ check: default
go get -v -x github.com/rogpeppe/godeps
go get -v -x github.com/remyoudompheng/go-misc/deadcode
go get -v -x github.com/golang/lint/golint
- go test -v $(TAGS) $(DEBUG) ./...
+ go test -v -tags "$(TAG_SQLITE3)" $(DEBUG) ./...
cd test && ./main.sh
.PHONY: dist
From d3d00ceb9371f14621776072d4d3ffb2a95f2bbf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 1 Aug 2018 12:53:12 -0400
Subject: [PATCH 7/9] Makefile: Require libsqlite3
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
Makefile | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/Makefile b/Makefile
index 4fbfcf70b3..262ad59658 100644
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,11 @@ TAG_SQLITE3=$(shell printf "\#include <sqlite3.h>\nvoid main(){int n = SQLITE_IO
.PHONY: default
default:
+ifeq ($(TAG_SQLITE3),)
+ @echo "Missing custom libsqlite3, run \"make deps\" to setup."
+ exit 1
+endif
+
go get -t -v -d ./...
go install -v -tags "$(TAG_SQLITE3)" $(DEBUG) ./...
@echo "LXD built successfully"
@@ -35,6 +40,11 @@ update-schema:
.PHONY: debug
debug:
+ifeq ($(TAG_SQLITE3),)
+ @echo "Missing custom libsqlite3, run \"make deps\" to setup."
+ exit 1
+endif
+
go get -t -v -d ./...
go install -v -tags "$(TAG_SQLITE3) logdebug" $(DEBUG) ./...
@echo "LXD built successfully"
From 213e234a910b694618716c72f449baafcc9e6d8e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 1 Aug 2018 12:53:27 -0400
Subject: [PATCH 8/9] Makefile: Include dqlite in dist tarball
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 262ad59658..11ee7a0615 100644
--- a/Makefile
+++ b/Makefile
@@ -71,7 +71,8 @@ dist:
# Download dependencies
cd $(TMP)/lxd-$(VERSION) && GOPATH=$(TMP)/dist go get -t -v -d ./...
- # Download the cluster-enabled sqlite
+ # Download the cluster-enabled sqlite/dqlite
+ git clone https://github.com/CanonicalLtd/dqlite $(TMP)/dist/dqlite
git clone https://github.com/CanonicalLtd/sqlite $(TMP)/dist/sqlite
cd $(TMP)/dist/sqlite && git log -1 --format="format:%ci%n" | sed -e 's/ [-+].*$$//;s/ /T/;s/^/D /' > manifest
cd $(TMP)/dist/sqlite && git log -1 --format="format:%H" > manifest.uuid
From 74c37f59536595a929e71007bd0e192f583f8c70 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 1 Aug 2018 13:31:30 -0400
Subject: [PATCH 9/9] Makefile: Add deps target
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
Makefile | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/Makefile b/Makefile
index 11ee7a0615..5d367de2b0 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,7 @@ POTFILE=po/$(DOMAIN).pot
VERSION=$(shell grep "var Version" shared/version/flex.go | cut -d'"' -f2)
ARCHIVE=lxd-$(VERSION).tar
TAG_SQLITE3=$(shell printf "\#include <sqlite3.h>\nvoid main(){int n = SQLITE_IOERR_NOT_LEADER;}" | $(CC) ${CGO_CFLAGS} -o /dev/null -xc - >/dev/null 2>&1 && echo "libsqlite3")
+GOPATH ?= $(HOME)/go
.PHONY: default
default:
@@ -24,6 +25,42 @@ client:
go install -v -tags "$(TAG_SQLITE3)" $(DEBUG) ./lxc
@echo "LXD client built successfully"
+.PHONY: deps
+deps:
+ # sqlite
+ @if [ -d "$(GOPATH)/deps/sqlite" ]; then \
+ cd "$(GOPATH)/deps/sqlite"; \
+ git pull; \
+ else \
+ git clone "https://github.com/CanonicalLtd/sqlite" "$(GOPATH)/deps/sqlite"; \
+ fi
+
+ cd "$(GOPATH)/deps/sqlite" && \
+ ./configure --enable-replication && \
+ git log -1 --format="format:%ci%n" | sed -e 's/ [-+].*$$//;s/ /T/;s/^/D /' > manifest && \
+ git log -1 --format="format:%H" > manifest.uuid && \
+ make
+
+ # dqlite
+ @if [ -d "$(GOPATH)/deps/dqlite" ]; then \
+ cd "$(GOPATH)/deps/dqlite"; \
+ git pull; \
+ else \
+ git clone "https://github.com/CanonicalLtd/dqlite" "$(GOPATH)/deps/dqlite"; \
+ fi
+
+ cd "$(GOPATH)/deps/dqlite" && \
+ autoreconf -i && \
+ ./configure && \
+ make CFLAGS="-I$(GOPATH)/deps/sqlite/"
+
+ # environment
+ @echo ""
+ @echo "Please set the following in your environment (possibly ~/.bashrc)"
+ @echo "export CGO_CFLAGS=\"-I$(GOPATH)/deps/sqlite/ -I$(GOPATH)/deps/dqlite/include/\""
+ @echo "export CGO_LDFLAGS=\"-L$(GOPATH)/deps/sqlite/.libs/ -L$(GOPATH)/deps/dqlite/.libs/\""
+ @echo "export LD_LIBRARY_PATH=\"$(GOPATH)/deps/sqlite/.libs/:$(GOPATH)/deps/dqlite/.libs/\""
+
.PHONY: update
update:
go get -t -v -d -u ./...
More information about the lxc-devel
mailing list