diff options
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 80 |
1 files changed, 59 insertions, 21 deletions
@@ -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 @@ -21,7 +22,7 @@ LDLIBS = .SUFFIXES: -.SUFFIXES: .go .bin +.SUFFIXES: .go .a .bin .bin-check @@ -29,17 +30,25 @@ all: include deps.mk +objects = \ + src/$(NAME).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 = \ - glaze.socket \ + $(NAME).socket \ @@ -48,22 +57,46 @@ side-assets = \ all: $(derived-assets) -$(NAME).bin: src/lib.go src/cmd/main.go Makefile - go build -o $@ -v src/cmd/main.go +$(objects): Makefile + +src/$(NAME).a: src/$(NAME).go + go tool compile $(GOCFLAGS) -o $@ -p $(*F) $*.go + +tests/$(NAME).a: tests/$(NAME).go src/$(NAME).go + go tool compile $(GOCFLAGS) -o $@ -p $(*F) $*.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 -tests/lib_test.bin: src/lib.go tests/lib_test.go Makefile - go test -c -o $@ -v $*.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) $*.a +$(NAME).bin: src/main.bin + ln -fs $? $@ -check-unit: tests/lib_test.bin - ./tests/lib_test.bin + +tests.bin-check = \ + tests/main.bin-check \ + +tests/main.bin-check: tests/main.bin +$(tests.bin-check): + $(EXEC)$*.bin + +check-unit: $(tests.bin-check) integration-tests = \ tests/cli-opts.sh \ + tests/integration.sh \ -$(integration-tests): $(NAME).bin ALWAYS +.PRECIOUS: $(integration-tests) +$(integration-tests): $(NAME).bin +$(integration-tests): ALWAYS sh $@ check-integration: $(integration-tests) @@ -87,27 +120,32 @@ 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)' \ + ## Run it locally. run: all - rm -f glaze.socket - ./$(NAME).bin -P '/api/socket*:retcp.socket' -P '*:../papo/src/static/' glaze.socket + rm -f $(NAME).socket + ./$(NAME).bin \ + -P '/fonte/*:src/' \ + -P '/pasta/*:tests/' \ + -P '/api/socket*:retcp.socket' \ + glaze.socket ALWAYS: |
