PUD: generate and provide version in/from Makefile
authorFerry Huberts <ferry.huberts@pelagic.nl>
Mon, 23 Apr 2012 06:56:04 +0000 (08:56 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Mon, 23 Apr 2012 07:14:25 +0000 (09:14 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
.gitignore
lib/pud/Makefile
lib/pud/scripts/makeVersionH [deleted file]
lib/pud/src/pudOlsrdPlugin.c
lib/pud/src/version.h [deleted file]
lib/pud/wireformat-java/Makefile
lib/pud/wireformat-java/resources/WireFormatConstants.java.h

index 073b16f..f576b0f 100644 (file)
@@ -47,4 +47,3 @@ debian/olsrd.postinst.debhelper
 debian/olsrd.postrm.debhelper
 debian/olsrd.prerm.debhelper
 debian/olsrd.substvars
-lib/pud/src/version.h
index e479ea8..0decdd3 100644 (file)
@@ -13,7 +13,6 @@ include $(TOPDIR)/Makefile.inc
 CFLAGS += -Werror -D_GNU_SOURCE
 
 
-VERSION_FILE = ./src/version.h
 RESOURCESDIR = ./resources
 LIBRARY_INC = $(LIBRARY_PATH)/include
 LIBRARY_LIB = $(LIBRARY_PATH)/lib
@@ -21,6 +20,9 @@ LIBRARY_LIB = $(LIBRARY_PATH)/lib
 CFLAGS += -I $(LIBRARY_INC)
 LIBS += -L $(LIBRARY_LIB) -lnmea -lm -l$(LIBRARY_NAME)
 
+GIT_SHA = $(shell git describe)
+CFLAGS += -DGIT_SHA=\"$(GIT_SHA)\" -DPLUGIN_VER=\"$(PLUGIN_VER)\"
+
 ifneq ($(OS),linux)
 
 .PHONY: all default_target install clean
@@ -36,7 +38,7 @@ else
 
 all: default_target
 
-default_target: library $(VERSION_FILE) $(PLUGIN_FULLNAME)
+default_target: library $(PLUGIN_FULLNAME)
 
 # repeat from toplevel Makefile.inc, and adjust: we need the library includes
 %.d: %.c
@@ -46,9 +48,6 @@ $(PLUGIN_FULLNAME): $(OBJS) version-script.txt
        @echo "[LD] $@"
        @$(CC) $(LDFLAGS) -o $(PLUGIN_FULLNAME) $(OBJS) $(LIBS)
 
-$(VERSION_FILE): library scripts/makeVersionH
-       @./scripts/makeVersionH "$(VERSION_FILE)" "$(PLUGIN_VER)"
-
 install: all
        @$(MAKE) -C $(LIBRARY_PATH) DESTDIR=$(DESTDIR) install
        $(INSTALL_LIB)
diff --git a/lib/pud/scripts/makeVersionH b/lib/pud/scripts/makeVersionH
deleted file mode 100755 (executable)
index daeae39..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/bin/bash
-
-set -e
-set -u
-
-if [[ ${#} -ne 2 ]]; then
-  echo "Need 2 arguments: outfile version"
-  exit 1
-fi
-
-outfile="${1}"
-version="${2}"
-
-
-outfileDir="$(dirname "${outfile}")"
-outfileName="$(basename "${outfile}")"
-tmpFile="$(mktemp --tmpdir="${outfileDir}" "${outfileName}.XXXXXXXXXX")"
-
-
-set +e
-sha="$(git describe 2> /dev/null)"
-set -e
-
-
-cat > "${tmpFile}" << EOF
-#ifndef _PUD_VERSION_H_
-#define _PUD_VERSION_H_
-
-#define PLUGIN_VER "${version}"
-EOF
-
-if [[ -z "${sha:-}" ]]; then
-  sha="OLSRD_Unknown-g0000000"
-fi
-
-cat >> "${tmpFile}" << EOF
-#define GIT_SHA    "${sha}"
-EOF
-
-cat >> "${tmpFile}" << EOF
-
-#endif /* _PUD_VERSION_H_ */
-EOF
-
-
-set +e
-diff "${outfile}" "${tmpFile}" &> /dev/null
-declare -i diffResult=$?
-set -e
-
-if [[ ${diffResult} -eq 0 ]]; then
-  rm -f "${tmpFile}"
-else
-  echo "[${outfile}]"
-  mv "${tmpFile}" "${outfile}"
-fi
-
index b219029..d2c4b4a 100644 (file)
@@ -2,7 +2,6 @@
 
 /* Plugin includes */
 #include "pud.h"
-#include "version.h"
 
 /* OLSRD includes */
 #include "olsr.h"
diff --git a/lib/pud/src/version.h b/lib/pud/src/version.h
deleted file mode 100644 (file)
index 884b7bd..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _PUD_VERSION_H_
-#define _PUD_VERSION_H_
-
-#define PLUGIN_VER "1.1.0"
-#define GIT_SHA    "OLSRD_Unknown-g0000000"
-
-#endif /* _PUD_VERSION_H_ */
index 3141dd9..9ec09b5 100644 (file)
@@ -61,6 +61,8 @@ JAVA_PKG = org.olsr.plugin.pud
 JAVA_PKG_DIR = $(subst .,/,$(JAVA_PKG))
 JAVA_PKG_UNDER = $(subst .,_,$(JAVA_PKG))
 
+GIT_SHA = $(shell git describe)
+
 
 ifneq ($(OS),linux)
 
@@ -191,10 +193,9 @@ build.xml: $(RESOURCES_DIR)/build.xml
 $(JAVASRC)/$(JAVA_PKG_DIR)/WireFormatConstants.java: \
       $(RESOURCES_DIR)/WireFormatConstants.java.h \
       $(BUILD_DIR_JNI)/c/library.h \
-      $(BUILD_DIR_JNI)/c/version.h \
       $(BUILD_DIR_JNI)/c/wireFormat.h
        @echo "[generate] $@"
-       @$(CPP) -I "$(BUILD_DIR_JNI)/c" "$<" | \
+       @$(CPP) -I "$(BUILD_DIR_JNI)/c" -DPLUGIN_VER=\"$(PLUGIN_VER)\" -DGIT_SHA=\"$(GIT_SHA)\" "$<" | \
          sed -r -e '/^[[:space:]]*#.*$$/ d' \
                 -e '/^[[:space:]]*$$/ d' \
                 > "$@"
@@ -208,10 +209,6 @@ $(BUILD_DIR_JNI)/c/library.h: Makefile.inc
        @echo "[generate] $@"
        @echo "#define PUD_WIRE_FORMAT_LIBRARYNAME \"$(PROJECT)\"" > "$@"
 
-$(BUILD_DIR_JNI)/c/version.h: ../scripts/makeVersionH
-       @echo "[generate] $@"
-       @"$<" "$@" "$(PLUGIN_VER)"
-
 $(BUILD_DIR_JNI)/c/wireFormat.h: $(INC_DIR_WIREFORMAT_FULL)/wireFormat.h
        @echo "[generate] $@"
        @grep -E '^[[:space:]]*#define[[:space:]]+' "$<" > "$@"
index dc89788..9b4ae91 100644 (file)
@@ -1,5 +1,4 @@
 #include "library.h"
-#include "version.h"
 #include "wireFormat.h"
 #ifndef GIT_SHA
   #define GIT_SHA ""