summaryrefslogtreecommitdiff
path: root/libre/ath9k-htc-firmware/PKGBUILD
blob: b47b95e0e70372aecc62ef6b84b67bf68a22a5f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Maintainer: André Silva <emulatorman@parabola.nu>
# Maintainer: Márcio Silva <coadde@parabola.nu>
# Contributor: Taro <taro-k@movasense.com>

pkgname=ath9k-htc-firmware
pkgver=1.3.2
pkgrel=4
pkgdesc='Free firmware files for the Qualcomm Atheros AR7010 and AR9271 USB 802.11n NICs'
arch=('any')
url=('http://wireless.kernel.org/en/users/Drivers/ath9k_htc')
license=('BSD')
makedepends=('cmake' 'xtensa-unknown-elf-binutils' 'xtensa-unknown-elf-gcc')
source=("https://github.com/qca/open-ath9k-htc-firmware/archive/$pkgver.tar.gz"
        'LICENSE')
md5sums=('73c66751151dd47535cb4142477da480'
         '5163b2711bc481c77045850610b7dd31')

prepare() {

  mkdir -p $srcdir/bin
  ln -s /usr/bin/xtensa-unknown-elf-as $srcdir/bin/as
  export PATH=$srcdir/bin:$PATH
  cd $srcdir/open-ath9k-htc-firmware-$pkgver/target_firmware
  mkdir -p build/{k2,magpie}

}

build() {

  cd $srcdir/open-ath9k-htc-firmware-$pkgver

  export CTARGET="xtensa-unknown-elf"
  export CFLAGS="-mtext-section-literals -O2 -pipe --param=ssp-buffer-size=4"
  export CXXFLAGS="${CFLAGS}"

  cat > target_firmware/build/toolchain.cmake <<EOF
INCLUDE(CMakeForceCompiler)

SET(CMAKE_SYSTEM_PROCESSOR xtensa)
SET(COMPILER_PREFIX "xtensa-unknown-elf")
SET(CMAKE_FIND_ROOT_PATH /usr/xtensa-unknown-elf)
SET(CMAKE_OBJCOPY /usr/bin/xtensa-unknown-elf-objcopy)

CMAKE_FORCE_C_COMPILER(/usr/bin/xtensa-unknown-elf-gcc GNU)
EOF

  cd $srcdir/open-ath9k-htc-firmware-$pkgver/target_firmware/build/k2

  cmake -DCMAKE_TOOLCHAIN_FILE=$srcdir/open-ath9k-htc-firmware-$pkgver/target_firmware/build/toolchain.cmake "$@" -DTARGET_K2=ON ../..
  cd -

  cd $srcdir/open-ath9k-htc-firmware-$pkgver/target_firmware/build/magpie

  cmake -DCMAKE_TOOLCHAIN_FILE=$srcdir/open-ath9k-htc-firmware-$pkgver/target_firmware/build/toolchain.cmake "$@" -DTARGET_MAGPIE=ON ../..
  cd -

  cd $srcdir/open-ath9k-htc-firmware-$pkgver/target_firmware

  make -C build/k2
  make -C build/magpie

}

package() {

  # create firmware folder to put the free firmware files there
  install -d -m755 $pkgdir/usr/lib/firmware

  cd $srcdir/open-ath9k-htc-firmware-$pkgver/target_firmware

  # move firmware files to firmware folder
  cp build/{k2,magpie}/htc_*.fw $pkgdir/usr/lib/firmware

  # create license folder to put the license file there
  install -d -m755 $pkgdir/usr/share/licenses/$pkgname

  # put LICENSE to license folder
  install -m644 $srcdir/LICENSE $pkgdir/usr/share/licenses/$pkgname
  
}