description="Core library of gphoto2, designed to allow access to digital camera by external programs."
url="http://www.gphoto.org/proj/libgphoto2/"

packager="Spiky <spiky@nutyx.org>"
contributors="Greg,Tnut,Spiky"

makedepends=(libjpeg-turbo libexif libusb-compat)

name=libgphoto2
version=2.5.30
_version="${version//./_}"

source=(https://github.com/gphoto/$name/archive/libgphoto2-${_version}-release.tar.gz)

build() {
cd $name-$name-${_version}-release

autoreconf -fvi

./configure --prefix=/usr --disable-rpath
sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0 /g' -e 's/ \
     if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then/ \
     func_append compile_command " -Wl,-O1,--as-needed"\n \
     func_append finalize_command " -Wl,-O1,--as-needed"\n\0/' libtool
make
make DESTDIR=$PKG install

# Remove unused udev helper
  rm -r "$PKG/usr/lib/udev"


cd $PKG/usr/lib/libgphoto2

export LD_LIBRARY_PATH=$PKG/usr/lib${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH
export CAMLIBS=$PWD/$version

./print-camera-list hwdb \
| install -Dm644 /dev/stdin $PKG/etc/udev/hwdb.d/20-gphoto.hwdb
./print-camera-list udev-rules version 201 \
| install -Dm644 /dev/stdin $PKG/etc/udev/rules.d/40-gphoto.rules

# Obsolets libs

rm $PKG/usr/lib/libgphoto2.la
# rm $PKG/usr/lib/libgphoto2/2.5.16/*.la
rm $PKG/usr/lib/libgphoto2_port.la
rm $PKG/usr/lib/libgphoto2_port/0.12.1/*.la

}
