summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-09-23 10:13:16 -0300
committerEuAndreh <eu@euandre.org>2024-09-28 19:04:10 -0300
commit78ce3d2aa74c5ac26c64f55d55bf5d6076c00a63 (patch)
tree2301826f6dd651259393c30391341e7c8b3688a4 /Makefile
parentInitial empty commit (diff)
downloadcracha-78ce3d2aa74c5ac26c64f55d55bf5d6076c00a63.tar.gz
cracha-78ce3d2aa74c5ac26c64f55d55bf5d6076c00a63.tar.xz
Init Go project skeleton with liteq init
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile148
1 files changed, 148 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..76ba338
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,148 @@
+.POSIX:
+DATE = 1970-01-01
+VERSION = 0.1.0
+NAME = gracha
+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 = -lsqlite3
+GOCFLAGS = -I $(GOLIBDIR)
+GOLDFLAGS = -L $(GOLIBDIR)
+
+
+
+.SUFFIXES:
+.SUFFIXES: .go .a .bin .bin-check
+
+
+
+all:
+include deps.mk
+
+
+objects = \
+ src/$(NAME).a \
+ src/main.a \
+ tests/$(NAME).a \
+ tests/main.a \
+
+sources = \
+ src/$(NAME).go \
+ src/version.go \
+ src/main.go \
+
+
+derived-assets = \
+ src/version.go \
+ $(objects) \
+ src/main.bin \
+ tests/main.bin \
+ $(NAME).bin \
+
+side-assets = \
+ gracha.db \
+
+
+
+## Default target. Builds all artifacts required for testing
+## and installation.
+all: $(derived-assets)
+
+
+$(objects): Makefile
+
+src/$(NAME).a: src/$(NAME).go src/version.go
+ go tool compile $(GOCFLAGS) -o $@ -p $(*F) -I $(@D) $*.go src/version.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 $@ -p $(*F) -I $(@D) $*.go
+
+tests/$(NAME).a: tests/$(NAME).go src/$(NAME).go src/version.go
+ go tool compile $(GOCFLAGS) -o $@ -p $(*F) $*.go src/$(*F).go src/version.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) --extldflags '$(LDLIBS)' $*.a
+
+$(NAME).bin: src/main.bin
+ ln -fs $? $@
+
+src/version.go: Makefile
+ echo 'package $(NAME); const Version = "$(VERSION)"' > $@
+
+
+
+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 \
+
+.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
+
+
+
+## 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)$(BINDIR)' \
+ '$(DESTDIR)$(GOLIBDIR)' \
+ '$(DESTDIR)$(SRCDIR)' \
+
+ cp $(NAME).bin '$(DESTDIR)$(BINDIR)'/$(NAME)
+ 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)$(GOLIBDIR)'/$(NAME).a \
+ '$(DESTDIR)$(SRCDIR)' \
+
+
+
+ALWAYS: