#!/bin/sh
#
# Copyright 2005 John M. Lang <john.m.lang@gmail.com>
# Available under the terms of the GNU GPL.
#
# Much thanks to Dagmar and the other geniuses at #Dropline for their help in
# porting this to the new build system.
#
# Thanks to Diffie for cleaning up the script and making all the USB Hotplug
# stuff work.


NAME="libgphoto2"
VERSION="2.1.6"
REVISION="2"

PKG_SOURCEURL='http://easynews.dl.sourceforge.net/sourceforge/gphoto/$NAME-$VERSION.tar.gz'
#PKG_PATCH[0]="usbcam_console.patch"

. $DLG_ROOT/config
. $DLG_ROOT/SCRIPTS/dropline-functions.sh

configfile /etc/hotplug/usb/usbcam

cflags
prepare

# From old 'pre' script, I'm not sure what it does ;)  It didn't seem to do 
# anything but return errors.
#( cd $PKG_STAGEROOT/usr/lib/gphoto2/#VERSION &&
#( cd $PKG_SRCROOT &&
#  libtool --finish || exit 1
#)

# Patch /etc/hotplug/usb/usbcam to contain correct paths
# See: http://www.dropline.net/forums/viewtopic.php?t=3751
#applypatch 0 0

analyzesource
configure
make
makeinstall install-strip
tidydocumentation

# Copy the usbcam script to /etc/hotplug/usb
createdir $PKG_STAGEROOT$PKG_SYSCONFDIR/hotplug/usb
spewdo "cp $PKG_SRCROOT/packaging/linux-hotplug/usbcam.console $PKG_STAGEROOT$PKG_SYSCONFDIR/hotplug/usb/usbcam"
# Create gphoto2 usb user mapping file (this will only work if libgphoto2 is 
# already installed, so put in doinst.sh instead).
#spewdo "$PKG_STAGEROOT$PKG_PREFIX/lib/$NAME/print-usb-usermap > $PKG_STAGEROOT$PKG_SYSCONFDIR/hotplug/usb/usb.usermap"

# From old 'fix' script: move hotplug script to the right place (replaced by 
# above by Diffie).
#install -d -m755 $PKG_STAGEROOT/etc/hotplug/usb
#install -m755 $PKG_STAGEROOT/usr/doc/$NAME-$VERSION/linux-hotplug/usbcam.console $PKG_STAGEROOT/etc/hotplug/usb/usbcam

analyzebinaries
finalizepackage
packagize
#cleanup
