$(QUIET_LINK)$(CC) $(CFLAGS) -lownet -shared -fPIC $< -o $@
clean:
- rm -vf rrdd *~ *.o .*.d *.so
+ rm -vf rrdd *~ *.o .*.d *.so .version version.h .compiler_check*
-.c.o:
+%.o: %.c .compiler_check
$(QUIET_CC)$(CC) -MMD -MF .$@.d $(CFLAGS) -c $< -o $@
$(Q)cp .$@.d .$@.P; \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < .$@.d >> .$@.P; \
mv .$@.P .$@.d
+version.h .compiler_check: FORCE
+ $(Q)./mkcompile_h "$(CC) $(CFLAGS)"
+
+FORCE:
+
+
TAGS:
@echo -e "\tTAGS\t"
@etags *.[ch]
#include <getopt.h>
#include <time.h>
+#include "version.h"
#include "process.h"
#include "rrdtool.h"
#include "parser.h"
int sleeptime;
int ret = 0;
+ pr_info("%s Version %s starting\n", argv[0], RRDD_VERSION);
+
bzero(&opts, sizeof(opts));
if (read_args(argc, argv, &opts) < 0)
--- /dev/null
+#!/bin/sh
+
+VERSION_TMP=.version
+VERSION_TARGET=version.h
+
+VERSION_STR=$(git show | grep ^commit | sed -e s.commit\ .. | cut -b -10)
+
+COMPILER_STR="$1"
+COMPILER_STR_TARGET=.compiler_check
+COMPILER_STR_TMP=$COMPILER_CHECK.tmp
+
+echo > $VERSION_TMP
+echo "#ifndef _VERSION_H_" >> $VERSION_TMP
+echo "#define _VERSION_H_" >> $VERSION_TMP
+echo >> $VERSION_TMP
+echo "/* Autogenerated version.h file */" >> $VERSION_TMP
+echo >> $VERSION_TMP
+echo "#define RRDD_VERSION \"$VERSION_STR\"" >> $VERSION_TMP
+echo >> $VERSION_TMP
+echo "#endif" >> $VERSION_TMP
+
+if [ -f $VERSION_TARGET ] ; then
+ cmp -s $VERSION_TMP $VERSION_TARGET || cp $VERSION_TMP $VERSION_TARGET
+else
+ cp $VERSION_TMP $VERSION_TARGET
+fi
+
+echo $COMPILER_STR > $COMPILER_STR_TMP
+
+if [ -f $COMPILER_STR_TARGET ] ; then
+ cmp -s $COMPILER_STR_TMP $COMPILER_STR_TARGET || \
+ cp $COMPILER_STR_TMP $COMPILER_STR_TARGET
+else
+ cp $COMPILER_STR_TMP $COMPILER_STR_TARGET
+fi
+