summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile72
1 files changed, 54 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index a6d47a2..4713192 100644
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,7 @@ LANGUAGES = en
PREFIX = /usr
BINDIR = $(PREFIX)/bin
LIBDIR = $(PREFIX)/lib
+GOLIBDIR = $(LIBDIR)/go
INCLUDEDIR = $(PREFIX)/include
SRCDIR = $(PREFIX)/src/$(NAME)
SHAREDIR = $(PREFIX)/share
@@ -17,12 +18,11 @@ EXEC = ./
## Where to store the installation. Empty by default.
DESTDIR =
LDLIBS =
-GOFLAGS =
.SUFFIXES:
-.SUFFIXES: .go .bin
+.SUFFIXES: .go .a .bin .bin-check
@@ -30,14 +30,24 @@ all:
include deps.mk
+objects = \
+ src/$(NAME).a \
+ src/proxy.a \
+ src/socks.a \
+ src/main.a \
+ tests/$(NAME).a \
+ tests/main.a \
+
sources = \
- src/lib.go \
- src/cmd/main.go \
+ src/$(NAME).go \
+ src/main.go \
derived-assets = \
+ $(objects) \
+ src/main.bin \
+ tests/main.bin \
$(NAME).bin \
- tests/lib_test.bin \
side-assets = \
$(NAME).socket \
@@ -49,22 +59,48 @@ side-assets = \
all: $(derived-assets)
-$(NAME).bin: src/lib.go src/cmd/main.go Makefile
- go build $(GOFLAGS) -v -o $@ src/cmd/main.go
+$(objects): Makefile
+
+src/$(NAME).a: src/$(NAME).go src/proxy.a
+src/proxy.a: src/proxy.go src/socks.a
+src/socks.a: src/socks.go
+src/$(NAME).a src/proxy.a src/socks.a:
+ go tool compile $(GOCFLAGS) -o $@ -p $(*F) -I src $*.go
+
+tests/$(NAME).a: tests/$(NAME).go src/$(NAME).go src/proxy.a
+tests/$(NAME).a:
+ go tool compile $(GOCFLAGS) -o $@ -p $(*F) -I src $*.go src/$(*F).go
+
+src/main.a: src/main.go src/$(NAME).a
+tests/main.a: tests/main.go tests/$(NAME).a
+src/main.a tests/main.a:
+ go tool compile $(GOCFLAGS) -o $@ -I $(@D) $*.go
+
+src/main.bin: src/main.a
+tests/main.bin: tests/main.a
+src/main.bin tests/main.bin:
+ go tool link $(GOLDFLAGS) -o $@ -L $(@D) -L src $*.a
+
+$(NAME).bin: src/main.bin
+ ln -fs $? $@
+
-tests/lib_test.bin: src/lib.go tests/lib_test.go Makefile
- go test $(GOFLAGS) -v -o $@ -c $*.go
+tests.bin-check = \
+ tests/main.bin-check \
+tests/main.bin-check: tests/main.bin
+$(tests.bin-check):
+ $(EXEC)$*.bin
-check-unit: tests/lib_test.bin
- ./tests/lib_test.bin
+check-unit: $(tests.bin-check)
integration-tests = \
tests/cli-opts.sh \
tests/integration.sh \
+.PRECIOUS: $(integration-tests)
$(integration-tests): $(NAME).bin
$(integration-tests): ALWAYS
sh $@
@@ -90,21 +126,21 @@ clean:
install: all
mkdir -p \
'$(DESTDIR)$(BINDIR)' \
+ '$(DESTDIR)$(GOLIBDIR)' \
+ '$(DESTDIR)$(SRCDIR)' \
cp $(NAME).bin '$(DESTDIR)$(BINDIR)'/$(NAME)
- for f in $(sources); do \
- dir='$(DESTDIR)$(SRCDIR)'/"`dirname "$${f#src/}"`"; \
- mkdir -p "$$dir"; \
- cp -P "$$f" "$$dir"; \
- done
+ cp src/$(NAME).a '$(DESTDIR)$(GOLIBDIR)'
+ cp $(sources) '$(DESTDIR)$(SRCDIR)'
## Uninstalls from $(DESTDIR)$(PREFIX). This is a perfect mirror
## of the "install" target, and removes *all* that was installed.
## A dedicated test asserts that this is always true.
uninstall:
rm -rf \
- '$(DESTDIR)$(BINDIR)'/$(NAME) \
- '$(DESTDIR)$(SRCDIR)' \
+ '$(DESTDIR)$(BINDIR)'/$(NAME) \
+ '$(DESTDIR)$(GOLIBDIR)'/$(NAME).a \
+ '$(DESTDIR)$(SRCDIR)' \