#!/bin/bash
# Copyright (c) 2000-2016 Synology Inc. All rights reserved.

case "$BUILD_TARGET" in
	EVANSPORT|MARVELL_ARMADAXP|MARVELL_ARMADA370|MARVELL_ARMADA375|MINDSPEED_COMCERTO2K|PPC_QORIQ|PPC_853X|TI_816X|MARVELL_88F6281|HISILICON_HI3535)
		STRIP=${STRIP}
		;;
	*) # platforms not kernel 3.x and 2.6.32 should build backports
		SkipThisProject
		return
		;;
esac

COMPAT_WIRELESS_VERSION=`cat /source/compat-wireless/VERSION`

cd ${COMPAT_WIRELESS_VERSION}

. ${ScriptsDir}/include/exports

make remoteinstall \
	KLIB_BUILD="/source/${SYNO_KERNEL_VERSION}" \
	FIRMWARE_DIR="${TmpFirmwareDir}" \
	STRIP=${STRIP} -f Makefile.syno

UDEV_DEVICE_TABLE_DIR="${TmpInstDir}/lib/udev/devicetable"
USB_WIFI_DEVICE_TABLE="usb.wifi.table"
USB_BLUETOOTH_DEVICE_TABLE="usb.bluetooth.table"

if [ ! -d "${UDEV_DEVICE_TABLE_DIR}" ]; then
	mkdir -p ${UDEV_DEVICE_TABLE_DIR};
fi
if [ -f "${USB_WIFI_DEVICE_TABLE}" ]; then
	install -c ${USB_WIFI_DEVICE_TABLE} ${UDEV_DEVICE_TABLE_DIR};
fi
if [ -f "${USB_BLUETOOTH_DEVICE_TABLE}" ]; then
	install -c ${USB_BLUETOOTH_DEVICE_TABLE} ${UDEV_DEVICE_TABLE_DIR};
fi

cd ../
