diff options
author | Simon Rettberg | 2017-12-22 11:40:43 +0100 |
---|---|---|
committer | Simon Rettberg | 2017-12-22 11:40:43 +0100 |
commit | 24b5a6bdda8f09593dd908c3fc69315ebb3754e1 (patch) | |
tree | 71b72641416040fe15864f8aeb77377b6ba376c7 | |
parent | Fix compile error (diff) | |
download | ldadp-24b5a6bdda8f09593dd908c3fc69315ebb3754e1.tar.gz ldadp-24b5a6bdda8f09593dd908c3fc69315ebb3754e1.tar.xz ldadp-24b5a6bdda8f09593dd908c3fc69315ebb3754e1.zip |
Add version information and --version
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Makefile | 13 | ||||
-rwxr-xr-x | gen-version | 40 | ||||
-rw-r--r-- | ldadp.c | 7 | ||||
-rw-r--r-- | version.in | 13 |
5 files changed, 70 insertions, 6 deletions
@@ -3,3 +3,6 @@ config.test *.o *.a /ldadp +/version.in.h +/.localversion + @@ -41,16 +41,17 @@ LIBS+=-g -lowfat -lssl -lcrypto %: %.c $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) ${LIBS} -ldadp: tmpbuffer.o ini.o client.o server.o helper.o proxy.o epoll.o openssl.o ldap.a asn1.a +ldadp: version.in.h tmpbuffer.o ini.o client.o server.o helper.o proxy.o epoll.o openssl.o ldap.a asn1.a + +version.in.h: + ./gen-version qndtest: ldap.a asn1.a -.PHONY: clean tar -clean: - rm -f *.[ao] ldadp qndtest +.PHONY: clean version.in.h -tar: clean - cd ..; tar cvvf ldadp.tar.bz2 ldadp --use=bzip2 --exclude capture --exclude .git +clean: + rm -f -- *.[ao] ldadp qndtest version.in.h bindrequest.o: bindrequest.c ldap.h diff --git a/gen-version b/gen-version new file mode 100755 index 0000000..eccc47c --- /dev/null +++ b/gen-version @@ -0,0 +1,40 @@ +#!/bin/sh + +export LANG=C + +# Always create version string for repository this script lies in, +# not the cwd... Makes usage easier in cmake/out of source builds +ARG0="$0" +SELF="$(readlink -f "${ARG0}")" +if [ -n "$SELF" ]; then + ROOT_DIR="$(dirname "${SELF}")" + cd "$ROOT_DIR" +fi + +MODDED= +[ -n "$(git diff)" ] && MODDED='+LOCALMOD' + +VERSION=$(git describe || git rev-parse --short HEAD) + +BUILDTIME=$(date -R) + +COMMIT=$(git rev-parse HEAD) + +COMMITTIME=$(git log -1 --date=short --pretty=format:%cD) + +if [ -s ".localversion" ]; then + . .localversion +fi + +VERSION="$VERSION$MODDED" + +# replace +ssed() { + local fnd rep + fnd="%${1}%" + eval rep='"'\$$1'"' + sed "s/$fnd/$(echo "$rep" | sed 's,\\,\\\\,g;s,/,\\/,g')/g" +} + +< "version.in" ssed "VERSION" | ssed "BUILDTIME" | ssed "COMMIT" | ssed "COMMITTIME" > "version.in.h" + @@ -12,6 +12,7 @@ #include "helper.h" #include "openssl.h" #include "helper.h" +#include "version.in.h" #include <stdio.h> #include <socket.h> #include <io.h> @@ -29,6 +30,12 @@ static char *certFile = NULL, *keyFile = NULL; int main(int argc, char **argv) { BOOL isdaemon = TRUE; + printf("Starting up ldadp %s\n", LDADP_VERSION); + printf("Commit: %s\n", LDADP_COMMIT); + printf("Commit time: %s\n", LDADP_COMMITTIME); + printf("Build time: %s\n", LDADP_BUILDTIME); + if (argc > 1 && strcmp(argv[1], "--version") == 0) + exit(0); if (argc < 2) { printf("Nö\n"); exit(1); diff --git a/version.in b/version.in new file mode 100644 index 0000000..88f2458 --- /dev/null +++ b/version.in @@ -0,0 +1,13 @@ +#ifndef _VERSION_IN_ +#define _VERSION_IN_ + +#define LDADP_VERSION "%VERSION%" + +#define LDADP_COMMIT "%COMMIT%" + +#define LDADP_COMMITTIME "%COMMITTIME%" + +#define LDADP_BUILDTIME "%BUILDTIME%" + +#endif + |