summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2012-11-14 20:00:52 (EST)
committer P. J. McDermott <pjm@nac.net>2012-11-14 20:00:52 (EST)
commit41b4397694b7892aa4176753e8365ce192c3438d (patch)
tree1b96952f18b18615a3c808b7f4097cc0bf86a320
parente80c8fcf62eea81a237c86f292e26f9e58b068b9 (diff)
Implement a "kbuild" build system plugin.
-rw-r--r--lib/buildsystem/Makefile.in2
-rw-r--r--lib/buildsystem/kbuild.sh116
2 files changed, 117 insertions, 1 deletions
diff --git a/lib/buildsystem/Makefile.in b/lib/buildsystem/Makefile.in
index 3138aff..a7b3c59 100644
--- a/lib/buildsystem/Makefile.in
+++ b/lib/buildsystem/Makefile.in
@@ -33,7 +33,7 @@ sed_script = s&@@PACKAGE_NAME@@&$(package_name)&;\
.SUFFIXES:
.SUFFIXES: .sh .sm
-SRCS = autoconf.sh make.sh
+SRCS = autoconf.sh make.sh kbuild.sh
OBJS = $(SRCS:.sh=.sm)
distdir = ../../$(package_name)-$(package_version)/lib/buildsystem
diff --git a/lib/buildsystem/kbuild.sh b/lib/buildsystem/kbuild.sh
new file mode 100644
index 0000000..5a1c5d2
--- /dev/null
+++ b/lib/buildsystem/kbuild.sh
@@ -0,0 +1,116 @@
+# opkhelper
+# lib/buildsystem/kbuild
+# 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 <http://www.gnu.org/licenses/>.
+
+[ -n "${_OH_BUILDSYSTEM_KBUILD_SM}" ] && return 0
+_OH_BUILDSYSTEM_KBUILD_SM='true'
+
+_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()
+{
+ _oh_kbuild_update_target 'install' \
+ "${@}" "DESTDIR=${_OH_BUILDSYSTEM_DESTDIR}"
+}
+
+_oh_kbuild_update_target()
+{
+ _oh_local _ohbskut_target _ohbskut_arch _ohbskut_rc
+
+ _ohbskut_target="${1}"
+ shift
+
+ if ! _ohbskut_arch="$(oh_buildsystem_arch "${OPK_HOST_ARCH}" 'kbuild')"
+ then
+ _oh_return 1
+ return ${?}
+ fi
+
+ mkdir -p "${_OH_BUILDSYSTEM_BUILD_DIR}"
+ cd "${_OH_BUILDSYSTEM_BUILD_DIR}"
+
+ if [ -n "${_OH_BUILDSYSTEM_BUILD_TARGET}" ]; then
+ make ARCH="${_ohbskut_arch}" CROSS_COMPILE="${OPK_TOOL_PREFIX}" \
+ "${@}" "${_OH_BUILDSYSTEM_BUILD_TARGET}"
+ _ohbskut_rc=${?}
+ elif [ -n "${_ohbskut_target}" ]; then
+ make ARCH="${_ohbskut_arch}" CROSS_COMPILE="${OPK_TOOL_PREFIX}" \
+ "${@}" "${_ohbskut_target}"
+ _ohbskut_rc=${?}
+ else
+ make ARCH="${_ohbskut_arch}" CROSS_COMPILE="${OPK_TOOL_PREFIX}" \
+ "${@}"
+ _ohbskut_rc=${?}
+ fi
+
+ cd "${_OH_BUILDSYSTEM_WORK_AREA}"
+
+ _oh_return ${_ohbskut_rc}
+ return ${?}
+}
+
+_oh_kbuild_test_arch()
+{
+ _oh_local _ohbskta_arch
+
+ _ohbskta_arch="${1}"
+
+ make -n ARCH="${_ohbskta_arch}" help >/dev/null 2>&1
+
+ _ob_return ${?}
+ return ${?}
+}