diff options
author | Andrew G. Morgan <morgan@kernel.org> | 2019-05-19 14:57:20 -0700 |
---|---|---|
committer | Andrew G. Morgan <morgan@kernel.org> | 2019-05-19 14:57:20 -0700 |
commit | 0615d996379dceedefcd65a114f93fefd81c208f (patch) | |
tree | 590edde235e563c88b62b913a449cc43884d1be2 /go/Makefile | |
parent | ac1ef3125f50594289a2d9a4de3b5a22d2882ea4 (diff) | |
download | libcap2-0615d996379dceedefcd65a114f93fefd81c208f.tar.gz |
A Go (golang) implementation of libcap: import "libcap/cap".
The API for this "libcap/cap" package is very similar to libcap.
I've included a substantial interoperability test that validate
libcap(c) and libcap/cap(go) have import/export text and binary
format compatibility.
My motivation for implementing a standalone Go package was for a
cross-compilation issue I ran into (Go is much more friendly for
cross-compilation by default, unless you need to use cgo).
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
Diffstat (limited to 'go/Makefile')
-rw-r--r-- | go/Makefile | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/go/Makefile b/go/Makefile new file mode 100644 index 0000000..059e0c1 --- /dev/null +++ b/go/Makefile @@ -0,0 +1,38 @@ +# Building the libcap/cap Go package. Note, we use symlinks to +# construct a go friendly src tree. + +topdir=$(realpath ..) +include ../Make.Rules + +all: + $(MAKE) compare-cap + ./compare-cap + +src/libcap/cap: + mkdir -p src/libcap + ln -s $(realpath ..)/cap src/libcap/ + +install: all +# TODO - install the Go package somewhere useful (ex. /usr/share/gocode/src/libcap/cap/ ) + +../libcap/cap_names.h: + make -C ../libcap + +src/libcap/cap/names.go: ../libcap/cap_names.h src/libcap/cap mknames.go + go run mknames.go --header=$< | gofmt > $@ || rm -f $@ + +GOPACKAGE=pkg/$(GOOSARCH)/libcap/cap.a +$(GOPACKAGE): src/libcap/cap/names.go src/libcap/cap/cap.go src/libcap/cap/text.go + echo testing Go package + GOPATH=$(realpath .) go test libcap/cap + echo building $(GOPACKAGE) + mkdir -p pkg + +# Compile and run something with this package and compare it to libcap. +compare-cap: compare-cap.go $(GOPACKAGE) + GOPATH=$(realpath .) go build $< + +clean: + GOPATH=$(realpath .) go clean -x -i libcap/cap || exit 0 + rm -f *.o *.so mknames compare-cap *~ ../cap/*~ ../cap/names.go + rm -fr pkg src |