| #!/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-sfe" |
| ################################################### |
| # 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) |
| soc_type=ipq50xx |
| extra_cflags="-DSFE_SUPPORT_IPV6" |
| build_flags="SFE_SUPPORT_IPV6=y" |
| |
| ################################################## |
| # Build Kernel Module |
| ################################################## |
| function BuildKModule() { |
| # make kernel module |
| echo "Build ${MODULE_NAME}" |
| ${CROSS_MAKE} -C ${kernel_path} M=${sdk_top_dir}/${MODULE_NAME} ${build_flags} EXTRA_CFLAGS=${extra_cflags} SoC=${soc_type} 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 |