Add a C module

This commit is contained in:
Laurence Withers 2007-01-31 14:03:00 +00:00
parent f5e3be481b
commit 8968ed27b2
8 changed files with 99 additions and 0 deletions

View File

@ -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@
*/

View File

@ -0,0 +1 @@
source src/@NAME@/build.module

View File

@ -0,0 +1 @@
source src/@NAME@/build.install-module

View File

@ -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@

View File

@ -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@

View File

@ -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@

View File

@ -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

View File

@ -7,6 +7,7 @@ build.firmware.gpasm
build.firmware.sdcc build.firmware.sdcc
build.lib.c build.lib.c
build.lib.c++ build.lib.c++
build.module.c
build.tests.c build.tests.c
build.tests.c++ build.tests.c++
module-create.sh module-create.sh