aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-05-11 15:01:09 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-05-11 15:01:09 -0400
commit761a483e28935f0bdee4658c37dfaa4606c2660a (patch)
tree2e0b76801f2838d568ebd7b9c76884599ada0744 /Makefile
parent84c29ce5facc166515b80abf79f33b2ea21bf9fa (diff)
Add new system for tracking versions.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile48
1 files changed, 26 insertions, 22 deletions
diff --git a/Makefile b/Makefile
index 49df2d5e..e5baef93 100644
--- a/Makefile
+++ b/Makefile
@@ -67,10 +67,11 @@ OSFLAGS != case $(OS) in *BSD|Darwin) echo '-D_BSD_SOURCE';; Linux) echo '-D_GNU
EXTRA=
G=-ggdb
O=-O3
-GIT_VERSION=$(shell git log -1 --pretty=format:"$$(git describe --tags --abbrev=0)_%as_%h")
+TOMO_VERSION=$(shell awk '/^## / {print $$2; exit}' CHANGES.md)
+GIT_VERSION=$(shell git log -1 --pretty=format:"%as_%h")
CFLAGS=$(CCONFIG) $(INCLUDE_DIRS) $(EXTRA) $(CWARN) $(G) $(O) $(OSFLAGS) $(LTO) \
-DTOMO_PREFIX='"$(PREFIX)"' -DSUDO='"$(SUDO)"' -DDEFAULT_C_COMPILER='"$(DEFAULT_C_COMPILER)"' \
- -DTOMO_VERSION='"$(GIT_VERSION)"'
+ -DTOMO_VERSION='"$(TOMO_VERSION)"' -DGIT_VERSION='"$(GIT_VERSION)"'
CFLAGS_PLACEHOLDER="$$(printf '\033[2m<flags...>\033[m\n')"
LDLIBS=-lgc -lcord -lm -lunistring -lgmp -ldl
LIBTOMO_FLAGS=-shared
@@ -87,16 +88,17 @@ ifeq ($(OS),OpenBSD)
LDLIBS += -lexecinfo
endif
-AR_FILE=libtomo.a
+AR_FILE=libtomo_$(TOMO_VERSION).a
ifeq ($(OS),Darwin)
INCLUDE_DIRS += -I/opt/homebrew/include
LDFLAGS += -L/opt/homebrew/lib
- LIB_FILE=libtomo.dylib
- LIBTOMO_FLAGS += -Wl,-install_name,@rpath/libtomo.dylib
+ LIB_FILE=libtomo_$(TOMO_VERSION).dylib
+ LIBTOMO_FLAGS += -Wl,-install_name,@rpath/libtomo_$(TOMO_VERSION).dylib
else
- LIB_FILE=libtomo.so
- LIBTOMO_FLAGS += -Wl,-soname,libtomo.so
+ LIB_FILE=libtomo_$(TOMO_VERSION).so
+ LIBTOMO_FLAGS += -Wl,-soname,libtomo_$(TOMO_VERSION).so
endif
+EXE_FILE=tomo_$(TOMO_VERSION)
COMPILER_OBJS=$(patsubst %.c,%.o,$(wildcard src/*.c))
STDLIB_OBJS=$(patsubst %.c,%.o,$(wildcard src/stdlib/*.c))
@@ -104,7 +106,7 @@ TESTS=$(patsubst test/%.tm,test/results/%.tm.testresult,$(wildcard test/*.tm))
API_YAML=$(wildcard api/*.yaml)
API_MD=$(patsubst %.yaml,%.md,$(API_YAML))
-all: config.mk check-c-compiler check-libs build/lib/$(LIB_FILE) build/lib/$(AR_FILE) build/bin/tomo
+all: config.mk check-c-compiler check-libs build/lib/$(LIB_FILE) build/lib/$(AR_FILE) build/bin/$(EXE_FILE)
check-c-compiler:
@$(DEFAULT_C_COMPILER) -v 2>/dev/null >/dev/null \
@@ -114,7 +116,7 @@ check-libs: check-c-compiler
@echo 'int main() { return 0; }' | $(DEFAULT_C_COMPILER) $(LDFLAGS) $(LDLIBS) -x c - -o /dev/null 2>/dev/null >/dev/null \
|| { printf '\033[31;1m%s\033[m\n' "I expected to find the following libraries on your system, but I can't find them: $(LDLIBS)"; exit 1; }
-build/bin/tomo: $(STDLIB_OBJS) $(COMPILER_OBJS)
+build/bin/$(EXE_FILE): $(STDLIB_OBJS) $(COMPILER_OBJS)
@mkdir -p build/bin
@echo $(CC) $(CFLAGS_PLACEHOLDER) $(LDFLAGS) $^ $(LDLIBS) -o $@
@$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
@@ -134,14 +136,14 @@ tags:
config.mk: configure.sh
bash ./configure.sh
-%.o: %.c src/ast.h src/environment.h src/types.h config.mk
+%.o: %.c src/ast.h src/environment.h src/types.h config.mk CHANGES.md
@echo $(CC) $(CFLAGS_PLACEHOLDER) -c $< -o $@
@$(CC) $(CFLAGS) -c $< -o $@
%: %.tm
./local-tomo -e $<
-test/results/%.tm.testresult: test/%.tm build/bin/tomo
+test/results/%.tm.testresult: test/%.tm build/bin/$(EXE_FILE)
@mkdir -p test/results
@printf '\033[33;1;4m%s\033[m\n' $<
@if ! COLOR=1 LC_ALL=C ./local-tomo -O 1 $< 2>&1 | tee $@; then \
@@ -176,10 +178,10 @@ man/man1/tomo.1: docs/tomo.1.md
pandoc --lua-filter=docs/.pandoc/bold-code.lua -s $< -t man -o $@
examples:
- ./build/bin/tomo -qIL examples/log examples/ini examples/vectors examples/http examples/wrap examples/colorful
- ./build/bin/tomo -e examples/game/game.tm examples/http-server/http-server.tm \
+ ./local-tomo -qIL examples/log examples/ini examples/vectors examples/http examples/wrap examples/colorful
+ ./local-tomo -e examples/game/game.tm examples/http-server/http-server.tm \
examples/tomodeps/tomodeps.tm examples/tomo-install/tomo-install.tm
- ./build/bin/tomo examples/learnxiny.tm
+ ./local-tomo examples/learnxiny.tm
deps:
bash ./install_dependencies.sh
@@ -188,7 +190,7 @@ check-utilities: check-c-compiler
@which debugedit 2>/dev/null >/dev/null \
|| printf '\033[33;1m%s\033[m\n' "I couldn't find 'debugedit' on your system! Try installing the package 'debugedit' with your package manager. (It's not required though)"
-install-files: build/bin/tomo build/lib/$(LIB_FILE) build/lib/$(AR_FILE) check-utilities
+install-files: build/bin/$(EXE_FILE) build/lib/$(LIB_FILE) build/lib/$(AR_FILE) check-utilities
@if ! echo "$$PATH" | tr ':' '\n' | grep -qx "$(PREFIX)/bin"; then \
echo $$PATH; \
printf "\033[31;1mError: '$(PREFIX)/bin' is not in your \$$PATH variable!\033[m\n" >&2; \
@@ -198,15 +200,16 @@ install-files: build/bin/tomo build/lib/$(LIB_FILE) build/lib/$(AR_FILE) check-u
exit 1; \
fi
$(DEFINE_AS_OWNER); \
- as_owner mkdir -p -m 755 "$(PREFIX)/man/man1" "$(PREFIX)/man/man3" "$(PREFIX)/bin" "$(PREFIX)/include/tomo" "$(PREFIX)/lib"; \
- as_owner cp src/stdlib/*.h "$(PREFIX)/include/tomo/"; \
+ as_owner mkdir -p -m 755 "$(PREFIX)/man/man1" "$(PREFIX)/man/man3" "$(PREFIX)/bin" "$(PREFIX)/include/tomo_$(TOMO_VERSION)" "$(PREFIX)/lib"; \
+ as_owner cp src/stdlib/*.h "$(PREFIX)/include/tomo_$(TOMO_VERSION)/"; \
as_owner cp build/lib/$(LIB_FILE) build/lib/$(AR_FILE) "$(PREFIX)/lib/"; \
- as_owner rm -f "$(PREFIX)/bin/tomo"; \
- as_owner cp build/bin/tomo "$(PREFIX)/bin/"; \
+ as_owner rm -f "$(PREFIX)/bin/$(EXE_FILE)"; \
+ as_owner cp build/bin/$(EXE_FILE) "$(PREFIX)/bin/"; \
as_owner cp man/man1/* "$(PREFIX)/man/man1/"; \
- as_owner cp man/man3/* "$(PREFIX)/man/man3/";
+ as_owner cp man/man3/* "$(PREFIX)/man/man3/"; \
+ as_owner sh link_versions.sh
-install-libs: build/bin/tomo check-utilities
+install-libs: build/bin/$(EXE_FILE) check-utilities
$(DEFINE_AS_OWNER); \
./local-tomo -qIL lib/patterns lib/time lib/commands lib/shell lib/random lib/base64 lib/pthreads lib/uuid lib/core
@@ -214,7 +217,8 @@ install: install-files install-libs
uninstall:
$(DEFINE_AS_OWNER); \
- as_owner rm -rvf "$(PREFIX)/bin/tomo" "$(PREFIX)/include/tomo" "$(PREFIX)/lib/$(LIB_FILE)" "$(PREFIX)/lib/$(AR_FILE)" "$(PREFIX)/share/tomo";
+ as_owner rm -rvf "$(PREFIX)/bin/tomo" "$(PREFIX)/bin/tomo"[0-9]* "$(PREFIX)/bin/tomo_v"* "$(PREFIX)/include/tomo_v"* "$(PREFIX)/lib/libtomo_v*" "$(PREFIX)/share/tomo_$(TOMO_VERSION)"; \
+ as_owner sh link_versions.sh
endif