mirror of
https://github.com/moparisthebest/sslh
synced 2024-11-21 16:45:03 -05:00
version.h: dynamically create version number based on git
When building the source from a checked out tag, eg v1.15, VERSION will equal v1.15. However, when building from anything other than a tagged version, you get 'v1.15-4-g50432d5-dirty' meaning I was 4 patches in front of v1.15, particularly '50432d5' was my current HEAD, and I had uncommited changes, '-dirty'. Very useful for folks submitting bug reports on versions they compiled themselves. Signed-off-by: Jason Cooper <jason@lakedaemon.net>
This commit is contained in:
parent
c6adb6a1e1
commit
f36eb7be39
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,3 +6,4 @@ sslh-fork
|
||||
sslh-select
|
||||
sslh.8.gz
|
||||
tags
|
||||
version.h
|
||||
|
14
Makefile
14
Makefile
@ -1,6 +1,6 @@
|
||||
# Configuration
|
||||
|
||||
VERSION="1.15"
|
||||
VERSION=$(shell ./genver.sh -r)
|
||||
USELIBCONFIG=1 # Use libconfig? (necessary to use configuration files)
|
||||
USELIBWRAP= # Use libwrap?
|
||||
COV_TEST= # Perform test coverage?
|
||||
@ -34,17 +34,19 @@ endif
|
||||
all: sslh $(MAN) echosrv
|
||||
|
||||
.c.o: *.h
|
||||
$(CC) $(CFLAGS) -D'VERSION=$(VERSION)' -c $<
|
||||
$(CC) $(CFLAGS) -c $<
|
||||
|
||||
version.h:
|
||||
./genver.sh >version.h
|
||||
|
||||
sslh: $(OBJS) sslh-fork sslh-select
|
||||
|
||||
sslh-fork: $(OBJS) sslh-fork.o Makefile common.h
|
||||
$(CC) $(CFLAGS) -D'VERSION=$(VERSION)' -o sslh-fork sslh-fork.o $(OBJS) $(LIBS)
|
||||
sslh-fork: $(OBJS) sslh-fork.o Makefile common.h version.h
|
||||
$(CC) $(CFLAGS) -o sslh-fork sslh-fork.o $(OBJS) $(LIBS)
|
||||
#strip sslh-fork
|
||||
|
||||
sslh-select: $(OBJS) sslh-select.o Makefile common.h
|
||||
$(CC) $(CFLAGS) -D'VERSION=$(VERSION)' -o sslh-select sslh-select.o $(OBJS) $(LIBS)
|
||||
sslh-select: $(OBJS) sslh-select.o Makefile common.h version.h
|
||||
$(CC) $(CFLAGS) -o sslh-select sslh-select.o $(OBJS) $(LIBS)
|
||||
#strip sslh-select
|
||||
|
||||
echosrv: $(OBJS) echosrv.o
|
||||
|
5
common.h
5
common.h
@ -27,10 +27,7 @@
|
||||
#include <libgen.h>
|
||||
#include <time.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#ifndef VERSION
|
||||
#define VERSION "v?"
|
||||
#endif
|
||||
#include "version.h"
|
||||
|
||||
#define CHECK_RES_DIE(res, str) \
|
||||
if (res == -1) { \
|
||||
|
33
genver.sh
Executable file
33
genver.sh
Executable file
@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ ${#} -eq 1 ] && [ "x$1" == "x-r" ]; then
|
||||
# release text only
|
||||
QUIET=1
|
||||
else
|
||||
QUIET=0
|
||||
fi
|
||||
|
||||
if head=`git rev-parse --verify HEAD 2>/dev/null`; then
|
||||
|
||||
if [ $QUIET -ne 1 ]; then
|
||||
printf "#ifndef _VERSION_H_ \n"
|
||||
printf "#define _VERSION_H_ \n\n"
|
||||
printf "#define VERSION \""
|
||||
fi
|
||||
|
||||
# generate the version info based on the tag
|
||||
(git describe --tags || git --describe || git describe --all --long) \
|
||||
2>/dev/null | tr -d '\n'
|
||||
|
||||
# Are there uncommitted changes?
|
||||
git update-index --refresh --unmerged > /dev/null
|
||||
if git diff-index --name-only HEAD | grep -v "^scripts/package" \
|
||||
| read dummy; then
|
||||
printf '%s' -dirty
|
||||
fi
|
||||
|
||||
if [ $QUIET -ne 1 ]; then
|
||||
printf "\"\n"
|
||||
printf "\n#endif\n"
|
||||
fi
|
||||
fi
|
Loading…
Reference in New Issue
Block a user