#!/bin/bash
## src2pkg script for:  db
## Auto-generated by src2pkg-2.1
## src2pkg - Copyright 2005-2009 Gilbert Ashley <[email protected]>

SOURCE_NAME='db-4.4.20.tar.bz2'
ALT_NAME='db44'   # Use ALT_NAME to override guessed value
VERSION='4.4.20'   # Use ALT_VERSION to override guessed value
# ARCH=''
# BUILD='1'
# PRE_FIX='usr'
# Any extra options go here:
EXTRA_CONFIGS="--enable-shared \
       --enable-rpc --enable-cxx \
       --enable-compat185"
DOCLIST='README LICENSE'

# Optional function replaces configure_source, compile_source, fake_install
# To use, uncomment and write/paste CODE between the {} brackets.
build() {
mkdir build-dir
cd build-dir
CFLAGS="$CFLAGS" \
CXXFLAGS="$CFLAGS" \
./dist/configure \
 --prefix=/usr \
 --libdir=/usr/lib${LIBDIRSUFFIX} \
 --enable-shared \
 --enable-rpc \
 --enable-cxx \
 --enable-compat185

       make -j3
       make install DESTDIR=$PKG_DIR
}

# Get the functions and configs
/usr/libexec/src2pkg/FUNCTIONS ;

# Execute the named packaging steps:
pre_process
find_source
make_dirs
unpack_source
fix_source_perms
configure_source #
compile_source   # If used, the 'build' function replaces these 3
fake_install     #

# Adapted from the db44.SlackBuild
# See the end of this file for full Copyright and License info

# Move include files:
( cd $PKG_DIR/usr/include
 mkdir db44
 mv *.h db44
 for FILE in db44/* ; do
   ln -sf $FILE .
 done
 # Better add this symlink, too, just to be safe...
 ln -sf db44 db4
)

# Put libdb-4.4.so into /lib${LIBDIRSUFFIX} since it might be needed
# before /usr is mounted (eg, nsswitch.conf can be set up to
# use databases instead of flat files)
mkdir -p $PKG_DIR/lib${LIBDIRSUFFIX}
mv $PKG_DIR/usr/lib${LIBDIRSUFFIX}/libdb-4.4.so $PKG_DIR/lib${LIBDIRSUFFIX}/libdb-4.4.so
( cd $PKG_DIR/usr/lib${LIBDIRSUFFIX}
 ln -sf /lib${LIBDIRSUFFIX}/libdb-4.4.so .
)

# Some things might look for these libraries by other names.
( cd $PKG_DIR/usr/lib${LIBDIRSUFFIX}
 ln -sf libdb-4.4.a libdb-4.a
 ln -sf libdb-4.4.a libdb4.a
 ln -sf libdb-4.4.a libdb.a
 ln -sf libdb_cxx-4.4.a libdb_cxx-4.a
 ln -sf libdb_cxx-4.4.a libdb_cxx.a
 ln -sf libdb-4.4.so libdb4.so
 ln -sf libdb-4.4.so libdb.so
)

# docs get installed to usr/docs, so fix that
( cd $PKG_DIR
       mkdir -p $docdir
       mv usr/docs $docdir/$NAME-$VERSION

)

fix_pkg_perms
strip_bins
create_docs
compress_man_pages
make_description
make_doinst
make_package
post_process

# Original copyright:
# Copyright 2008, 2009  Patrick J. Volkerding, Sebeka, Minnesota, USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.