drh | 90ca975 | 2001-09-28 17:47:14 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # This script is used to compile SQLite and all its documentation and |
| 4 | # ship everything up to the SQLite website. This script will only work |
| 5 | # on the system "zadok" at the Hwaci offices. But others might find |
| 6 | # the script useful as an example. |
| 7 | # |
| 8 | |
| 9 | # Set srcdir to the name of the directory that contains the publish.sh |
| 10 | # script. |
| 11 | # |
| 12 | srcdir=`echo "$0" | sed 's%\(^.*\)/[^/][^/]*$%\1%'` |
| 13 | |
| 14 | # Get the makefile. |
| 15 | # |
drh | 7680032 | 2002-08-13 20:45:39 +0000 | [diff] [blame] | 16 | cp $srcdir/Makefile.linux-gcc ./Makefile |
drh | 75f6a03 | 2004-07-15 14:15:00 +0000 | [diff] [blame] | 17 | cp $srcdir/sqlite3.def ./sqlite3.def |
drh | e8a6342 | 2004-01-27 17:46:55 +0000 | [diff] [blame] | 18 | chmod +x $srcdir/install-sh |
drh | 90ca975 | 2001-09-28 17:47:14 +0000 | [diff] [blame] | 19 | |
drh | 7b93ed3 | 2004-06-16 03:02:00 +0000 | [diff] [blame] | 20 | # Get the current version number - needed to help build filenames |
| 21 | # |
| 22 | VERS=`cat $srcdir/VERSION` |
| 23 | VERSW=`sed 's/\./_/g' $srcdir/VERSION` |
| 24 | |
| 25 | # Start by building an sqlite shell for linux. |
drh | 90ca975 | 2001-09-28 17:47:14 +0000 | [diff] [blame] | 26 | # |
| 27 | make clean |
drh | 7b93ed3 | 2004-06-16 03:02:00 +0000 | [diff] [blame] | 28 | make sqlite3 |
| 29 | strip sqlite3 |
| 30 | mv sqlite3 sqlite3-$VERS.bin |
| 31 | gzip sqlite3-$VERS.bin |
| 32 | mv sqlite3-$VERS.bin.gz doc |
drh | 90ca975 | 2001-09-28 17:47:14 +0000 | [diff] [blame] | 33 | |
| 34 | # Build the tclsqlite.so shared library for import into tclsh or wish |
| 35 | # under Linux |
| 36 | # |
| 37 | make target_source |
| 38 | cd tsrc |
drh | 43d0578 | 2004-06-18 15:13:48 +0000 | [diff] [blame] | 39 | zip ../doc/sqlite-source-$VERSW.zip * |
drh | 90ca975 | 2001-09-28 17:47:14 +0000 | [diff] [blame] | 40 | rm shell.c |
| 41 | TCLDIR=/home/drh/tcltk/8.2linux |
drh | 66f95a6 | 2001-09-28 18:10:55 +0000 | [diff] [blame] | 42 | TCLSTUBLIB=$TCLDIR/libtclstub8.2g.a |
drh | a297b5c | 2002-01-15 18:39:43 +0000 | [diff] [blame] | 43 | OPTS='-DUSE_TCL_STUBS=1 -DNDEBUG=1' |
drh | 66f95a6 | 2001-09-28 18:10:55 +0000 | [diff] [blame] | 44 | gcc -fPIC $OPTS -O2 -I. -I$TCLDIR -shared *.c $TCLSTUBLIB -o tclsqlite.so |
drh | 90ca975 | 2001-09-28 17:47:14 +0000 | [diff] [blame] | 45 | strip tclsqlite.so |
drh | 7b93ed3 | 2004-06-16 03:02:00 +0000 | [diff] [blame] | 46 | mv tclsqlite.so tclsqlite-$VERS.so |
| 47 | gzip tclsqlite-$VERS.so |
| 48 | mv tclsqlite-$VERS.so.gz ../doc |
drh | 1c92853 | 2002-01-31 15:54:21 +0000 | [diff] [blame] | 49 | rm tclsqlite.c |
| 50 | gcc -fPIC -DNDEBUG=1 -O2 -I. -shared *.c -o sqlite.so |
| 51 | strip sqlite.so |
drh | 7b93ed3 | 2004-06-16 03:02:00 +0000 | [diff] [blame] | 52 | mv sqlite.so sqlite-$VERS.so |
| 53 | gzip sqlite-$VERS.so |
| 54 | mv sqlite-$VERS.so.gz ../doc |
drh | 90ca975 | 2001-09-28 17:47:14 +0000 | [diff] [blame] | 55 | cd .. |
drh | 90ca975 | 2001-09-28 17:47:14 +0000 | [diff] [blame] | 56 | |
| 57 | # Build the tclsqlite.dll shared library that can be imported into tclsh |
| 58 | # or wish on windows. |
| 59 | # |
| 60 | make target_source |
| 61 | cd tsrc |
drh | 66f95a6 | 2001-09-28 18:10:55 +0000 | [diff] [blame] | 62 | rm shell.c |
drh | 90ca975 | 2001-09-28 17:47:14 +0000 | [diff] [blame] | 63 | TCLDIR=/home/drh/tcltk/8.2win |
| 64 | TCLSTUBLIB=$TCLDIR/tclstub82.a |
| 65 | PATH=$PATH:/opt/mingw/bin |
drh | a297b5c | 2002-01-15 18:39:43 +0000 | [diff] [blame] | 66 | OPTS='-DUSE_TCL_STUBS=1 -DNDEBUG=1 -DTHREADSAFE=1' |
drh | 1f66c57 | 2002-07-02 11:55:32 +0000 | [diff] [blame] | 67 | CC="i386-mingw32msvc-gcc -O2 $OPTS -I. -I$TCLDIR" |
drh | 90ca975 | 2001-09-28 17:47:14 +0000 | [diff] [blame] | 68 | rm shell.c |
| 69 | for i in *.c; do |
| 70 | CMD="$CC -c $i" |
| 71 | echo $CMD |
| 72 | $CMD |
| 73 | done |
drh | 8eebadf | 2004-06-22 14:41:35 +0000 | [diff] [blame] | 74 | echo 'EXPORTS' >tclsqlite3.def |
drh | ee4a187 | 2004-07-01 11:25:35 +0000 | [diff] [blame] | 75 | echo 'Tclsqlite3_Init' >>tclsqlite3.def |
| 76 | echo 'Sqlite3_Init' >>tclsqlite3.def |
drh | 1f66c57 | 2002-07-02 11:55:32 +0000 | [diff] [blame] | 77 | i386-mingw32msvc-dllwrap \ |
drh | 8eebadf | 2004-06-22 14:41:35 +0000 | [diff] [blame] | 78 | --def tclsqlite3.def -v --export-all \ |
drh | 1f66c57 | 2002-07-02 11:55:32 +0000 | [diff] [blame] | 79 | --driver-name i386-mingw32msvc-gcc \ |
| 80 | --dlltool-name i386-mingw32msvc-dlltool \ |
| 81 | --as i386-mingw32msvc-as \ |
drh | 90ca975 | 2001-09-28 17:47:14 +0000 | [diff] [blame] | 82 | --target i386-mingw32 \ |
drh | 8eebadf | 2004-06-22 14:41:35 +0000 | [diff] [blame] | 83 | -dllname tclsqlite3.dll -lmsvcrt *.o $TCLSTUBLIB |
drh | ee4a187 | 2004-07-01 11:25:35 +0000 | [diff] [blame] | 84 | i386-mingw32msvc-strip tclsqlite3.dll |
drh | 1c92853 | 2002-01-31 15:54:21 +0000 | [diff] [blame] | 85 | rm tclsqlite.o |
drh | 75f6a03 | 2004-07-15 14:15:00 +0000 | [diff] [blame] | 86 | cp ../sqlite3.def . |
drh | 1f66c57 | 2002-07-02 11:55:32 +0000 | [diff] [blame] | 87 | i386-mingw32msvc-dllwrap \ |
drh | ee4a187 | 2004-07-01 11:25:35 +0000 | [diff] [blame] | 88 | --def sqlite3.def -v --export-all \ |
drh | 1f66c57 | 2002-07-02 11:55:32 +0000 | [diff] [blame] | 89 | --driver-name i386-mingw32msvc-gcc \ |
| 90 | --dlltool-name i386-mingw32msvc-dlltool \ |
| 91 | --as i386-mingw32msvc-as \ |
drh | 1c92853 | 2002-01-31 15:54:21 +0000 | [diff] [blame] | 92 | --target i386-mingw32 \ |
drh | 8eebadf | 2004-06-22 14:41:35 +0000 | [diff] [blame] | 93 | -dllname sqlite3.dll -lmsvcrt *.o |
| 94 | i386-mingw32msvc-strip sqlite3.dll |
| 95 | zip ../doc/tclsqlite-$VERSW.zip tclsqlite3.dll |
drh | 8685a94 | 2004-07-22 18:44:23 +0000 | [diff] [blame] | 96 | echo zip ../doc/tclsqlite-$VERSW.zip tclsqlite3.dll |
drh | 8eebadf | 2004-06-22 14:41:35 +0000 | [diff] [blame] | 97 | zip ../doc/sqlitedll-$VERSW.zip sqlite3.dll sqlite3.def |
drh | 8685a94 | 2004-07-22 18:44:23 +0000 | [diff] [blame] | 98 | echo zip ../doc/sqlitedll-$VERSW.zip sqlite3.dll sqlite3.def |
drh | 90ca975 | 2001-09-28 17:47:14 +0000 | [diff] [blame] | 99 | cd .. |
drh | 90ca975 | 2001-09-28 17:47:14 +0000 | [diff] [blame] | 100 | |
| 101 | # Build the sqlite.exe executable for windows. |
| 102 | # |
| 103 | make target_source |
| 104 | cd tsrc |
| 105 | rm tclsqlite.c |
drh | a297b5c | 2002-01-15 18:39:43 +0000 | [diff] [blame] | 106 | OPTS='-DSTATIC_BUILD=1 -DNDEBUG=1' |
drh | 8eebadf | 2004-06-22 14:41:35 +0000 | [diff] [blame] | 107 | i386-mingw32msvc-gcc -O2 $OPTS -I. -I$TCLDIR *.c -o sqlite3.exe |
| 108 | zip ../doc/sqlite-$VERSW.zip sqlite3.exe |
drh | 90ca975 | 2001-09-28 17:47:14 +0000 | [diff] [blame] | 109 | cd .. |
drh | 90ca975 | 2001-09-28 17:47:14 +0000 | [diff] [blame] | 110 | |
| 111 | # Construct a tarball of the source tree |
| 112 | # |
| 113 | ORIGIN=`pwd` |
| 114 | cd $srcdir |
| 115 | cd .. |
drh | 8685a94 | 2004-07-22 18:44:23 +0000 | [diff] [blame] | 116 | EXCLUDE=`find sqlite -print | grep CVS | sed 's,^, --exclude ,'` |
drh | 7b93ed3 | 2004-06-16 03:02:00 +0000 | [diff] [blame] | 117 | tar czf $ORIGIN/doc/sqlite-$VERS.tar.gz $EXCLUDE sqlite |
drh | 90ca975 | 2001-09-28 17:47:14 +0000 | [diff] [blame] | 118 | cd $ORIGIN |
drh | 90ca975 | 2001-09-28 17:47:14 +0000 | [diff] [blame] | 119 | |
doughenry | 1d36650 | 2002-03-29 01:29:53 +0000 | [diff] [blame] | 120 | # |
| 121 | # Build RPMS (binary) and Source RPM |
| 122 | # |
| 123 | |
drh | 203c211 | 2002-03-29 18:16:04 +0000 | [diff] [blame] | 124 | # Make sure we are properly setup to build RPMs |
| 125 | # |
| 126 | echo "%HOME %{expand:%%(cd; pwd)}" > $HOME/.rpmmacros |
| 127 | echo "%_topdir %{HOME}/rpm" >> $HOME/.rpmmacros |
| 128 | mkdir $HOME/rpm |
| 129 | mkdir $HOME/rpm/BUILD |
| 130 | mkdir $HOME/rpm/SOURCES |
| 131 | mkdir $HOME/rpm/RPMS |
| 132 | mkdir $HOME/rpm/SRPMS |
| 133 | mkdir $HOME/rpm/SPECS |
doughenry | 1d36650 | 2002-03-29 01:29:53 +0000 | [diff] [blame] | 134 | |
| 135 | # create the spec file from the template |
drh | 7b93ed3 | 2004-06-16 03:02:00 +0000 | [diff] [blame] | 136 | sed s/SQLITE_VERSION/$VERS/g $srcdir/spec.template > $HOME/rpm/SPECS/sqlite.spec |
doughenry | 1d36650 | 2002-03-29 01:29:53 +0000 | [diff] [blame] | 137 | |
| 138 | # copy the source tarball to the rpm directory |
drh | 7b93ed3 | 2004-06-16 03:02:00 +0000 | [diff] [blame] | 139 | cp doc/sqlite-$VERS.tar.gz $HOME/rpm/SOURCES/. |
doughenry | 1d36650 | 2002-03-29 01:29:53 +0000 | [diff] [blame] | 140 | |
| 141 | # build all the rpms |
| 142 | rpm -ba $HOME/rpm/SPECS/sqlite.spec >& rpm-$vers.log |
| 143 | |
drh | 203c211 | 2002-03-29 18:16:04 +0000 | [diff] [blame] | 144 | # copy the RPMs into the build directory. |
drh | 7b93ed3 | 2004-06-16 03:02:00 +0000 | [diff] [blame] | 145 | mv $HOME/rpm/RPMS/i386/sqlite*-$vers*.rpm doc |
| 146 | mv $HOME/rpm/SRPMS/sqlite-$vers*.rpm doc |
doughenry | 1d36650 | 2002-03-29 01:29:53 +0000 | [diff] [blame] | 147 | |
drh | 90ca975 | 2001-09-28 17:47:14 +0000 | [diff] [blame] | 148 | # Build the website |
| 149 | # |
drh | 20753fb | 2004-07-22 18:53:17 +0000 | [diff] [blame] | 150 | #cp $srcdir/../historical/* doc |
drh | 90ca975 | 2001-09-28 17:47:14 +0000 | [diff] [blame] | 151 | make doc |