adding version information to build.
This commit is contained in:
parent
a973415f0e
commit
8531c612d3
4 changed files with 31 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,6 +1,7 @@
|
|||
*.o
|
||||
archived
|
||||
Makefile.local.mk
|
||||
VERSION
|
||||
test/test_*
|
||||
nbproject
|
||||
config.ini
|
||||
|
|
|
|||
10
Makefile
10
Makefile
|
|
@ -2,6 +2,7 @@
|
|||
#
|
||||
# Archived Makefile
|
||||
#
|
||||
all::
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -O2 -Wall -Ilib
|
||||
|
|
@ -27,10 +28,14 @@ else
|
|||
obj += $(obj-mysql)
|
||||
endif
|
||||
|
||||
VERSION :
|
||||
@$(SHELL) ./VERSION-GEN > VERSION
|
||||
-include VERSION
|
||||
|
||||
.SUFFIXES: .c .o
|
||||
.PHONY : clean distclean
|
||||
|
||||
all : $(PROGRAM)
|
||||
all:: $(PROGRAM)
|
||||
|
||||
$(PROGRAM) : src/archived.o $(obj)
|
||||
$(QUIET_LD)$(LD) $(sort $(^)) -o $@ $(LDFLAGS)
|
||||
|
|
@ -41,11 +46,14 @@ clean :
|
|||
done
|
||||
@make -C test clean
|
||||
@make -C docs clean
|
||||
$(RM) VERSION
|
||||
|
||||
distclean : clean
|
||||
$(RM) $(PROGRAM)
|
||||
$(RM) Makefile.local.mk
|
||||
|
||||
src/archived.o : CFLAGS += -DARCHIVED_VERSION='"$(ARCHIVED_VERSION)"'
|
||||
|
||||
%.o : %.c
|
||||
$(QUIET_CC)$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
|
|
|
|||
18
VERSION-GEN
Executable file
18
VERSION-GEN
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/sh
|
||||
|
||||
VERSION=$(git describe --tags --match "v[0-9]*" HEAD 2>/dev/null)
|
||||
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
VERSION="${VERSION}-dirty"
|
||||
fi
|
||||
|
||||
if [ -f "${1}" ]; then
|
||||
OLD=$(cat ${1} | sed 's/VERSION = //')
|
||||
else
|
||||
OLD=""
|
||||
fi
|
||||
|
||||
if [ "${VERSION}" != "${OLD}" ]; then
|
||||
echo >&2 " Archived ${VERSION}"
|
||||
echo "ARCHIVED_VERSION = ${VERSION}"
|
||||
fi
|
||||
|
|
@ -27,6 +27,9 @@
|
|||
#include "util.h"
|
||||
|
||||
static const char *archived_usage_str =
|
||||
#ifdef ARCHIVED_VERSION
|
||||
"Archived " ARCHIVED_VERSION "\n"
|
||||
#endif
|
||||
"Usage: archived [-c <config>] <root>\n"
|
||||
" config - Path to the configuration file (default ./config.ini)\n"
|
||||
" root - Path to indexroot. All subdirectories will be indexed.\n";
|
||||
|
|
|
|||
Reference in a new issue