From 8968ed27b27605502d677afe6b07bc547a0340c9 Mon Sep 17 00:00:00 2001 From: Laurence Withers Date: Wed, 31 Jan 2007 14:03:00 +0000 Subject: [PATCH] Add a C module --- scripts/build.module.c/TopSource.c | 13 +++++++ scripts/build.module.c/build.default | 1 + scripts/build.module.c/build.install | 1 + scripts/build.module.c/build.install-module | 12 +++++++ scripts/build.module.c/build.module | 39 +++++++++++++++++++++ scripts/build.module.c/build.monolithic | 17 +++++++++ scripts/build.module.c/instantiate | 15 ++++++++ skel/scripts/.gitignore | 1 + 8 files changed, 99 insertions(+) create mode 100644 scripts/build.module.c/TopSource.c create mode 100644 scripts/build.module.c/build.default create mode 100644 scripts/build.module.c/build.install create mode 100644 scripts/build.module.c/build.install-module create mode 100644 scripts/build.module.c/build.module create mode 100644 scripts/build.module.c/build.monolithic create mode 100644 scripts/build.module.c/instantiate diff --git a/scripts/build.module.c/TopSource.c b/scripts/build.module.c/TopSource.c new file mode 100644 index 0000000..b298f9c --- /dev/null +++ b/scripts/build.module.c/TopSource.c @@ -0,0 +1,13 @@ +/* @P@/src/@NAME@/TopSource.c + * + * (c)2006, @AUTHOR@, <@EMAIL@>. + * Released under the GNU GPLv2. See file COPYING or + * http://www.gnu.org/copyleft/gpl.html for details. +*/ + +/* Below are includes used throughout the module */ + +/* options for text editors +kate: @KATE_MODELINE@ +vim: @VIM_MODELINE@ +*/ diff --git a/scripts/build.module.c/build.default b/scripts/build.module.c/build.default new file mode 100644 index 0000000..a92d188 --- /dev/null +++ b/scripts/build.module.c/build.default @@ -0,0 +1 @@ +source src/@NAME@/build.module diff --git a/scripts/build.module.c/build.install b/scripts/build.module.c/build.install new file mode 100644 index 0000000..27faa5c --- /dev/null +++ b/scripts/build.module.c/build.install @@ -0,0 +1 @@ +source src/@NAME@/build.install-module diff --git a/scripts/build.module.c/build.install-module b/scripts/build.module.c/build.install-module new file mode 100644 index 0000000..c6254d6 --- /dev/null +++ b/scripts/build.module.c/build.install-module @@ -0,0 +1,12 @@ +build_target @NAME@ + +# make paths (this is for Gentoo in particular) +build_dir_tree "${MODULEDIR}" || return 1 + +# install module +echo "Installing module into '${MODULEDIR}'" +install_file ${@CNAME@} ${MODULEDIR} 0755 || return 1 +print_success "Done" + +# kate: @KATE_MODELINE@ +# vim: @VIM_MODELINE@ diff --git a/scripts/build.module.c/build.module b/scripts/build.module.c/build.module new file mode 100644 index 0000000..f80b382 --- /dev/null +++ b/scripts/build.module.c/build.module @@ -0,0 +1,39 @@ +# These are external variables, and shouldn't clash with anything else +# @CNAME@ +# @CNAME@_BUILT + +if [ -z ${@CNAME@_BUILT} ] +then + @CNAME@="obj/@NAME@.so" + SO_EXTRA="" # @TODO@ + + echo "Building module ${@CNAME@}..." + + do_cmd source src/@NAME@/build.monolithic || return 1 + + MODIFIED=0 + for test in ${MONOLITHIC_TESTS} ${SRC} + do + if [ ${test} -nt ${@CNAME@} ] + then + MODIFIED=1 + break + fi + done + + if [ ${MODIFIED} -ne 0 ] + then + echo " Compiling" + + do_cmd ${CC} ${CFLAGS} -Iobj -shared -fpic -o "${@CNAME@}" \ + ${SRC} ${SO_EXTRA} || return 1 + + print_success "Module built" + else + print_success "Module up to date" + fi + + @CNAME@_BUILT=1 +fi +# kate: @KATE_MODELINE@ +# vim: @VIM_MODELINE@ diff --git a/scripts/build.module.c/build.monolithic b/scripts/build.module.c/build.monolithic new file mode 100644 index 0000000..789dc9e --- /dev/null +++ b/scripts/build.module.c/build.monolithic @@ -0,0 +1,17 @@ +# These are external variables, and shouldn't clash with anything else +# @CNAME@_MONOLITHIC + +SRC="obj/@NAME@.c" +HDR="obj/@HEADER_NAME@" + +MONOLITHIC_TESTS="src/@NAME@/build.module src/@NAME@/build.monolithic" + +if [ -z "${@CNAME@_MONOLITHIC}" ] +then + MONOLITHIC_SOURCE="$(echo src/@NAME@/TopSource.c)" + make_monolithic ${SRC} C || return 1 + + @CNAME@_MONOLITHIC=1 +fi +# kate: @KATE_MODELINE@ +# vim: @VIM_MODELINE@ diff --git a/scripts/build.module.c/instantiate b/scripts/build.module.c/instantiate new file mode 100644 index 0000000..1c99bcd --- /dev/null +++ b/scripts/build.module.c/instantiate @@ -0,0 +1,15 @@ +if [ $# -ne 0 ] +then + print_failure "Not expecting arguments." + exit 1 +fi + +do_parameter_subst +add_config_option "CC" "${COPT_CC_DEFAULT}" +add_config_option "CFLAGS" "${COPT_CFLAGS_DEFAULT}" +add_config_option "BINDIR" "${COPT_BINDIR_DEFAULT}" +add_config_option "MODULEDIR" "${COPT_LIBDIR_DEFAULT}/@TODO@/" +true + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/skel/scripts/.gitignore b/skel/scripts/.gitignore index 8e5e559..3419bff 100644 --- a/skel/scripts/.gitignore +++ b/skel/scripts/.gitignore @@ -7,6 +7,7 @@ build.firmware.gpasm build.firmware.sdcc build.lib.c build.lib.c++ +build.module.c build.tests.c build.tests.c++ module-create.sh