# Description: Library for file management
# URL: https://wiki.lxde.org/en/PCManFM
# Maintainer: unmaintained
# Depends on: gtk3 menu-cache vala
# Optional: dbus-glib gtk gvfs libexif

name=libfm
version=1.3.2
release=3
source=(https://downloads.sourceforge.net/pcmanfm/$name-$version.tar.xz)

build() {
  cp -r $SRC/$name-$version $SRC/gtk3

  cd $SRC/gtk3
  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --with-gnu-ld \
    --disable-nls \
    --disable-gtk-doc-html \
    --with-gtk=3

  make
  make DESTDIR=$PKG install

  cd $SRC

  if prt-get isinst gtk; then
    cp -r $SRC/$name-$version $SRC/gtk2

    cd $SRC/gtk2
    ./configure \
      --prefix=/usr \
      --sysconfdir=/etc \
      --with-gnu-ld \
      --disable-nls \
      --disable-gtk-doc-html

    # https://bugzilla.gnome.org/show_bug.cgi?id=656231
    sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool

    make
    make DESTDIR=$PKG install
    cd $SRC
  fi

  rm -r $PKG/usr/share/locale

  rm -r $PKG/usr/include/libfm
  mv $PKG/usr/include/libfm-1.0/ $PKG/usr/include/libfm

  # In libfm-extra
  rm -r $PKG/usr/include/libfm/fm-{extra,version,xml-file}.h \
    $PKG/usr/lib/libfm-extra.* \
    $PKG/usr/lib/pkgconfig/libfm-extra.pc
}
