# opkhelper # lib/buildsystem/kbuild.sh # Build system plugin for kbuild. # # Copyright (C) 2012 Patrick "P. J." McDermott # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . [ "x${_OH_BUILDSYSTEM_KBUILD_SM+set}" = 'xset' ] && return 0 _OH_BUILDSYSTEM_KBUILD_SM=1 _oh_kbuild_can_configure() { [ -d "${_OH_BUILDSYSTEM_SOURCE_DIR}/scripts/kconfig" -a \ -r "${_OH_BUILDSYSTEM_SOURCE_DIR}/Makefile" ] } _oh_kbuild_configure() { return 0 } _oh_kbuild_can_build() { _oh_kbuild_can_configure } _oh_kbuild_build() { _oh_kbuild_update_target '' "${@}" } _oh_kbuild_can_clean() { _oh_kbuild_can_configure } _oh_kbuild_clean() { _oh_kbuild_update_target 'clean' "${@}" } _oh_kbuild_can_test() { return 1 } _oh_kbuild_can_install() { _oh_kbuild_can_configure } _oh_kbuild_install() { # BusyBox uses CONFIG_PREFIX. Linux is, of course, different. _oh_kbuild_update_target 'install' \ "CONFIG_PREFIX=${_OH_BUILDSYSTEM_DESTDIR}" "${@}" } _oh_kbuild_update_target() { local target="${1}" local arch= local rc= shift 1 if ! arch="$(oh_buildsystem_arch "${OPK_HOST_ARCH}" 'kbuild')" then return 1 fi mkdir -p "${_OH_BUILDSYSTEM_BUILD_DIR}" cd "${_OH_BUILDSYSTEM_BUILD_DIR}" if [ "x${_OH_BUILDSYSTEM_BUILD_TARGET}" != 'x' ]; then make ARCH="${arch}" CROSS_COMPILE="${OPK_TOOL_PREFIX}" \ "${@}" "${_OH_BUILDSYSTEM_BUILD_TARGET}" rc=${?} elif [ "x${target}" != 'x' ]; then make ARCH="${arch}" CROSS_COMPILE="${OPK_TOOL_PREFIX}" \ "${@}" "${target}" rc=${?} else make ARCH="${arch}" CROSS_COMPILE="${OPK_TOOL_PREFIX}" \ "${@}" rc=${?} fi cd "${_OH_BUILDSYSTEM_WORK_AREA}" return ${rc} } _oh_kbuild_testarch() { local arch="${1}" local rc= mkdir -p "${_OH_BUILDSYSTEM_BUILD_DIR}" cd "${_OH_BUILDSYSTEM_BUILD_DIR}" make -n ARCH="${arch}" help >/dev/null 2>&1 rc=${?} cd "${_OH_BUILDSYSTEM_WORK_AREA}" return ${rc} }