On Thu, Sep 22, 2005 at 07:23:57AM -0700, Doug Hanks wrote:
> Has anyone went through (what I feel is a painful process) of adding
> sqlite in a GNU project?

The following may help, which is a small package:
   http://ftp1.sourceforge.net/souptonuts/quota_examples.tar.gz
or
   http://ftp1.sourceforge.net/cpearls/simple_but_common_cpp.tar.gz

I put the following in my configure.in or configure.am file which
checks for version 3 of sqlite.

  AC_CHECK_LIB(sqlite3,sqlite3_open,[],found=no)

This is the full configure.in file


AC_INIT(getquota.c)
AC_PROG_CXX

if test -f VERSION; then
  VERSION=`cat VERSION`
  echo "Version set to $VERSION"
else
  VERSION='0.0.0'
fi
AM_INIT_AUTOMAKE(quota_examples, $VERSION )
AC_PROG_CXX
CXXFLAGS='-Wall -W -O2 -s -pipe'                                    
CFLAGS='-Wall -W -O2 -s -pipe'      


AM_CONDITIONAL(HAVE_SQLITE, true)
AC_CHECK_LIB(sqlite3,sqlite3_open,[],found=no)
 if test "$found" = "no"; then
   AC_CHECK_FILE(/usr/local/lib/libsqlite3.a, found=yes)
   if test "$found" = "yes"; then
     SQLLIBS="-lsqlite3 "
     INCLUDES="$INCLUDES -I/usr/local/include"
     EXTRALIB='-L/usr/local/lib'
    else
     AM_CONDITIONAL(HAVE_SQLITE, false)
     echo ""
     echo " 
-----------------------------------------------------------------------"
     echo "| Are you SURE sqlite3 is installed?                                 
   |"
     echo "|  You need to try this:                                             
   |"
     echo "|    export LDFLAGS='-L/usr/<some directory where sqlite is 
located>'   |"
     echo "|     ./configure                                                    
   |"
     echo " 
-----------------------------------------------------------------------" 
     echo "|  Will not compile the sqlite programs. But, why not install 
SQLite?   |"
     echo "|       $ wget http://www.sqlite.org/sqlite-3.2.2.tar.gz             
   |"
     echo " 
-----------------------------------------------------------------------" 
     echo ""
   fi
 else
   SQLLIBS="$LIBS"
   LIBS=""
 fi
SQLIBOBJS='-Wl,-R/usr/local/lib'
AC_SUBST(SQLIBOBJS)
AC_SUBST(SQLLIBS)
AC_SUBST(INCLUDES)
AC_SUBST(EXTRALIB)
AC_OUTPUT(Makefile)


Below is an example of the Makefile.am that goes with the 
configure.in above.

if HAVE_SQLITE
bin_PROGRAMS = getquota setquotas quotadb
else
bin_PROGRAMS = getquota setquotas 
endif

getquota_SOURCES = getquota.c quota.h


setquotas_SOURCES = setquotas.c quota.h


quotadb_SOURCES = quotadb.c quota.h
quotadb_LDADD =  @INCLUDES@ @SQLIBOBJS@ @EXTRALIB@ @SQLLIBS@


Hope with helps. 

Regards,

Mike Chirico

Reply via email to