libpst

changeset 95:ff1743cbe4aa

initial attempt at building a shared library
author Carl Byington <carl@five-ten-sg.com>
date Sat, 13 Sep 2008 20:15:40 -0700
parents 997cf1373f9e
children 2e3ec9511166
files Makefile.am compile configure.in libpst.pc.in src/Makefile.am
diffstat 5 files changed, 215 insertions(+), 3 deletions(-) [+]
line diff
     1.1 --- a/Makefile.am	Tue Sep 09 11:11:56 2008 -0700
     1.2 +++ b/Makefile.am	Sat Sep 13 20:15:40 2008 -0700
     1.3 @@ -2,5 +2,9 @@
     1.4  htmldir = ${datadir}/doc/@PACKAGE@-@VERSION@
     1.5  html_DATA = AUTHORS COPYING ChangeLog NEWS README
     1.6  CLEANFILES = xml/libpst xml/Makefile
     1.7 +
     1.8 +pkgconfigdir = $(libdir)/pkgconfig
     1.9 +pkgconfig_DATA = libpst.pc
    1.10 +
    1.11  EXTRA_DIST = Doxyfile libpst.html.tar.gz libpst.spec $(wildcard xml/M*) $(wildcard xml/h*) $(wildcard xml/lib*)
    1.12  
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/compile	Sat Sep 13 20:15:40 2008 -0700
     2.3 @@ -0,0 +1,140 @@
     2.4 +#! /bin/sh
     2.5 +# Wrapper for compilers which do not understand `-c -o'.
     2.6 +
     2.7 +scriptversion=2004-09-10.20
     2.8 +
     2.9 +# Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
    2.10 +# Written by Tom Tromey <tromey@cygnus.com>.
    2.11 +#
    2.12 +# This program is free software; you can redistribute it and/or modify
    2.13 +# it under the terms of the GNU General Public License as published by
    2.14 +# the Free Software Foundation; either version 2, or (at your option)
    2.15 +# any later version.
    2.16 +#
    2.17 +# This program is distributed in the hope that it will be useful,
    2.18 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.19 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.20 +# GNU General Public License for more details.
    2.21 +#
    2.22 +# You should have received a copy of the GNU General Public License
    2.23 +# along with this program; if not, write to the Free Software
    2.24 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    2.25 +
    2.26 +# As a special exception to the GNU General Public License, if you
    2.27 +# distribute this file as part of a program that contains a
    2.28 +# configuration script generated by Autoconf, you may include it under
    2.29 +# the same distribution terms that you use for the rest of that program.
    2.30 +
    2.31 +# This file is maintained in Automake, please report
    2.32 +# bugs to <bug-automake@gnu.org> or send patches to
    2.33 +# <automake-patches@gnu.org>.
    2.34 +
    2.35 +case $1 in
    2.36 +  '')
    2.37 +     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
    2.38 +     exit 1;
    2.39 +     ;;
    2.40 +  -h | --h*)
    2.41 +    cat <<\EOF
    2.42 +Usage: compile [--help] [--version] PROGRAM [ARGS]
    2.43 +
    2.44 +Wrapper for compilers which do not understand `-c -o'.
    2.45 +Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
    2.46 +arguments, and rename the output as expected.
    2.47 +
    2.48 +If you are trying to build a whole package this is not the
    2.49 +right script to run: please start by reading the file `INSTALL'.
    2.50 +
    2.51 +Report bugs to <bug-automake@gnu.org>.
    2.52 +EOF
    2.53 +    exit 0
    2.54 +    ;;
    2.55 +  -v | --v*)
    2.56 +    echo "compile $scriptversion"
    2.57 +    exit 0
    2.58 +    ;;
    2.59 +esac
    2.60 +
    2.61 +ofile=
    2.62 +cfile=
    2.63 +eat=
    2.64 +
    2.65 +for arg
    2.66 +do
    2.67 +  if test -n "$eat"; then
    2.68 +    eat=
    2.69 +  else
    2.70 +    case $1 in
    2.71 +      -o)
    2.72 +	# configure might choose to run compile as `compile cc -o foo foo.c'.
    2.73 +	# So we strip `-o arg' only if arg is an object.
    2.74 +	eat=1
    2.75 +	case $2 in
    2.76 +	  *.o | *.obj)
    2.77 +	    ofile=$2
    2.78 +	    ;;
    2.79 +	  *)
    2.80 +	    set x "$@" -o "$2"
    2.81 +	    shift
    2.82 +	    ;;
    2.83 +	esac
    2.84 +	;;
    2.85 +      *.c)
    2.86 +	cfile=$1
    2.87 +	set x "$@" "$1"
    2.88 +	shift
    2.89 +	;;
    2.90 +      *)
    2.91 +	set x "$@" "$1"
    2.92 +	shift
    2.93 +	;;
    2.94 +    esac
    2.95 +  fi
    2.96 +  shift
    2.97 +done
    2.98 +
    2.99 +if test -z "$ofile" || test -z "$cfile"; then
   2.100 +  # If no `-o' option was seen then we might have been invoked from a
   2.101 +  # pattern rule where we don't need one.  That is ok -- this is a
   2.102 +  # normal compilation that the losing compiler can handle.  If no
   2.103 +  # `.c' file was seen then we are probably linking.  That is also
   2.104 +  # ok.
   2.105 +  exec "$@"
   2.106 +fi
   2.107 +
   2.108 +# Name of file we expect compiler to create.
   2.109 +cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
   2.110 +
   2.111 +# Create the lock directory.
   2.112 +# Note: use `[/.-]' here to ensure that we don't use the same name
   2.113 +# that we are using for the .o file.  Also, base the name on the expected
   2.114 +# object file name, since that is what matters with a parallel build.
   2.115 +lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
   2.116 +while true; do
   2.117 +  if mkdir "$lockdir" >/dev/null 2>&1; then
   2.118 +    break
   2.119 +  fi
   2.120 +  sleep 1
   2.121 +done
   2.122 +# FIXME: race condition here if user kills between mkdir and trap.
   2.123 +trap "rmdir '$lockdir'; exit 1" 1 2 15
   2.124 +
   2.125 +# Run the compile.
   2.126 +"$@"
   2.127 +ret=$?
   2.128 +
   2.129 +if test -f "$cofile"; then
   2.130 +  mv "$cofile" "$ofile"
   2.131 +fi
   2.132 +
   2.133 +rmdir "$lockdir"
   2.134 +exit $ret
   2.135 +
   2.136 +# Local Variables:
   2.137 +# mode: shell-script
   2.138 +# sh-indentation: 2
   2.139 +# eval: (add-hook 'write-file-hooks 'time-stamp)
   2.140 +# time-stamp-start: "scriptversion="
   2.141 +# time-stamp-format: "%:y-%02m-%02d.%02H"
   2.142 +# time-stamp-end: "$"
   2.143 +# End:
     3.1 --- a/configure.in	Tue Sep 09 11:11:56 2008 -0700
     3.2 +++ b/configure.in	Sat Sep 13 20:15:40 2008 -0700
     3.3 @@ -20,6 +20,7 @@
     3.4  AC_PROG_CPP
     3.5  AC_PROG_INSTALL
     3.6  AC_PROG_LN_S
     3.7 +AC_PROG_LIBTOOL
     3.8  AC_PROG_MAKE_SET
     3.9  AC_PROG_RANLIB
    3.10  
    3.11 @@ -80,17 +81,41 @@
    3.12        )
    3.13  
    3.14  
    3.15 +# The following lines adds the --enable-libpst-shared option to configure:
    3.16 +#
    3.17 +# Give the user the choice to enter one of these:
    3.18 +# --enable-libpst-shared
    3.19 +# --enable-libpst-shared=yes
    3.20 +# --enable-libpst-shared=no
    3.21 +#
    3.22 +AC_MSG_CHECKING([whether we are building libpst shared object])
    3.23 +AC_ARG_ENABLE(libpst-shared,
    3.24 +      AC_HELP_STRING([--enable-libpst-shared], [build libpst shared object]),
    3.25 +      [if test "${enable_libpst_shared}" = "no" ; then
    3.26 +          AC_MSG_RESULT([no])
    3.27 +          AM_CONDITIONAL(BUILD_LIBPST_SHARED, test 0 = 1)
    3.28 +      else
    3.29 +          AC_MSG_RESULT([yes])
    3.30 +          AM_CONDITIONAL(BUILD_LIBPST_SHARED, test 1 = 1)
    3.31 +      fi],
    3.32 +      # Default value for configure
    3.33 +      [AC_MSG_RESULT([no])
    3.34 +       AM_CONDITIONAL(BUILD_LIBPST_SHARED, test 0 = 1)]
    3.35 +      )
    3.36 +
    3.37 +
    3.38  AC_OUTPUT(                  \
    3.39      Makefile                \
    3.40      debian/changelog        \
    3.41      debian/Makefile         \
    3.42      libpst.spec             \
    3.43 +    libpst.pc               \
    3.44      html/Makefile           \
    3.45      info/Makefile           \
    3.46      man/Makefile            \
    3.47      src/Makefile            \
    3.48      src/version.h           \
    3.49 -    src/pst2dii.cpp 	    \
    3.50 +    src/pst2dii.cpp         \
    3.51      xml/Makefile            \
    3.52      xml/libpst              \
    3.53      )
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/libpst.pc.in	Sat Sep 13 20:15:40 2008 -0700
     4.3 @@ -0,0 +1,11 @@
     4.4 +prefix=@prefix@
     4.5 +exec_prefix=@exec_prefix@
     4.6 +libdir=@libdir@
     4.7 +includedir=@includedir@
     4.8 +
     4.9 +Name: libpst
    4.10 +Description: A library for reading PST files
    4.11 +Version: @VERSION@
    4.12 +Requires: 
    4.13 +Libs: -L${libdir} -lpst
    4.14 +Cflags: -I${includedir}
     5.1 --- a/src/Makefile.am	Tue Sep 09 11:11:56 2008 -0700
     5.2 +++ b/src/Makefile.am	Sat Sep 13 20:15:40 2008 -0700
     5.3 @@ -9,12 +9,44 @@
     5.4  readpst_SOURCES     = $(hfiles) readpst.c    libpst.c timeconv.c libstrfunc.c debug.c lzfu.c vbuf.c
     5.5  readpstlog_SOURCES  = $(hfiles) readpstlog.c                                  debug.c
     5.6  pst2ldif_SOURCES    = $(hfiles) pst2ldif.cpp libpst.c timeconv.c libstrfunc.c debug.c lzfu.c vbuf.c
     5.7 -pst2dii_SOURCES	    = $(hfiles) pst2dii.cpp  libpst.c timeconv.c libstrfunc.c debug.c lzfu.c vbuf.c
     5.8 -
     5.9 +pst2dii_SOURCES     = $(hfiles) pst2dii.cpp  libpst.c timeconv.c libstrfunc.c debug.c lzfu.c vbuf.c
    5.10  deltasearch_SOURCES = deltasearch.cpp debug.c
    5.11  dumpblocks_SOURCES  = dumpblocks.c    debug.c libpst.c libstrfunc.c timeconv.c vbuf.c
    5.12  getidblock_SOURCES  = getidblock.c    debug.c libpst.c libstrfunc.c timeconv.c vbuf.c
    5.13  
    5.14 +if BUILD_LIBPST_SHARED
    5.15 +    lspst_CFLAGS        = $(AM_CFLAGS)
    5.16 +    readpst_CFLAGS      = $(AM_CFLAGS)
    5.17 +    readpstlog_CFLAGS   = $(AM_CFLAGS)
    5.18 +    pst2ldif_CFLAGS     = $(AM_CFLAGS)
    5.19 +    pst2dii_CFLAGS      = $(AM_CFLAGS)
    5.20 +    deltasearch_CFLAGS  = $(AM_CFLAGS)
    5.21 +    dumpblocks_CFLAGS   = $(AM_CFLAGS)
    5.22 +    getidblock_CFLAGS   = $(AM_CFLAGS)
    5.23 +    lib_LTLIBRARIES = libpst.la
    5.24 +    libpst_la_SOURCES = common.h        \
    5.25 +                        debug.c 		\
    5.26 +                        libpst.c        \
    5.27 +                        libpst.h        \
    5.28 +                        libstrfunc.c    \
    5.29 +                        libstrfunc.h    \
    5.30 +                        lspst.c         \
    5.31 +                        timeconv.c      \
    5.32 +                        timeconv.h      \
    5.33 +                        vbuf.c          \
    5.34 +                        vbuf.h          \
    5.35 +                        version.h
    5.36 +    libpst_la_LDFLAGS = -no-undefined
    5.37 +    libpstincludedir = $(includedir)/libpst
    5.38 +    libpstinclude_HEADERS = common.h        \
    5.39 +                            define.h        \
    5.40 +                            libpst.h        \
    5.41 +                            libstrfunc.h	\
    5.42 +                            timeconv.h      \
    5.43 +                            vbuf.h          \
    5.44 +                            version.h
    5.45 +endif
    5.46 +
    5.47  if NEED_XGETOPT
    5.48      lspst_SOURCES       += XGetopt.c
    5.49      readpst_SOURCES     += XGetopt.c