summaryrefslogtreecommitdiff
path: root/src/third_party/scripts/timelib_get_sources.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/scripts/timelib_get_sources.sh')
-rwxr-xr-xsrc/third_party/scripts/timelib_get_sources.sh117
1 files changed, 117 insertions, 0 deletions
diff --git a/src/third_party/scripts/timelib_get_sources.sh b/src/third_party/scripts/timelib_get_sources.sh
new file mode 100755
index 00000000000..5125a8f0c5f
--- /dev/null
+++ b/src/third_party/scripts/timelib_get_sources.sh
@@ -0,0 +1,117 @@
+#!/bin/bash
+
+set -o verbose
+set -o errexit
+
+# This script downloads and imports timelib
+# timelib does not use any autotools/cmake/config system to it is a simple import.
+
+# This script is designed to run on Linux or Mac OS X
+# Parsers make use of re2c, which needs to be installed and at least be version
+# 0.16.
+#
+
+VERSION=2017.05beta3
+NAME=timelib
+TARBALL=$VERSION.tar.gz
+TARBALL_DIR=$NAME-$VERSION
+TEMP_DIR=/tmp/temp-$NAME-$VERSION
+DEST_DIR=`git rev-parse --show-toplevel`/src/third_party/$NAME-$VERSION
+
+# Check prerequisites: re2c, wget
+if ! [ -x "$(command -v re2c)" ]; then
+ echo 'Error: re2c is not installed.' >&2
+ exit 1
+fi
+if ! [ -x "$(command -v wget)" ]; then
+ echo 'Error: wget is not installed.' >&2
+ exit 1
+fi
+
+if [ ! -f $TARBALL ]; then
+ echo "Get tarball"
+ wget https://github.com/derickr/timelib/archive/$TARBALL
+fi
+
+echo $TARBALL
+tar -zxvf $TARBALL
+
+rm -rf $TEMP_DIR
+mv $TARBALL_DIR $TEMP_DIR
+mkdir $DEST_DIR || true
+
+cp -r $TEMP_DIR/* $DEST_DIR
+
+cd $DEST_DIR
+
+# Prune files
+rm -rf $DEST_DIR/tests
+rm $DEST_DIT/zones/old-tzcode-32-bit-output.tar.gz || true
+
+# Create parsers
+echo "Creating parsers"
+make parse_date.c parse_iso_intervals.c
+
+# Create SConscript file
+cat << EOF > SConscript
+# This is a generated file, please do not modify. It is generated by
+# timelib_get_sources.sh
+
+Import('env')
+
+env = env.Clone()
+
+try:
+ env.AppendUnique(CCFLAGS=[
+ '-DHAVE_GETTIMEOFDAY',
+ '-DHAVE_STRING_H',
+ ])
+ if env.TargetOSIs('windows'):
+ env.AppendUnique(CCFLAGS=[
+ '-DHAVE_IO_H',
+ '-DHAVE_WINSOCK2_H',
+ ])
+ elif env.TargetOSIs('solaris'):
+ env.AppendUnique(CCFLAGS=[
+ '-DHAVE_DIRENT_H',
+ '-DHAVE_STRINGS_H',
+ '-DHAVE_UNISTD_H',
+ '-D_POSIX_C_SOURCE=200112L',
+ ])
+ elif env.TargetOSIs('darwin'):
+ env.AppendUnique(CCFLAGS=[
+ '-DHAVE_DIRENT_H',
+ '-DHAVE_SYS_TIME_H',
+ '-DHAVE_UNISTD_H',
+ ])
+ else:
+ env.AppendUnique(CCFLAGS=[
+ '-DHAVE_DIRENT_H',
+ '-DHAVE_SYS_TIME_H',
+ '-DHAVE_UNISTD_H',
+ '-D_GNU_SOURCE',
+ ])
+except ValueError:
+ pass
+
+env.Library(
+ target='timelib',
+ source=[
+ 'astro.c',
+ 'dow.c',
+ 'interval.c',
+ 'parse_date.c',
+ 'parse_iso_intervals.c',
+ 'parse_tz.c',
+ 'parse_zoneinfo.c',
+ 'timelib.c',
+ 'tm2unixtime.c',
+ 'unixtime2tm.c',
+ ],
+ LIBDEPS_TAGS=[
+ 'init-no-global-side-effects',
+ ],
+)
+EOF
+
+echo "Done"