blob: 9afc226439630f34655f8ce3b2bcface59cdd548 [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-drv"
###################################################
# 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_dp_path=$(readlink -e ${sdk_top_dir}/qca-nss-dp/exports)
qca_nss_dp_dependency=$(readlink -e ${sdk_top_dir}/qca-nss-dp)
soc_type=ipq50xx
extra_cflags="-I${qca_ssdk_include_path} -I${qca_ssdk_common_path} -I${qca_ssdk_sal_path} -I${qca_ssdk_sal_linux_path} -I${qca_nss_dp_path}"
##################################################
# Build Kernel Module
##################################################
function BuildKModule() {
# make kernel module
echo "Build ${MODULE_NAME}"
${CROSS_MAKE} -C ${kernel_path} M=${sdk_top_dir}/${MODULE_NAME} SoC=${soc_type} EXTRA_CFLAGS="${extra_cflags}" KBUILD_EXTRA_SYMBOLS=${qca_nss_dp_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}.ko"
local module_target_dir="$(GetModulePath ${eureka_src_path} ${product})"
mkdir -p ${module_target_dir}
cp -f ${MODULE_NAME}.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