### this file is sourced not run
PKGVER=4.0.2018.09
PKGBUILD=1
PKGARCH=i686

# source: james
DB_TARBALL=foomatic-db-4.0-20180930.tar.xz
DB_MD5SUM=2902d01c3c8be46bdc372319af5262f1
DB_SRC_URL=http://distro.ibiblio.org/fatdog/source/800/$DB_TARBALL

DB_NONFREE_TARBALL=foomatic-db-nonfree-20180930.tar.gz
DB_NONFREE_MD5SUM=ebb7c40c1bf3c9b9afe57c2a74f36005
DB_NONFREE_SRC_URL=http://distro.ibiblio.org/fatdog/source/800/$DB_NONFREE_TARBALL

ENGINE_TARBALL=foomatic-db-engine-4.0-20180930.tar.gz
ENGINE_MD5SUM=0487574f3dad875fb845fb241482f689
ENGINE_SRC_URL=http://distro.ibiblio.org/fatdog/source/800/$ENGINE_TARBALL

# the source URL for all these packages are actuall here:
# http://www.openprinting.org/download/foomatic/
# but they get updated everyday, so we need to persistent copy

SLACKREQ='cups32 ghostscript32 foomatic'
SLACKDESC="foomatic32: foomatic32 $PKGVER (Foomatic printer drivers)
foomatic32: 
foomatic32: Foomatic is a database-driven system for integrating free software 
foomatic32: printer drivers with common spoolers under Unix. It supports CUPS, 
foomatic32: LPRng, LPD, GNUlpr, Solaris LP, PPR, PDQ, CPS, and direct printing 
foomatic32: with every free software printer driver known to us and every printer 
foomatic32: known to work with these drivers.
foomatic32: 
foomatic32: https://wiki.linuxfoundation.org/openprinting/database/foomatic
foomatic32: 
foomatic32: This contains 32-bit libraries.
"

### default pkg_download
### prepare
pkg_prepare() {
	#SRC_URL=$DB_SRC_URL pkg_check $SRC_DIR $DB_TARBALL $DB_MD5SUM &&
	#SRC_URL=$DB_NONFREE_SRC_URL pkg_check $SRC_DIR $DB_NONFREE_TARBALL $DB_NONFREE_MD5SUM &&
	SRC_URL=$ENGINE_SRC_URL pkg_check $SRC_DIR $ENGINE_TARBALL $ENGINE_MD5SUM &&
	#tar -xf $SRC_DIR/$DB_TARBALL -C tmp &&
	#tar -xf $SRC_DIR/$DB_NONFREE_TARBALL -C tmp &&
	tar -xf $SRC_DIR/$ENGINE_TARBALL -C tmp &&
	true
}

### package - only collect the libraries
pkg_package() {
	rm -rf etc bin sbin usr/bin usr/sbin usr/include usr/share
}

### build
pkg_build() {
	# in 32-bit we only need to do the engine
	
	# first, the database
    #cd /tmp/foomatic-db-2* &&
    #./configure --prefix=/usr &&
    #make install &&

    # then the non-free database
    #cd /tmp/foomatic-db-non* &&
    #./configure --prefix=/usr &&
    #make install &&

    # lastly the engine
    cd /tmp/foomatic-db-en* &&
    ./configure $CONFFLAGS &&
    make && make install &&
    
	pkg_build_slackdesc
}


