Snapshot of upstream SQLite 3.45.3
[sqlcipher.git] / tool / mkautoconfamal.sh
blob35dbfb41e0bd868969b58093427e379a079f3389
1 #!/bin/sh
2 # This script is used to build the amalgamation autoconf package.
3 # It assumes the following:
5 # 1. The files "sqlite3.c", "sqlite3.h", "sqlite3ext.h", "shell.c",
6 # and "sqlite3rc.h" are available in the current directory.
8 # 2. Variable $TOP is set to the full path of the root directory
9 # of the SQLite source tree.
11 # 3. There is nothing of value in the ./mkpkg_tmp_dir directory.
12 # This is important, as the script executes "rm -rf ./mkpkg_tmp_dir".
16 # Bail out of the script if any command returns a non-zero exit
17 # status. Or if the script tries to use an unset variable. These
18 # may fail for old /bin/sh interpreters.
20 set -e
21 set -u
23 TMPSPACE=./mkpkg_tmp_dir
24 VERSION=`cat $TOP/VERSION`
25 HASH=`sed 's/^\(..........\).*/\1/' $TOP/manifest.uuid`
26 DATETIME=`grep '^D' $TOP/manifest | sed -e 's/[^0-9]//g' -e 's/\(............\).*/\1/'`
28 # Verify that the version number in the TEA autoconf file is correct.
29 # Fail with an error if not.
31 if grep $VERSION $TOP/autoconf/tea/configure.ac
32 then echo "TEA version number ok"
33 else echo "TEA version number mismatch. Should be $VERSION"; exit 1
36 # If this script is given an argument of --snapshot, then generate a
37 # snapshot tarball named for the current checkout SHA1 hash, rather than
38 # the version number.
40 if test "$#" -ge 1 -a x$1 != x--snapshot
41 then
42 # Set global variable $ARTIFACT to the "3xxyyzz" string incorporated
43 # into artifact filenames. And $VERSION2 to the "3.x.y[.z]" form.
44 xx=`echo $VERSION|sed 's/3\.\([0-9]*\)\..*/\1/'`
45 yy=`echo $VERSION|sed 's/3\.[^.]*\.\([0-9]*\).*/\1/'`
46 zz=0
47 set +e
48 zz=`echo $VERSION|sed 's/3\.[^.]*\.[^.]*\.\([0-9]*\).*/\1/'|grep -v '\.'`
49 set -e
50 TARBALLNAME=`printf "sqlite-autoconf-3%.2d%.2d%.2d" $xx $yy $zz`
51 else
52 TARBALLNAME=sqlite-snapshot-$DATETIME
55 rm -rf $TMPSPACE
56 cp -R $TOP/autoconf $TMPSPACE
57 cp sqlite3.c $TMPSPACE
58 cp sqlite3.h $TMPSPACE
59 cp sqlite3ext.h $TMPSPACE
60 cp sqlite3rc.h $TMPSPACE
61 cp $TOP/sqlite3.1 $TMPSPACE
62 cp $TOP/sqlite3.pc.in $TMPSPACE
63 cp shell.c $TMPSPACE
64 cp $TOP/src/sqlite3.rc $TMPSPACE
65 cp $TOP/tool/Replace.cs $TMPSPACE
67 cat $TMPSPACE/configure.ac |
68 sed "s/--SQLITE-VERSION--/$VERSION/" > $TMPSPACE/tmp
69 mv $TMPSPACE/tmp $TMPSPACE/configure.ac
71 cd $TMPSPACE
72 autoreconf -i
73 #libtoolize
74 #aclocal
75 #autoconf
76 #automake --add-missing
78 mkdir -p tea/generic
79 echo "#ifdef USE_SYSTEM_SQLITE" > tea/generic/tclsqlite3.c
80 echo "# include <sqlite3.h>" >> tea/generic/tclsqlite3.c
81 echo "#else" >> tea/generic/tclsqlite3.c
82 echo "#include \"sqlite3.c\"" >> tea/generic/tclsqlite3.c
83 echo "#endif" >> tea/generic/tclsqlite3.c
84 cat $TOP/src/tclsqlite.c >> tea/generic/tclsqlite3.c
86 cat tea/configure.ac |
87 sed "s/AC_INIT(\[sqlite\], .*)/AC_INIT([sqlite], [$VERSION])/" > tmp
88 mv tmp tea/configure.ac
90 cd tea
91 autoconf
92 rm -rf autom4te.cache
94 cd ../
95 ./configure && make dist
96 tar -xzf sqlite-$VERSION.tar.gz
97 mv sqlite-$VERSION $TARBALLNAME
98 tar -czf $TARBALLNAME.tar.gz $TARBALLNAME
99 mv $TARBALLNAME.tar.gz ..
100 cd ..
101 ls -l $TARBALLNAME.tar.gz