2010-05-27 09:41:46 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# __________ __ ___.
|
|
|
|
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
# \/ \/ \/ \/ \/
|
|
|
|
|
2010-05-28 04:07:57 +00:00
|
|
|
# Usage: genversion.sh c/h destination-dir path-to-version.sh [source-root]
|
2010-05-27 09:41:46 +00:00
|
|
|
|
2010-05-28 04:07:57 +00:00
|
|
|
# Generate version.[ch] files (if first argument is c or h)
|
2010-05-27 09:41:46 +00:00
|
|
|
|
2010-05-28 04:07:57 +00:00
|
|
|
# XXX DO NOT TWEAK VERSION HERE, EDIT version.sh INSTEAD
|
2010-05-27 09:41:46 +00:00
|
|
|
|
2010-05-28 04:07:57 +00:00
|
|
|
VERSION=`$3 $4`
|
|
|
|
|
|
|
|
if [ "$1" = "h" ]; then
|
|
|
|
cat > "$2/_version.h" << EOF
|
2010-05-27 09:41:46 +00:00
|
|
|
/* Generated by genversion.sh */
|
|
|
|
extern const char rbversion[];
|
|
|
|
#define RBVERSION "$VERSION"
|
|
|
|
EOF
|
|
|
|
|
2010-05-28 04:07:57 +00:00
|
|
|
if [ -f "$2/version.h" ]
|
|
|
|
then if diff "$2/_version.h" "$2/version.h" > /dev/null
|
|
|
|
then mv "$2/_version.h" "$2/version.h"
|
|
|
|
else rm -f "$2/_version.h"
|
|
|
|
fi
|
|
|
|
else mv "$2/_version.h" "$2/version.h"
|
2010-05-27 09:41:46 +00:00
|
|
|
fi
|
2010-05-28 04:07:57 +00:00
|
|
|
elif [ "$1" = "c" ]; then
|
|
|
|
cat > "$2/_version.c" << EOF
|
2010-05-27 09:41:46 +00:00
|
|
|
/* Generated by genversion.sh */
|
2010-05-28 04:07:57 +00:00
|
|
|
#include "version.h"
|
|
|
|
const char rbversion[] = RBVERSION;
|
2010-05-27 09:41:46 +00:00
|
|
|
EOF
|
|
|
|
|
2010-05-28 04:07:57 +00:00
|
|
|
if [ -f "$2/version.c" ]
|
|
|
|
then if diff "$2/_version.c" "$2/version.c" > /dev/null
|
|
|
|
then mv "$2/_version.c" "$2/version.c"
|
|
|
|
else rm -f "$2/_version.c"
|
|
|
|
fi
|
|
|
|
else mv "$2/_version.c" "$2/version.c"
|
2010-05-27 09:41:46 +00:00
|
|
|
fi
|
|
|
|
fi
|