.POSIX: DATE = 1970-01-01 VERSION = 0.1.0 NAME = golite NAME_UC = $(NAME) LANGUAGES = en ## Installation prefix. Defaults to "/usr". PREFIX = /usr BINDIR = $(PREFIX)/bin LIBDIR = $(PREFIX)/lib GOLIBDIR = $(LIBDIR)/go INCLUDEDIR = $(PREFIX)/include SRCDIR = $(PREFIX)/src/$(NAME) SHAREDIR = $(PREFIX)/share LOCALEDIR = $(SHAREDIR)/locale MANDIR = $(SHAREDIR)/man EXEC = ./ ## Where to store the installation. Empty by default. DESTDIR = LDLIBS = .SUFFIXES: .SUFFIXES: .go .a .c .o .bin .bin-check .c.o: $(CC) $(iCFLAGS) -o $@ -c $< all: include deps.mk cgo-sources = \ src/_cgo_export.c \ src/_cgo_export.h \ src/_cgo_main.c \ src/_cgo_gotypes.go \ src/_cgo_import.go \ src/$(NAME).cgo1.go \ src/$(NAME).cgo2.c \ libdeps = \ src/_cgo_import.go \ src/_cgo_gotypes.go \ src/$(NAME).cgo1.go \ objects = \ src/$(NAME).a \ tests/$(NAME).a \ tests/main.a \ $(cgo-sources) \ src/_cgo_.o \ sources = \ src/$(NAME).go \ derived-assets = \ $(objects) \ tests/main.bin \ pack2.sentinel \ src/_cgo_export.o \ src/$(NAME).cgo2.o \ side-assets = \ ## Default target. Builds all artifacts required for testing ## and installation. all: $(derived-assets) $(objects): Makefile # src/$(NAME).a: src/$(NAME).go tests/main.a: tests/main.go tests/$(NAME).a tests/main.a: go tool compile $(GOCFLAGS) -o $@ -p $(*F) -I $(@D) $*.go $(cgo-sources): src/_cgo_.o src/_cgo_.o: src/$(NAME).go go tool cgo --objdir $(@D) src/$(NAME).go src/_cgo_import.go: src/_cgo_.o go tool cgo --dynpackage $(NAME) --dynimport src/_cgo_.o --dynout $@ src/$(NAME).a: $(libdeps) go tool compile $(GOCFLAGS) -o $@ -p $(*F) $(libdeps) # FIXME dependency pack2.sentinel: src/$(NAME).a src/_cgo_export.o src/$(NAME).cgo2.o go tool pack r $@ src/_cgo_export.o src/$(NAME).cgo2.o touch $@ tests/$(NAME).a: tests/$(NAME).go src/_cgo_gotypes.go src/$(NAME).cgo1.go src/_cgo_import.go src/_cgo_export.o src/$(NAME).cgo2.o go tool compile $(GOCFLAGS) -o $@ -p $(*F) tests/$(NAME).go src/_cgo_gotypes.go src/$(NAME).cgo1.go src/_cgo_import.go go tool pack r $@ src/_cgo_export.o src/$(NAME).cgo2.o tests/main.bin: tests/main.a go tool link $(GOLDFLAGS) -o $@ -L $(@D) --extldflags '-lsqlite3' $*.a 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 = \ .PRECIOUS: $(integration-tests) $(integration-tests): $(NAME).bin $(integration-tests): ALWAYS sh $@ check-integration: $(integration-tests) ## Run all tests. Each test suite is isolated, so that a parallel ## build can run tests at the same time. The required artifacts ## are created if missing. check: check-unit check-integration bench: tests/main.bin $(EXEC)tests/main.bin -test.bench '.*' ## Remove *all* derived artifacts produced during the build. ## A dedicated test asserts that this is always true. clean: rm -rf $(derived-assets) $(side-assets) ## Installs into $(DESTDIR)$(PREFIX). Its dependency target ## ensures that all installable artifacts are crafted beforehand. install: all mkdir -p \ '$(DESTDIR)$(GOLIBDIR)' \ '$(DESTDIR)$(SRCDIR)' \ 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)$(GOLIBDIR)'/$(NAME).a \ '$(DESTDIR)$(SRCDIR)' \ ALWAYS: