blob: 88fb7604d37243563704f361d9a04ba7476f1fea [file] [log] [blame]
#!/bin/bash
set -e
set -o errtrace
trap 'echo Fatal error: script $0 aborting at line $LINENO, command \"$BASH_COMMAND\" returned $?; exit 1' ERR
PRODUCT_LIST="sirocco"
NUM_JOBS=$(grep -c processor /proc/cpuinfo)
MODULE_NAME="qca-nss-clients"
###################################################
# Setup build toollchain
###################################################
sdk_top_dir=$(readlink -e $(dirname $0)/..)
TOP_DIR=$(readlink -e ${sdk_top_dir}/..)
#export ARCH and build related envs.
source ${TOP_DIR}/sdk/build_scripts/setup_env.sh
kernel_path=$(readlink -e ${sdk_top_dir}/../kernel)
qca_ssdk_include_path=$(readlink -e ${sdk_top_dir}/qca-ssdk/include)
qca_ssdk_common_path=$(readlink -e ${sdk_top_dir}/qca-ssdk/include/common)
qca_ssdk_sal_path=$(readlink -e ${sdk_top_dir}/qca-ssdk/include/sal/os)
qca_ssdk_sal_linux_path=$(readlink -e ${sdk_top_dir}/qca-ssdk/include/sal/os/linux)
qca_nss_drv_export_path=$(readlink -e ${sdk_top_dir}/qca-nss-drv/exports)
qca_nss_drv_dependency=$(readlink -e ${sdk_top_dir}/qca-nss-drv)
soc_type=ipq50xx
export SoC=${soc_type}
dtlsmgr_ver="v2.0"
ipsecmgr_ver="v2.0"
extra_cflags="-I${qca_nss_drv_export_path} -I${qca_ssdk_include_path} -I${qca_ssdk_common_path} -I${qca_ssdk_sal_path} -I${qca_ssdk_sal_linux_path}"
make_modules="wifi-meshmgr"
make_opts=""
for module in ${make_modules}; do
make_opts="${make_opts} ${module}=y"
done
##################################################
# Build Kernel Module
##################################################
function BuildKModule() {
# make kernel module
echo "Build ${MODULE_NAME}"
${CROSS_MAKE} -C ${kernel_path} ${make_opts} M=${sdk_top_dir}/${MODULE_NAME} SoC=${soc_type} EXTRA_CFLAGS=${extra_cflags} DTLSMGR_DIR=${dtlsmgr_ver} IPSECMGR_DIR=${ipsecmgr_ver} KBUILD_EXTRA_SYMBOLS=${qca_nss_drv_dependency}/Module.symvers V=1
}
##################################################
# Build & Install
##################################################
function BuildAndInstall() {
local product=$1
local eureka_src_path=$(readlink -e $2)
if [ -z ${eureka_src_path} ]; then
echo "eureka_src_path doesn't exist"
exit 1
fi
# clean previous build
find . -name "*.o" -delete
find . -name "*.cmd" -delete
find . -name "*.ko" -delete
find . -name "*.mod.*" -delete
find . -name "*.mod" -delete
find . -name Module.symvers -delete
# build module
BuildKModule
# install module
echo "Install ${MODULE_NAME} modules: ${make_modules}"
local module_target_dir="$(GetModulePath ${eureka_src_path} ${product})"
mkdir -p ${module_target_dir}
cp -f wifi_meshmgr/qca-nss-wifi-meshmgr.ko ${module_target_dir}/.
}
function Usage() {
cat << EOF
Usage:
$0 <product> <eureka_src_path>
Valid products: ${PRODUCT_LIST}
EOF
}
function IsProductValid() {
local product
local ret=1
for product in ${PRODUCT_LIST}; do
if [ "${product}" == "$1" ]; then
ret=0
break
fi
done
return ${ret}
}
#########################
####### Main Entry ######
#########################
if (( $# < 2 )); then
Usage
else
if IsProductValid $1; then
BuildAndInstall $1 $2
else
echo "$1 is a invalid product"
Usage
fi
fi