summaryrefslogtreecommitdiffhomepage
path: root/auto/modules/go
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2017-12-01 16:57:30 +0300
committerMax Romanov <max.romanov@nginx.com>2017-12-01 16:57:30 +0300
commit40eb1f8b9b2a76d76ef6a4a094bf8192a44cbe41 (patch)
treef8e1b7f97762d6c36deeadca1b503dc91aa3ce12 /auto/modules/go
parentffb1c68609620824a88e0573e13f91ce0e810bf2 (diff)
downloadunit-40eb1f8b9b2a76d76ef6a4a094bf8192a44cbe41.tar.gz
unit-40eb1f8b9b2a76d76ef6a4a094bf8192a44cbe41.tar.bz2
Making Go package source distributable and renaming to 'nginx/unit'.
All header files are copied to Go package sources. As the result, package can be (re-)build when required. This closes #23 issue on GitHub.
Diffstat (limited to 'auto/modules/go')
-rw-r--r--auto/modules/go40
1 files changed, 18 insertions, 22 deletions
diff --git a/auto/modules/go b/auto/modules/go
index c31dbe94..68eb7d4a 100644
--- a/auto/modules/go
+++ b/auto/modules/go
@@ -85,41 +85,37 @@ fi
cat << END >> $NXT_MAKEFILE
-.PHONY: ${NXT_GO} ${NXT_GO}-install ${NXT_GO}-uninstall
-
-all: ${NXT_GO}
-
-NXT_ROOT = `pwd`
+.PHONY: ${NXT_GO}
+.PHONY: ${NXT_GO}-install
+.PHONY: ${NXT_GO}-install-src
+.PHONY: ${NXT_GO}-install-build
+.PHONY: ${NXT_GO}-uninstall
GOPATH = $NXT_GO_PATH
GOOS = `${NXT_GO} env GOOS`
GOARCH = `${NXT_GO} env GOARCH`
-${NXT_GO}: $NXT_BUILD_DIR/nxt_go_gen.h
+NXT_GO_DST = ${NXT_GO_PATH%%:*}
-$NXT_BUILD_DIR/nxt_go_gen.h: src/go/unit/*.go
- GOPATH=`pwd` \\
- CGO_CPPFLAGS="-DNXT_CONFIGURE \\
- -I`pwd`/src" \\
- ${NXT_GO} build -o $NXT_BUILD_DIR/nxt_go_gen.a \\
- --buildmode=c-archive go/unit
+install: ${NXT_GO}-install
+${NXT_GO}:
-install: ${NXT_GO}-install
+${NXT_GO}-install: ${NXT_GO}-install-build
+
+${NXT_GO}-install-src:
+ install -d \$(DESTDIR)\$(NXT_GO_DST)/src/nginx/unit
+ install -p -m644 ./src/*.h ./build/*.h ./src/go/unit/* \
+ \$(DESTDIR)\$(NXT_GO_DST)/src/nginx/unit/
-${NXT_GO}-install: ${NXT_GO}
- install -d \$(DESTDIR)\$(GOPATH)/src/unit
- install -p -m644 ./src/go/unit/* \$(DESTDIR)\$(GOPATH)/src/unit/
- CGO_CFLAGS="-I\$(NXT_ROOT)/$NXT_BUILD_DIR -I\$(NXT_ROOT)/src" \\
- CGO_LDFLAGS="-L\$(NXT_ROOT)/$NXT_BUILD_DIR ${NXT_LIBRT}" \\
- GOPATH=\$(DESTDIR)\$(GOPATH) \\
- ${NXT_GO} install -v unit
+${NXT_GO}-install-build: ${NXT_GO}-install-src
+ GOPATH=\$(DESTDIR)\$(GOPATH) ${NXT_GO} build nginx/unit
uninstall: ${NXT_GO}-uninstall
${NXT_GO}-uninstall:
- rm -rf \$(DESTDIR)\$(GOPATH)/src/unit
- rm -f \$(DESTDIR)\$(GOPATH)/pkg/\$(GOOS)_\$(GOARCH)/unit.a
+ rm -rf \$(DESTDIR)\$(NXT_GO_DST)/src/nginx/unit
+ rm -rf \$(DESTDIR)\$(NXT_GO_DST)/pkg/\$(GOOS)_\$(GOARCH)/nginx/unit
END