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

# source: james
DB_TARBALL=foomatic-db-4.0-20230411.tar.xz
DB_MD5SUM=543fdb3c8fe2f11905e3c4dce5e84035
DB_SRC_URL=http://distro.ibiblio.org/fatdog/source/900/$DB_TARBALL

DB_NONFREE_TARBALL=foomatic-db-nonfree-20230411.tar.gz
DB_NONFREE_MD5SUM=7cc445bf7f6a0c6598a89939e405edd1
DB_NONFREE_SRC_URL=http://distro.ibiblio.org/fatdog/source/900/$DB_NONFREE_TARBALL

ENGINE_TARBALL=foomatic-db-engine-4.0.13.tar.gz
ENGINE_MD5SUM=f178947ca0437d85823a247f5725e6eb
ENGINE_SRC_URL=http://distro.ibiblio.org/fatdog/source/900/$ENGINE_TARBALL

FILTER_TARBALL=foomatic-filters-4.0.17.tar.gz
FILTER_MD5SUM=b05f5dcbfe359f198eef3df5b283d896
FILTER_SRC_URL=http://distro.ibiblio.org/fatdog/source/900/$FILTER_TARBALL

# the source URL for all these packages are actually 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 &&
	#SRC_URL=$FILTER_SRC_URL pkg_check $SRC_DIR $FILTER_TARBALL $FILTER_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 &&
	#tar -xf $SRC_DIR/$FILTER_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 and the filter
	
	# 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 &&

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

    # lastly the filter - not sure if this is needed
    # pretend that it doesn't for now
    #CFLAGS="$CFLAGS -fcommon" && # restore old gcc behaviour
    #cd /tmp/foomatic-filter* &&
    #./configure $CONFFLAGS &&
    #make && make install &&
    
	pkg_build_slackdesc
}


