# Contributor: Nathan Angelacos <nangel@alpinelinux.org>
# Maintainer: Nathan Angelacos <nangel@alpinelinux.org>
setvar pkgname = 'gpsd'
setvar pkgver = '3.16'
setvar pkgrel = '1'
setvar pkgdesc = ""A GPS daemon""
setvar arch = 'all'
setvar url = ""http://catb.org/gpsd/""
setvar license = ""BSD""
setvar depends = """"
setvar makedepends = ""scons python2-dev libcap-dev ncurses-dev""
setvar install = ''
setvar subpackages = ""$pkgname-dev""
setvar source = ""http://download-mirror.savannah.gnu.org/releases/gpsd/$pkgname-$pkgver.tar.gz
	timepps.h
	gpsd-use-local-timepps-header.patch
	ttydefaults.patch
	gpsd.initd
	gpsd.confd""

setvar _builddir = ""$srcdir"/$pkgname-$pkgver"


proc prepare {
	local i

    # We copy timepps.h to the local build directory instead of
    # creating a pps-tools-dev package for ppstime.h
    # (See https://github.com/ago/pps-tools)
    mkdir -p "$_builddir"/sys
    cp timepps.h "$_builddir"/sys/


	cd $_builddir
	for i in $source {
		case (i) {
		*.patch { msg $i; patch -p1 -i "$srcdir"/$i || return 1}
		}
	}

}

proc build {
	cd $_builddir
        setvar CPPFLAGS = ""-I. -DHAVE_SYS_TIMEPPS_H""
	scons -j1 \
		prefix=/usr \
		|| return 1
}

proc package {
    cd $_builddir

    mkdir -p "$pkgdir"/usr/lib
    cp -a "$_builddir"/libgps*.so* "$pkgdir"/usr/lib/

    mkdir -p "$pkgdir"/usr/sbin
    for a in gpsdecode gpsd gpsctl gpsdctl gpspipe {
     install -m755 -D "$_builddir/"$a "$pkgdir"/usr/sbin/
    }

    install -m755 -D "$srcdir"/gpsd.initd "$pkgdir"/etc/init.d/gpsd
    install -m644 -D "$srcdir"/gpsd.confd "$pkgdir"/etc/conf.d/gpsd
}

setvar md5sums = ""68691b5de4c94f82ec4062b042b5eb63  gpsd-3.16.tar.gz
28f6835098a216f4a620f9218d15b5b8  timepps.h
940780c04830eb08ae29276da1de8925  gpsd-use-local-timepps-header.patch
5189a0776250acda819286e1336ac8c6  ttydefaults.patch
8bb3f9c4c7913bd12006e3af42782246  gpsd.initd
453f3d1d75d2b048f0987cfb9cf250fd  gpsd.confd""
setvar sha256sums = ""03579af13a4d3fe0c5b79fa44b5f75c9f3cac6749357f1d99ce5d38c09bc2029  gpsd-3.16.tar.gz
ab4f459ee9d1037d7fa962a66ea652b08935539a4f443dc216e82b5717d8bb22  timepps.h
4857faaf2d0f69b5b91c32f1813ffd01c435677e73aab2ff8125c373cdc9c048  gpsd-use-local-timepps-header.patch
d42d323425eae828d5685b058a81ff1bb6e82ab695ea3e80c2fff18f0c8cc302  ttydefaults.patch
723d2d644421a9974579fd409f19370f7db6a9df42be72df40f60246a6365963  gpsd.initd
218a7f044f902070922c45f3b543c9ff6af25be5305648899565c1fbdc0d5da9  gpsd.confd""
setvar sha512sums = ""a8ad85a1f17d3ea550a4b99c262e47a834ed8fd16b00e10574f7cf5f34b6c506142aa77a870a61f8827c0d0c88fe7f65f6e916089d64e84c5667d4a2ca89c543  gpsd-3.16.tar.gz
eb11fc19243d1789016d88eb7645bfe67c46304547781489bf36eb1dd4c252d523681ff835a6488fa0ef62b6b9e2f781c672279f4439f5d5640a3f214a113048  timepps.h
1802e72c9ac71a162fcd37d99dc9c8596b6085180dba9b37f24f2b17344d16cd5f618228f43bfdc2f7509f9a2f1072c2b11c238486febcdb94d9d0d095eaebdd  gpsd-use-local-timepps-header.patch
e2af8f52fc2d7e663882b6d12c5f4d709aa267b16eb9aeca2a70d8ecc681ae72359f3efcd1636cde576bc8579e008f242574bc0adfab7252d3e763f039e86135  ttydefaults.patch
a0e7bf206ad51c31195f86f79ef92adca425d7f988534c0f70a2dd3053613f6fc46820d62d0330aaef7ca100b5f2ab781ce9643f25b4c99c844ae66e7eec5cbc  gpsd.initd
55d4a51f82d445d3ac93b2855132ef4380908ed045feba6298ed1d0b607cd9054b5325c024dc52b370983ebd5d9b377537aee7d7128c97aa22e3075f4134d404  gpsd.confd""