/ Check-in [8ad0ab8c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Various changes to enable compilation of SQLite library and command line shell with the Windows CE cross compiler from cegcc.sourceforge.net (CVS 4541)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8ad0ab8cb374bd34e47af9e71b2aad9dd9af0d1b
User & Date: chw 2007-11-12 21:09:11
Context
2007-11-13
10:30
Modify the Tcl interface to use sqlite3_prepare_v2(). (CVS 4542) check-in: 7bb00c7d user: danielk1977 tags: trunk
2007-11-12
21:09
Various changes to enable compilation of SQLite library and command line shell with the Windows CE cross compiler from cegcc.sourceforge.net (CVS 4541) check-in: 8ad0ab8c user: chw tags: trunk
17:56
Another attempt at fixing a memory leak in the TCL interface. See check-in (4338) for the first attempt. Ticket #2597. (CVS 4540) check-in: 68a43c99 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added Makefile.arm-wince-mingw32ce-gcc.

            1  +#!/usr/make
            2  +#
            3  +# Makefile for SQLITE
            4  +#
            5  +# This is a template makefile for SQLite.  Most people prefer to
            6  +# use the autoconf generated "configure" script to generate the
            7  +# makefile automatically.  But that does not work for everybody
            8  +# and in every situation.  If you are having problems with the
            9  +# "configure" script, you might want to try this makefile as an
           10  +# alternative.  Create a copy of this file, edit the parameters
           11  +# below and type "make".
           12  +#
           13  +
           14  +#### The directory where to find the mingw32ce tools
           15  +MINGW32CE = /opt/mingw32ce/bin
           16  +
           17  +#### The target prefix of the mingw32ce tools
           18  +TARGET = arm-wince-mingw32ce
           19  +
           20  +#### The toplevel directory of the source tree.  This is the directory
           21  +#    that contains this "Makefile.in" and the "configure.in" script.
           22  +#
           23  +TOP = ../sqlite
           24  +
           25  +#### C Compiler and options for use in building executables that
           26  +#    will run on the platform that is doing the build.
           27  +#
           28  +BCC = gcc -g -O2
           29  +#BCC = /opt/ancic/bin/c89 -0
           30  +
           31  +#### If the target operating system supports the "usleep()" system
           32  +#    call, then define the HAVE_USLEEP macro for all C modules.
           33  +#
           34  +USLEEP = 
           35  +#USLEEP = -DHAVE_USLEEP=1
           36  +
           37  +#### If you want the SQLite library to be safe for use within a 
           38  +#    multi-threaded program, then define the following macro
           39  +#    appropriately:
           40  +#
           41  +THREADSAFE = -DTHREADSAFE=1
           42  +#THREADSAFE = -DTHREADSAFE=0
           43  +
           44  +#### Specify any extra linker options needed to make the library
           45  +#    thread safe
           46  +#
           47  +#THREADLIB = -lpthread
           48  +THREADLIB = 
           49  +
           50  +#### Specify any extra libraries needed to access required functions.
           51  +#
           52  +#TLIBS = -lrt    # fdatasync on Solaris 8
           53  +TLIBS = 
           54  +
           55  +#### Leave SQLITE_DEBUG undefined for maximum speed.  Use SQLITE_DEBUG=1
           56  +#    to check for memory leaks.  Use SQLITE_DEBUG=2 to print a log of all
           57  +#    malloc()s and free()s in order to track down memory leaks.
           58  +#    
           59  +#    SQLite uses some expensive assert() statements in the inner loop.
           60  +#    You can make the library go almost twice as fast if you compile
           61  +#    with -DNDEBUG=1
           62  +#
           63  +#OPTS = -DSQLITE_DEBUG=2
           64  +#OPTS = -DSQLITE_DEBUG=1
           65  +#OPTS = 
           66  +OPTS = -DNDEBUG=1 -DOS_WIN=1 -D_WIN32_WCE=1
           67  +#OPTS += -DHAVE_FDATASYNC=1
           68  +
           69  +#### The suffix to add to executable files.  ".exe" for windows.
           70  +#    Nothing for unix.
           71  +#
           72  +EXE = .exe
           73  +#EXE =
           74  +
           75  +#### C Compile and options for use in building executables that 
           76  +#    will run on the target platform.  This is usually the same
           77  +#    as BCC, unless you are cross-compiling.
           78  +#
           79  +#TCC = gcc -O6
           80  +#TCC = gcc -g -O0 -Wall
           81  +#TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage
           82  +#TCC = /opt/mingw/bin/i386-mingw32-gcc -O6
           83  +TCC = $(MINGW32CE)/$(TARGET)-gcc -O2
           84  +#TCC = /opt/ansic/bin/c89 -O +z -Wl,-a,archive
           85  +
           86  +#### Tools used to build a static library.
           87  +#
           88  +#AR = ar cr
           89  +#AR = /opt/mingw/bin/i386-mingw32-ar cr
           90  +AR = $(MINGW32CE)/$(TARGET)-ar cr
           91  +#RANLIB = ranlib
           92  +#RANLIB = /opt/mingw/bin/i386-mingw32-ranlib
           93  +RANLIB = $(MINGW32CE)/$(TARGET)-ranlib
           94  +
           95  +#MKSHLIB = gcc -shared
           96  +#SO = so
           97  +#SHPREFIX = lib
           98  +MKSHLIB = $(MINGW32CE)/$(TARGET)-gcc -shared
           99  +SO = dll
          100  +SHPREFIX =
          101  +
          102  +#### Extra compiler options needed for programs that use the TCL library.
          103  +#
          104  +#TCL_FLAGS =
          105  +#TCL_FLAGS = -DSTATIC_BUILD=1
          106  +TCL_FLAGS = -I/home/drh/tcltk/8.4linux
          107  +#TCL_FLAGS = -I/home/drh/tcltk/8.4win -DSTATIC_BUILD=1
          108  +#TCL_FLAGS = -I/home/drh/tcltk/8.3hpux
          109  +
          110  +#### Linker options needed to link against the TCL library.
          111  +#
          112  +#LIBTCL = -ltcl -lm -ldl
          113  +LIBTCL = /home/drh/tcltk/8.4linux/libtcl8.4g.a -lm -ldl
          114  +#LIBTCL = /home/drh/tcltk/8.4win/libtcl84s.a -lmsvcrt
          115  +#LIBTCL = /home/drh/tcltk/8.3hpux/libtcl8.3.a -ldld -lm -lc
          116  +
          117  +#### Additional objects for SQLite library when TCL support is enabled.
          118  +TCLOBJ =
          119  +#TCLOBJ = tclsqlite.o
          120  +
          121  +#### Compiler options needed for programs that use the readline() library.
          122  +#
          123  +READLINE_FLAGS =
          124  +#READLINE_FLAGS = -DHAVE_READLINE=1 -I/usr/include/readline
          125  +
          126  +#### Linker options needed by programs using readline() must link against.
          127  +#
          128  +LIBREADLINE =
          129  +#LIBREADLINE = -static -lreadline -ltermcap
          130  +
          131  +#### Which "awk" program provides nawk compatibilty
          132  +#
          133  +# NAWK = nawk
          134  +NAWK = awk
          135  +
          136  +# You should not have to change anything below this line
          137  +###############################################################################
          138  +include $(TOP)/main.mk

Changes to Makefile.linux-gcc.

    99     99   
   100    100   #### Linker options needed to link against the TCL library.
   101    101   #
   102    102   #LIBTCL = -ltcl -lm -ldl
   103    103   LIBTCL = /home/drh/tcltk/8.4linux/libtcl8.4g.a -lm -ldl
   104    104   #LIBTCL = /home/drh/tcltk/8.4win/libtcl84s.a -lmsvcrt
   105    105   #LIBTCL = /home/drh/tcltk/8.3hpux/libtcl8.3.a -ldld -lm -lc
          106  +
          107  +#### Additional objects for SQLite library when TCL support is enabled.
          108  +#TCLOBJ =
          109  +TCLOBJ = tclsqlite.o
   106    110   
   107    111   #### Compiler options needed for programs that use the readline() library.
   108    112   #
   109    113   READLINE_FLAGS =
   110    114   #READLINE_FLAGS = -DHAVE_READLINE=1 -I/usr/include/readline
   111    115   
   112    116   #### Linker options needed by programs using readline() must link against.

Changes to main.mk.

    51     51   LIBOBJ+= alter.o analyze.o attach.o auth.o btmutex.o btree.o build.o \
    52     52            callback.o complete.o date.o delete.o \
    53     53            expr.o func.o hash.o insert.o journal.o loadext.o \
    54     54            main.o malloc.o mem1.o mem2.o mem3.o mutex.o mutex_os2.o \
    55     55            mutex_unix.o mutex_w32.o \
    56     56            opcodes.o os.o os_os2.o os_unix.o os_win.o \
    57     57            pager.o parse.o pragma.o prepare.o printf.o random.o \
    58         -         select.o table.o tclsqlite.o tokenize.o trigger.o \
           58  +         select.o table.o $(TCLOBJ) tokenize.o trigger.o \
    59     59            update.o util.o vacuum.o \
    60     60            vdbe.o vdbeapi.o vdbeaux.o vdbeblob.o vdbefifo.o vdbemem.o \
    61     61            where.o utf.o legacy.o vtab.o
    62     62   
    63     63   EXTOBJ = icu.o
    64     64   EXTOBJ += fts1.o \
    65     65   	  fts1_hash.o \

Changes to src/os_win.c.

  1403   1403       h = LoadLibraryA((char*)zConverted);
  1404   1404   #endif
  1405   1405     }
  1406   1406     free(zConverted);
  1407   1407     return (void*)h;
  1408   1408   }
  1409   1409   static void winDlError(sqlite3_vfs *pVfs, int nBuf, char *zBufOut){
         1410  +#if OS_WINCE
         1411  +  int error = GetLastError();
         1412  +  if( error>0x7FFFFFF ){
         1413  +    sqlite3_snprintf(nBuf, zBufOut, "OsError 0x%x", error);
         1414  +  }else{
         1415  +    sqlite3_snprintf(nBuf, zBufOut, "OsError %d", error);
         1416  +  }
         1417  +#else
  1410   1418     FormatMessageA(
  1411   1419       FORMAT_MESSAGE_FROM_SYSTEM,
  1412   1420       NULL,
  1413   1421       GetLastError(),
  1414   1422       0,
  1415   1423       zBufOut,
  1416   1424       nBuf-1,
  1417   1425       0
  1418   1426     );
         1427  +#endif
  1419   1428   }
  1420   1429   void *winDlSym(sqlite3_vfs *pVfs, void *pHandle, const char *zSymbol){
  1421   1430   #if OS_WINCE
  1422   1431     /* The GetProcAddressA() routine is only available on wince. */
  1423   1432     return GetProcAddressA((HANDLE)pHandle, zSymbol);
  1424   1433   #else
  1425   1434     /* All other windows platforms expect GetProcAddress() to take

Changes to src/shell.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code to implement the "sqlite" command line
    13     13   ** utility for accessing SQLite databases.
    14     14   **
    15         -** $Id: shell.c,v 1.168 2007/11/02 12:53:04 drh Exp $
           15  +** $Id: shell.c,v 1.169 2007/11/12 21:09:11 chw Exp $
    16     16   */
    17     17   #include <stdlib.h>
    18     18   #include <string.h>
    19     19   #include <stdio.h>
    20     20   #include <assert.h>
    21     21   #include "sqlite3.h"
    22     22   #include <ctype.h>
................................................................................
    56     56   #if defined(_WIN32) || defined(WIN32)
    57     57   # include <io.h>
    58     58   #else
    59     59   /* Make sure isatty() has a prototype.
    60     60   */
    61     61   extern int isatty();
    62     62   #endif
           63  +
           64  +#if defined(_WIN32_WCE)
           65  +/* Windows CE (arm-wince-mingw32ce-gcc) does not provide isatty()
           66  + * thus we always assume that we have a console. That can be
           67  + * overridden with the -batch command line option.
           68  + */
           69  +#define isatty(x) 1
           70  +#endif
    63     71   
    64     72   #if !defined(_WIN32) && !defined(WIN32) && !defined(__OS2__)
    65     73   #include <sys/time.h>
    66     74   #include <sys/resource.h>
    67     75   
    68     76   /* Saved resource information for the beginning of an operation */
    69     77   static struct rusage sBegin;
................................................................................
  1755   1763   ** 0 return indicates an error of some kind.  Space to hold the
  1756   1764   ** resulting string is obtained from malloc().  The calling
  1757   1765   ** function should free the result.
  1758   1766   */
  1759   1767   static char *find_home_dir(void){
  1760   1768     char *home_dir = NULL;
  1761   1769   
  1762         -#if !defined(_WIN32) && !defined(WIN32) && !defined(__MACOS__) && !defined(__OS2__)
         1770  +#if !defined(_WIN32) && !defined(WIN32) && !defined(__MACOS__) && !defined(__OS2__) && !defined(_WIN32_WCE)
  1763   1771     struct passwd *pwent;
  1764   1772     uid_t uid = getuid();
  1765   1773     if( (pwent=getpwuid(uid)) != NULL) {
  1766   1774       home_dir = pwent->pw_dir;
  1767   1775     }
  1768   1776   #endif
  1769   1777   
  1770   1778   #ifdef __MACOS__
  1771   1779     char home_path[_MAX_PATH+1];
  1772   1780     home_dir = getcwd(home_path, _MAX_PATH);
  1773   1781   #endif
         1782  +
         1783  +#if defined(_WIN32_WCE)
         1784  +  /* Windows CE (arm-wince-mingw32ce-gcc) does not provide getenv()
         1785  +   */
         1786  +  home_dir = strdup("/");
         1787  +#else
  1774   1788   
  1775   1789   #if defined(_WIN32) || defined(WIN32) || defined(__OS2__)
  1776   1790     if (!home_dir) {
  1777   1791       home_dir = getenv("USERPROFILE");
  1778   1792     }
  1779   1793   #endif
  1780   1794   
................................................................................
  1794   1808         if( home_dir==0 ) return 0;
  1795   1809         sqlite3_snprintf(n, home_dir, "%s%s", zDrive, zPath);
  1796   1810         return home_dir;
  1797   1811       }
  1798   1812       home_dir = "c:\\";
  1799   1813     }
  1800   1814   #endif
         1815  +
         1816  +#endif /* !_WIN32_WCE */
  1801   1817   
  1802   1818     if( home_dir ){
  1803   1819       int n = strlen(home_dir) + 1;
  1804   1820       char *z = malloc( n );
  1805   1821       if( z ) memcpy(z, home_dir, n);
  1806   1822       home_dir = z;
  1807   1823     }