diff options
author | EuAndreh <eu@euandre.org> | 2024-08-05 07:34:39 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-08-05 07:34:39 -0300 |
commit | 516ca9e257306420759b9531c7aac0c42872a778 (patch) | |
tree | 006687f9cfde35cab6bd49af52f5b0f6b171bfb2 /Makefile | |
parent | rm src/cmd/main.go (diff) | |
download | gobang-516ca9e257306420759b9531c7aac0c42872a778.tar.gz gobang-516ca9e257306420759b9531c7aac0c42872a778.tar.xz |
Makefile: Build with "go tool compile" and "go tool link"
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 62 |
1 files changed, 35 insertions, 27 deletions
@@ -8,8 +8,8 @@ LANGUAGES = en PREFIX = /usr BINDIR = $(PREFIX)/bin LIBDIR = $(PREFIX)/lib +GOLIBDIR = $(LIBDIR)/go INCLUDEDIR = $(PREFIX)/include -LIBDDIR = $(PREFIX)/lib/$(NAME) SRCDIR = $(PREFIX)/src/$(NAME) SHAREDIR = $(PREFIX)/share LOCALEDIR = $(SHAREDIR)/locale @@ -22,19 +22,26 @@ LDLIBS = .SUFFIXES: -.SUFFIXES: .go .bin +.SUFFIXES: .go .a .bin +all: +include deps.mk + + sources = \ - go.mod \ - src/lib.go \ - src/cmd/main.go \ + src/$(NAME).go \ + +objects = \ + src/$(NAME).a \ + tests/$(NAME).a \ + tests/$(NAME)_main.a \ derived-assets = \ - $(NAME).bin \ - tests/lib_test.bin \ + $(objects) \ + tests/$(NAME)_main.bin \ side-assets = \ @@ -45,23 +52,28 @@ side-assets = \ all: $(derived-assets) -$(NAME).bin: src/lib.go src/cmd/main.go Makefile - go build -o $@ -v src/cmd/main.go +src/$(NAME).a: src/$(NAME).go + go tool compile $(GOCFLAGS) -o $@ -p $(*F) $*.go -tests/lib_test.bin: src/lib.go tests/lib_test.go Makefile - go test -c -o $@ -v $*.go +tests/$(NAME).a: tests/$(NAME).go src/$(NAME).go + go tool compile $(GOCFLAGS) -o $@ -p $(*F) $*.go src/$(NAME).go +tests/$(NAME)_main.a: tests/$(NAME)_main.go tests/$(NAME).a + go tool compile $(GOCFLAGS) -o $@ -I $(@D) $*.go +tests/$(NAME)_main.bin: tests/$(NAME)_main.a + go tool link $(GOLDFLAGS) -o $@ -L $(@D) $*.a -check-unit: tests/lib_test.bin - ./tests/lib_test.bin +$(objects): Makefile -integration-tests = \ - tests/cli-opts.sh \ -$(integration-tests): $(NAME).bin ALWAYS - sh $@ $(EXEC)$(NAME).bin + +check-unit: tests/$(NAME)_main.bin + ./tests/$(NAME)_main.bin + + +integration-tests = \ check-integration: $(integration-tests) @@ -83,23 +95,19 @@ clean: ## ensures that all installable artifacts are crafted beforehand. 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)$(LIBDDIR)' \ - '$(DESTDIR)$(SRCDIR)' \ + '$(DESTDIR)$(GOLIBDIR)'/$(NAME).a \ + '$(DESTDIR)$(SRCDIR)' \ ALWAYS: |