2015-03-05 12:46:31 -05:00
|
|
|
DOMAIN=lxd
|
|
|
|
|
POFILES=$(wildcard po/*.po)
|
|
|
|
|
MOFILES=$(patsubst %.po,%.mo,$(POFILES))
|
|
|
|
|
LINGUAS=$(basename $(POFILES))
|
|
|
|
|
POTFILE=po/$(DOMAIN).pot
|
2016-12-16 15:36:53 -05:00
|
|
|
VERSION=$(shell grep "var Version" shared/version/flex.go | cut -d'"' -f2)
|
2015-03-05 12:46:31 -05:00
|
|
|
ARCHIVE=lxd-$(VERSION).tar
|
2018-08-01 12:42:03 -04:00
|
|
|
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")
|
2018-08-01 13:31:30 -04:00
|
|
|
GOPATH ?= $(HOME)/go
|
2015-03-05 12:46:31 -05:00
|
|
|
|
2014-11-07 03:58:32 -06:00
|
|
|
.PHONY: default
|
|
|
|
|
default:
|
2018-08-01 12:53:12 -04:00
|
|
|
ifeq ($(TAG_SQLITE3),)
|
|
|
|
|
@echo "Missing custom libsqlite3, run \"make deps\" to setup."
|
|
|
|
|
exit 1
|
|
|
|
|
endif
|
|
|
|
|
|
2018-02-01 09:50:26 +00:00
|
|
|
go get -t -v -d ./...
|
2018-08-27 10:46:09 +02:00
|
|
|
CC=$(CC) go install -v -tags "$(TAG_SQLITE3)" $(DEBUG) ./...
|
2019-11-08 16:57:01 -05:00
|
|
|
CGO_ENABLED=0 go install -v -tags netgo ./lxd-p2c
|
2019-11-08 16:58:37 -05:00
|
|
|
go install -v -tags agent ./lxd-agent
|
2016-02-11 21:20:29 +01:00
|
|
|
@echo "LXD built successfully"
|
2014-11-07 03:58:32 -06:00
|
|
|
|
2015-08-03 10:56:47 -04:00
|
|
|
.PHONY: client
|
2015-08-03 10:25:35 -04:00
|
|
|
client:
|
2017-02-17 16:02:12 -05:00
|
|
|
go get -t -v -d ./...
|
2018-08-01 12:42:03 -04:00
|
|
|
go install -v -tags "$(TAG_SQLITE3)" $(DEBUG) ./lxc
|
2016-02-11 21:20:29 +01:00
|
|
|
@echo "LXD client built successfully"
|
2015-08-03 10:25:35 -04:00
|
|
|
|
2019-11-08 16:58:37 -05:00
|
|
|
.PHONY: lxd-agent
|
|
|
|
|
lxd-agent:
|
|
|
|
|
go install -v -tags agent ./lxd-agent
|
|
|
|
|
@echo "LXD agent built successfully"
|
|
|
|
|
|
2018-10-04 12:58:05 -04:00
|
|
|
.PHONY: lxd-p2c
|
|
|
|
|
lxd-p2c:
|
|
|
|
|
CGO_ENABLED=0 go install -v -tags netgo ./lxd-p2c
|
|
|
|
|
@echo "LXD-P2C built successfully"
|
|
|
|
|
|
2018-08-01 13:31:30 -04:00
|
|
|
.PHONY: deps
|
|
|
|
|
deps:
|
|
|
|
|
# sqlite
|
|
|
|
|
@if [ -d "$(GOPATH)/deps/sqlite" ]; then \
|
2019-07-16 10:45:21 -04:00
|
|
|
if [ -d "$(GOPATH)/deps/sqlite/.git" ]; then \
|
|
|
|
|
cd "$(GOPATH)/deps/sqlite"; \
|
|
|
|
|
git pull; \
|
|
|
|
|
fi; \
|
2018-08-01 13:31:30 -04:00
|
|
|
else \
|
2019-08-08 17:35:49 -04:00
|
|
|
git clone --depth=1 "https://github.com/canonical/sqlite" "$(GOPATH)/deps/sqlite"; \
|
2019-08-23 09:17:41 -07:00
|
|
|
cd "$(GOPATH)/deps/sqlite"; \
|
2019-07-16 10:45:21 -04:00
|
|
|
git log -1 --format="format:%ci%n" | sed -e 's/ [-+].*$$//;s/ /T/;s/^/D /' > manifest; \
|
|
|
|
|
git log -1 --format="format:%H" > manifest.uuid; \
|
2018-08-01 13:31:30 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
cd "$(GOPATH)/deps/sqlite" && \
|
2018-08-13 15:02:52 -04:00
|
|
|
./configure --enable-replication --disable-amalgamation --disable-tcl && \
|
2018-08-01 13:31:30 -04:00
|
|
|
make
|
|
|
|
|
|
2019-06-24 10:31:19 +02:00
|
|
|
# libco
|
|
|
|
|
@if [ -d "$(GOPATH)/deps/libco" ]; then \
|
2019-07-16 10:45:21 -04:00
|
|
|
if [ -d "$(GOPATH)/deps/libco/.git" ]; then \
|
|
|
|
|
cd "$(GOPATH)/deps/libco"; \
|
|
|
|
|
git pull; \
|
|
|
|
|
fi; \
|
2019-06-24 10:31:19 +02:00
|
|
|
else \
|
2019-08-08 17:35:49 -04:00
|
|
|
git clone --depth=1 "https://github.com/canonical/libco" "$(GOPATH)/deps/libco"; \
|
2019-06-24 10:31:19 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
cd "$(GOPATH)/deps/libco" && \
|
|
|
|
|
make
|
|
|
|
|
|
|
|
|
|
# raft
|
|
|
|
|
@if [ -d "$(GOPATH)/deps/raft" ]; then \
|
2019-07-16 10:45:21 -04:00
|
|
|
if [ -d "$(GOPATH)/deps/raft/.git" ]; then \
|
|
|
|
|
cd "$(GOPATH)/deps/raft"; \
|
|
|
|
|
git pull; \
|
|
|
|
|
fi; \
|
2019-06-24 10:31:19 +02:00
|
|
|
else \
|
2019-08-08 17:35:49 -04:00
|
|
|
git clone --depth=1 "https://github.com/canonical/raft" "$(GOPATH)/deps/raft"; \
|
2019-06-24 10:31:19 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
cd "$(GOPATH)/deps/raft" && \
|
|
|
|
|
autoreconf -i && \
|
|
|
|
|
./configure && \
|
|
|
|
|
make
|
|
|
|
|
|
2018-08-01 13:31:30 -04:00
|
|
|
# dqlite
|
|
|
|
|
@if [ -d "$(GOPATH)/deps/dqlite" ]; then \
|
2019-07-16 10:45:21 -04:00
|
|
|
if [ -d "$(GOPATH)/deps/dqlite/.git" ]; then \
|
|
|
|
|
cd "$(GOPATH)/deps/dqlite"; \
|
|
|
|
|
git pull; \
|
|
|
|
|
fi; \
|
2018-08-01 13:31:30 -04:00
|
|
|
else \
|
2019-08-08 17:35:49 -04:00
|
|
|
git clone --depth=1 "https://github.com/canonical/dqlite" "$(GOPATH)/deps/dqlite"; \
|
2018-08-01 13:31:30 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
cd "$(GOPATH)/deps/dqlite" && \
|
|
|
|
|
autoreconf -i && \
|
2019-06-24 10:31:19 +02:00
|
|
|
PKG_CONFIG_PATH="$(GOPATH)/deps/sqlite/:$(GOPATH)/deps/libco/:$(GOPATH)/deps/raft/" ./configure && \
|
|
|
|
|
make CFLAGS="-I$(GOPATH)/deps/sqlite/ -I$(GOPATH)/deps/libco/ -I$(GOPATH)/deps/raft/include/" LDFLAGS="-L$(GOPATH)/deps/sqlite/.libs/ -L$(GOPATH)/deps/libco/ -L$(GOPATH)/deps/raft/.libs/"
|
2018-08-01 13:31:30 -04:00
|
|
|
|
|
|
|
|
# environment
|
|
|
|
|
@echo ""
|
|
|
|
|
@echo "Please set the following in your environment (possibly ~/.bashrc)"
|
2019-06-24 10:31:19 +02:00
|
|
|
@echo "export CGO_CFLAGS=\"-I$(GOPATH)/deps/sqlite/ -I$(GOPATH)/deps/libco/ -I$(GOPATH)/deps/raft/include/ -I$(GOPATH)/deps/dqlite/include/\""
|
|
|
|
|
@echo "export CGO_LDFLAGS=\"-L$(GOPATH)/deps/sqlite/.libs/ -L$(GOPATH)/deps/libco/ -L$(GOPATH)/deps/raft/.libs -L$(GOPATH)/deps/dqlite/.libs/\""
|
|
|
|
|
@echo "export LD_LIBRARY_PATH=\"$(GOPATH)/deps/sqlite/.libs/:$(GOPATH)/deps/libco/:$(GOPATH)/deps/raft/.libs/:$(GOPATH)/deps/dqlite/.libs/\""
|
2018-08-01 13:31:30 -04:00
|
|
|
|
2015-12-20 22:15:21 -05:00
|
|
|
.PHONY: update
|
|
|
|
|
update:
|
|
|
|
|
go get -t -v -d -u ./...
|
|
|
|
|
@echo "Dependencies updated"
|
|
|
|
|
|
2018-08-01 12:25:54 -04:00
|
|
|
.PHONY: update-protobuf
|
|
|
|
|
update-protobuf:
|
|
|
|
|
protoc --go_out=. ./lxd/migration/migrate.proto
|
|
|
|
|
|
2018-08-01 12:24:56 -04:00
|
|
|
.PHONY: update-schema
|
2019-09-04 14:38:19 -04:00
|
|
|
update-schema:
|
2018-09-05 09:29:07 +02:00
|
|
|
cd shared/generate && go build -o lxd-generate -tags "$(TAG_SQLITE3)" $(DEBUG) && cd -
|
|
|
|
|
mv shared/generate/lxd-generate $(GOPATH)/bin
|
|
|
|
|
go generate ./...
|
|
|
|
|
@echo "Code generation completed"
|
2017-08-25 08:08:45 +00:00
|
|
|
|
2017-03-24 01:46:59 +01:00
|
|
|
.PHONY: debug
|
|
|
|
|
debug:
|
2018-08-01 12:53:12 -04:00
|
|
|
ifeq ($(TAG_SQLITE3),)
|
|
|
|
|
@echo "Missing custom libsqlite3, run \"make deps\" to setup."
|
|
|
|
|
exit 1
|
|
|
|
|
endif
|
|
|
|
|
|
2017-03-24 01:46:59 +01:00
|
|
|
go get -t -v -d ./...
|
2018-08-27 10:46:09 +02:00
|
|
|
CC=$(CC) go install -v -tags "$(TAG_SQLITE3) logdebug" $(DEBUG) ./...
|
2017-03-24 01:46:59 +01:00
|
|
|
@echo "LXD built successfully"
|
|
|
|
|
|
2019-10-21 20:58:55 +02:00
|
|
|
.PHONY: nocache
|
|
|
|
|
nocache:
|
|
|
|
|
ifeq ($(TAG_SQLITE3),)
|
|
|
|
|
@echo "Missing custom libsqlite3, run \"make deps\" to setup."
|
|
|
|
|
exit 1
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
go get -t -v -d ./...
|
|
|
|
|
CC=$(CC) go install -a -v -tags "$(TAG_SQLITE3)" $(DEBUG) ./...
|
|
|
|
|
@echo "LXD built successfully"
|
|
|
|
|
|
2014-11-07 03:58:32 -06:00
|
|
|
.PHONY: check
|
|
|
|
|
check: default
|
2016-10-04 15:04:04 -06:00
|
|
|
go get -v -x github.com/rogpeppe/godeps
|
2019-10-21 12:03:51 -04:00
|
|
|
go get -v -x github.com/tsenart/deadcode
|
2017-02-14 11:41:34 -05:00
|
|
|
go get -v -x github.com/golang/lint/golint
|
2018-08-01 12:42:03 -04:00
|
|
|
go test -v -tags "$(TAG_SQLITE3)" $(DEBUG) ./...
|
2014-11-07 06:07:22 -06:00
|
|
|
cd test && ./main.sh
|
2014-11-07 03:58:32 -06:00
|
|
|
|
2015-01-28 06:54:44 +01:00
|
|
|
.PHONY: dist
|
|
|
|
|
dist:
|
2016-12-16 16:21:49 -05:00
|
|
|
# Cleanup
|
|
|
|
|
rm -Rf $(ARCHIVE).gz
|
2017-05-30 10:47:11 +02:00
|
|
|
|
2016-12-16 16:21:49 -05:00
|
|
|
# Create build dir
|
2016-09-28 01:27:52 -04:00
|
|
|
$(eval TMP := $(shell mktemp -d))
|
2016-12-16 16:21:49 -05:00
|
|
|
git archive --prefix=lxd-$(VERSION)/ HEAD | tar -x -C $(TMP)
|
2019-07-16 10:57:22 -04:00
|
|
|
mkdir -p $(TMP)/_dist/src/github.com/lxc
|
|
|
|
|
ln -s ../../../../lxd-$(VERSION) $(TMP)/_dist/src/github.com/lxc/lxd
|
2017-05-30 10:47:11 +02:00
|
|
|
|
2016-12-16 16:21:49 -05:00
|
|
|
# Download dependencies
|
2019-07-16 10:57:22 -04:00
|
|
|
cd $(TMP)/lxd-$(VERSION) && GOPATH=$(TMP)/_dist go get -t -v -d ./...
|
2017-05-30 10:47:11 +02:00
|
|
|
|
2018-08-01 12:53:27 -04:00
|
|
|
# Download the cluster-enabled sqlite/dqlite
|
2019-07-16 10:57:22 -04:00
|
|
|
mkdir $(TMP)/_dist/deps/
|
2019-08-08 17:35:49 -04:00
|
|
|
git clone --depth=1 https://github.com/canonical/dqlite $(TMP)/_dist/deps/dqlite
|
|
|
|
|
git clone --depth=1 https://github.com/canonical/sqlite $(TMP)/_dist/deps/sqlite
|
|
|
|
|
git clone --depth=1 https://github.com/canonical/libco $(TMP)/_dist/deps/libco
|
|
|
|
|
git clone --depth=1 https://github.com/canonical/raft $(TMP)/_dist/deps/raft
|
2019-07-16 10:57:22 -04:00
|
|
|
cd $(TMP)/_dist/deps/sqlite && git log -1 --format="format:%ci%n" | sed -e 's/ [-+].*$$//;s/ /T/;s/^/D /' > manifest
|
|
|
|
|
cd $(TMP)/_dist/deps/sqlite && git log -1 --format="format:%H" > manifest.uuid
|
2018-02-28 14:56:23 -05:00
|
|
|
|
2018-04-09 12:58:30 +02:00
|
|
|
# Write a manifest
|
2019-07-16 10:57:22 -04:00
|
|
|
cd $(TMP)/_dist && find . -type d -name .git | while read line; do GITDIR=$$(dirname $$line); echo "$${GITDIR}: $$(cd $${GITDIR} && git show-ref HEAD $${GITDIR} | cut -d' ' -f1)"; done | sort > $(TMP)/_dist/MANIFEST
|
2018-04-09 12:58:30 +02:00
|
|
|
|
2016-12-16 16:21:49 -05:00
|
|
|
# Assemble tarball
|
2019-07-16 10:57:22 -04:00
|
|
|
rm $(TMP)/_dist/src/github.com/lxc/lxd
|
|
|
|
|
ln -s ../../../../ $(TMP)/_dist/src/github.com/lxc/lxd
|
|
|
|
|
mv $(TMP)/_dist $(TMP)/lxd-$(VERSION)/
|
2016-12-16 16:21:49 -05:00
|
|
|
tar --exclude-vcs -C $(TMP) -zcf $(ARCHIVE).gz lxd-$(VERSION)/
|
2017-05-30 10:47:11 +02:00
|
|
|
|
2016-12-16 16:21:49 -05:00
|
|
|
# Cleanup
|
|
|
|
|
rm -Rf $(TMP)
|
2015-01-29 11:28:36 +01:00
|
|
|
|
2015-05-26 13:38:52 -04:00
|
|
|
.PHONY: i18n update-po update-pot build-mo static-analysis
|
2017-06-02 01:09:08 -04:00
|
|
|
i18n: update-pot update-po
|
2015-03-05 12:46:31 -05:00
|
|
|
|
|
|
|
|
po/%.mo: po/%.po
|
|
|
|
|
msgfmt --statistics -o $@ $<
|
|
|
|
|
|
|
|
|
|
po/%.po: po/$(DOMAIN).pot
|
|
|
|
|
msgmerge -U po/$*.po po/$(DOMAIN).pot
|
|
|
|
|
|
|
|
|
|
update-po:
|
2017-02-17 16:02:12 -05:00
|
|
|
for lang in $(LINGUAS); do\
|
2015-03-05 12:46:31 -05:00
|
|
|
msgmerge -U $$lang.po po/$(DOMAIN).pot; \
|
2015-09-12 16:27:02 +01:00
|
|
|
rm -f $$lang.po~; \
|
2015-03-05 12:46:31 -05:00
|
|
|
done
|
|
|
|
|
|
|
|
|
|
update-pot:
|
2016-06-21 20:34:37 -04:00
|
|
|
go get -v -x github.com/snapcore/snapd/i18n/xgettext-go/
|
2018-02-22 03:13:28 -05:00
|
|
|
xgettext-go -o po/$(DOMAIN).pot --add-comments-tag=TRANSLATORS: --sort-output --package-name=$(DOMAIN) --msgid-bugs-address=lxc-devel@lists.linuxcontainers.org --keyword=i18n.G --keyword-plural=i18n.NG lxc/*.go lxc/*/*.go
|
2015-09-09 15:31:49 -04:00
|
|
|
|
2015-03-05 12:46:31 -05:00
|
|
|
build-mo: $(MOFILES)
|
2015-05-26 13:38:52 -04:00
|
|
|
|
|
|
|
|
static-analysis:
|
2017-05-30 10:47:11 +02:00
|
|
|
(cd test; /bin/sh -x -c ". suites/static_analysis.sh; test_static_analysis")
|
2015-08-21 09:47:20 -07:00
|
|
|
|
2015-10-22 09:03:48 -06:00
|
|
|
tags: *.go lxd/*.go shared/*.go lxc/*.go
|
2015-08-21 09:47:20 -07:00
|
|
|
find . | grep \.go | grep -v git | grep -v .swp | grep -v vagrant | xargs gotags > tags
|