Merge pull request 'feat(version): added support for building version information' (#2) from gfaraday/bbs:main into main

Reviewed-on: #2
This commit is contained in:
2025-08-06 19:54:06 -04:00
4 changed files with 36 additions and 2 deletions

3
.gitignore vendored
View File

@@ -1,2 +1,5 @@
bbs
build/
# Machine generated files:
src/version.c

View File

@@ -3,7 +3,10 @@
# Makefile for Amber's BBS Interface
# Buildsys by Gale Faraday
.PHONY: all clean run
# `generate` must be called before `all` to build version information and other
# machine generated files.
.PHONY: all clean run generate
.SUFFIXES:
.DEFAULT_GOAL := all
@@ -11,6 +14,7 @@
TARGET := $(shell basename $(CURDIR))
SOURCES := src/
BUILD := build/
GENABLES := $(SOURCES)version.c
OBJS := $(patsubst $(SOURCES)%.c,$(BUILD)%.o,$(wildcard $(SOURCES)*.c))
EXECUTABLE := $(TARGET)
@@ -27,7 +31,12 @@ run: $(EXECUTABLE)
.IGNORE: clean
clean:
@rm -rvf $(BUILD) $(EXECUTABLE)
@rm -rvf $(BUILD) $(EXECUTABLE) $(GENABLES)
generate: $(GENABLES)
$(GENABLES): genver.sh
./genver.sh
$(EXECUTABLE): $(OBJS)
$(LD) $(LDFLAGS) -o $@ $^

17
genver.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# Script to generate version information file
# Current git tag
TAG="$(git describe --always --dirty --tags)"
# Output filename
OUTFILE='src/version.c'
sed -e "s/<HASH>/$TAG/g" <<EOF > "$OUTFILE"
/* Build version information. This file generated by genver.sh */
const char GIT_HASH[] = "<HASH>";
const char CC_VERSION[] = __VERSION__;
const char BUILD_DATE[] = __DATE__;
EOF

5
src/version.h Normal file
View File

@@ -0,0 +1,5 @@
/* Header for version information constants */
extern const char GIT_HASH[];
extern const char CC_VERSION[];
extern const char BUILD_DATE[];