OSDN Git Service

version.sh: add preprocessing guards
authorTimothy Gu <timothygu99@gmail.com>
Fri, 29 Nov 2013 17:57:30 +0000 (09:57 -0800)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 30 Nov 2013 20:42:03 +0000 (21:42 +0100)
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
version.sh

index c28ffe7..92edcb9 100755 (executable)
@@ -42,9 +42,17 @@ if [ -z "$2" ]; then
 fi
 
 NEW_REVISION="#define FFMPEG_VERSION \"$version\""
-OLD_REVISION=$(cat "$2" 2> /dev/null)
+OLD_REVISION=$(cat "$2" 2> /dev/null | head -3 | tail -1)
+
+# String used for preprocessor guard
+GUARD=$(echo "$2" | sed 's/\//_/' | sed 's/\./_/' | tr '[:lower:]' '[:upper:]' | sed 's/LIB//')
 
 # Update version header only on revision changes to avoid spurious rebuilds
 if test "$NEW_REVISION" != "$OLD_REVISION"; then
-    echo "$NEW_REVISION" > "$2"
+    cat << EOF > "$2"
+#ifndef $GUARD
+#define $GUARD
+$NEW_REVISION
+#endif /* $GUARD */
+EOF
 fi