# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: maz-1 <loveayawaka@gmail.com>

pkgbase=ndiswrapper
pkgname=(ndiswrapper-dkms ndiswrapper)
pkgver=1.61
_extramodules=extramodules-ARCH
pkgrel=8
pkgdesc="Module for NDIS (Windows Network Drivers) drivers supplied by vendors"
arch=('x86_64')
url="http://sourceforge.net/projects/ndiswrapper/"
license=('GPL')
source=("$pkgbase-$pkgver.tar.gz::https://github.com/pgiri/ndiswrapper/archive/v$pkgver.tar.gz"
        'dkms.conf' 'linux-4.11.patch' 'linux-4.13.patch' 'linux-4.15.patch' 'linux-5.0.patch' 'linux-5.3.patch')
sha512sums=('85f550f2952137529e0e9855f4d94b7bbc64cbf8a84a31c1b75a4be09d97478a997e64fa6e1ff4e0d29a97a79fc3d4dab1ebdaa9edb3d627a215f47aa4d52823'
            '9fce255fc02ddf6e939dc61a5e29c0ea5fa1a31ecc3c390081bc53aa1cd48eddf5db621f0a1cb909634529d4ccc2995eea8827be8eb5807b34dc17e15045ecf4'
            '5350308406457658fb31c378d6f3dd2a34c7331aebe5bdc80744bf955f1144e88181441704ccc7532f55d6fbe8d410440fb8838c2955d688dde4b55f74fc6ba5'
            'de026a271cbfbefee99bc00a13c50be87294e5e2c5407d23cff6ce2d2a0c853542ce4f7e3e150741c7e8e32466fb1ab7cab266957da5bcca8376fb0f38e94482'
            '4296e7488d8c0cd971d70a81c01f24ab8e01c8611934024e2438181f0fb7c39a2c8201d48ab04659af2a8897ae93fb0810332e89c2a09a8140e216aed56db34b'
            '4918dcebd62ae577401469719f1a8866edd3dc97667aa3de287af1530aa68f50dc2508c883ecd2c9d1fe20f226ecd342b04b08f7a2cace0e531e5f49bbc12f2c'
            'c404f35280534b172235c5c578657d7a30ac2253c7c2abedd65a183d09390e95e7c3030cb409accb4d198ff0411482f8029f8664418c99d5672f92e9c733801d')

prepare() {
  cd ndiswrapper-$pkgver
  patch --no-backup-if-mismatch -p1 -i "$srcdir"/linux-4.11.patch
  patch --no-backup-if-mismatch -p1 -i "$srcdir"/linux-4.13.patch
  patch --no-backup-if-mismatch -p1 -i "$srcdir"/linux-4.15.patch
  patch --no-backup-if-mismatch -p1 -i "$srcdir"/linux-5.0.patch
  patch --no-backup-if-mismatch -p1 -i "$srcdir"/linux-5.3.patch
}

build() {
  cd ndiswrapper-$pkgver/ndiswrapper
  make -C utils
}

package_ndiswrapper-dkms() {
  depends=('dkms')
  provides=('NDISWRAPPER-MODULE')
  conflicts=('NDISWRAPPER-MODULE')

  cd ndiswrapper-$pkgver/ndiswrapper
  mkdir -p "$pkgdir"/usr/src
  cp -RL ./driver "$pkgdir"/usr/src/ndiswrapper-$pkgver
  cp "$srcdir"/dkms.conf "$pkgdir"/usr/src/ndiswrapper-$pkgver
}

package_ndiswrapper() {
  depends=('NDISWRAPPER-MODULE')

  cd ndiswrapper-$pkgver/ndiswrapper
  make -C utils sbindir=/usr/bin usrsbindir=/usr/bin DESTDIR="$pkgdir" install
}
