diff --git a/scripts/build.c++.app/TopHeader.h b/scripts/build.c++.app/TopHeader.h new file mode 100644 index 0000000..281f7ab --- /dev/null +++ b/scripts/build.c++.app/TopHeader.h @@ -0,0 +1,13 @@ +/* @P@/src/@NAME@/TopHeader.h + * + * (c)2006, @AUTHOR@, <@EMAIL@>. + * Released under the GNU GPLv2. See file COPYING or + * http://www.gnu.org/copyleft/gpl.html for details. +*/ + +// standard includes, or includes needed for type declarations + +/* options for text editors +kate: replace-trailing-space-save true; space-indent true; tab-width 4; +vim: expandtab:ts=4:sw=4 +*/ diff --git a/scripts/build.c++.app/TopSource.cpp b/scripts/build.c++.app/TopSource.cpp new file mode 100644 index 0000000..9d055a4 --- /dev/null +++ b/scripts/build.c++.app/TopSource.cpp @@ -0,0 +1,13 @@ +/* @P@/src/@NAME@/TopSource.cpp + * + * (c)2006, @AUTHOR@, <@EMAIL@>. + * Released under the GNU GPLv2. See file COPYING or + * http://www.gnu.org/copyleft/gpl.html for details. +*/ + +// Below are all the includes used throughout the application. + +/* options for text editors +kate: replace-trailing-space-save true; space-indent true; tab-width 4; +vim: expandtab:ts=4:sw=4 +*/ diff --git a/scripts/build.c++.app/build.app b/scripts/build.c++.app/build.app new file mode 100644 index 0000000..7e70252 --- /dev/null +++ b/scripts/build.c++.app/build.app @@ -0,0 +1,41 @@ +# These are external variables, and shouldn't clash with anything else +# @NAME@ +# @NAME@_BUILT +# + +if [ -z ${@NAME@_BUILT} ] +then + @NAME@="obj/@NAME@" + EXTRAS="@TODO@" # cflags, libs + + echo "Building application ${@NAME@}..." + + do_cmd source src/@NAME@/build.monolithic || return 1 + + MODIFIED=0 + for test in ${MONOLITHIC_TESTS} ${SRC} + do + if [ ${test} -nt ${@NAME@} ] + then + MODIFIED=1 + break + fi + done + + if [ ${MODIFIED} -ne 0 ] + then + echo " Compiling..." + + do_cmd ${CXX} ${CFLAGS} -o "${@NAME@}" ${SRC} ${EXTRAS} || return 1 + + print_success "Application built" + else + print_success "Application up to date" + fi + + @NAME@_BUILT=1 + +fi + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c++.app/build.default b/scripts/build.c++.app/build.default new file mode 100644 index 0000000..5f2b4b0 --- /dev/null +++ b/scripts/build.c++.app/build.default @@ -0,0 +1 @@ +source src/@NAME@/build.app diff --git a/scripts/build.c++.app/build.install b/scripts/build.c++.app/build.install new file mode 100644 index 0000000..ef2021c --- /dev/null +++ b/scripts/build.c++.app/build.install @@ -0,0 +1 @@ +source src/@NAME@/build.install-app diff --git a/scripts/build.c++.app/build.install-app b/scripts/build.c++.app/build.install-app new file mode 100644 index 0000000..af436a7 --- /dev/null +++ b/scripts/build.c++.app/build.install-app @@ -0,0 +1,12 @@ +build_target @NAME@ + +# make paths (this is for Gentoo in particular) +build_dir_tree "${BINDIR}" || return 1 + +# install binary +echo "Installing binaries into '${BINDIR}'" +install_file "${@NAME@}" "${BINDIR}" 0755 || return 1 +print_success "Done" + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c++.app/build.monolithic b/scripts/build.c++.app/build.monolithic new file mode 100644 index 0000000..c311844 --- /dev/null +++ b/scripts/build.c++.app/build.monolithic @@ -0,0 +1,18 @@ +# These are external variables, and shouldn't clash with anything else +# @NAME@_MONOLITHIC +# + +SRC="obj/@NAME@.cpp" +MONOLITHIC_TESTS="src/@NAME@/build.app src/@NAME@/build.monolithic" + +if [ -z "${@NAME@_MONOLITHIC}" ] +then + MONOLITHIC_SOURCE="$(echo src/@NAME@/TopHeader.h) $(echo src/@NAME@/TopSource.cpp)" + make_monolithic ${SRC} C || return 1 + + @NAME@_MONOLITHIC=1 + MONOLITHIC_DOC="${MONOLITHIC_DOC} ${SRC}" +fi + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c++.app/instantiate b/scripts/build.c++.app/instantiate new file mode 100644 index 0000000..f8f4e51 --- /dev/null +++ b/scripts/build.c++.app/instantiate @@ -0,0 +1,25 @@ +if [ $# -ne 0 ] +then + print_failure "Too many arguments. None required for this module." + exit 1 +fi + +if [ -e src/${NAME} ] +then + print_failure "src/${NAME} already exists." + exit 1 +fi + +echo "Instantiating module src/${NAME}..." + +do_cmd mkdir src/${NAME} || exit 1 +do_cmd cp ${TEMPLATE}/* src/${NAME} || exit 1 + +do_cmd cd src/${NAME} || exit 1 +do_cmd rm instantiate || exit 1 +do_cmd find . -type f -exec sed -e "s,@NAME@,${NAME},g" -i {} \; || exit 1 +do_cmd grep "@TODO@" * || exit 1 +print_success "Module instantiated." + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c++.lib/BottomHeader.h b/scripts/build.c++.lib/BottomHeader.h new file mode 100644 index 0000000..28e508a --- /dev/null +++ b/scripts/build.c++.lib/BottomHeader.h @@ -0,0 +1,13 @@ +/* @P@/src/@NAME@/BottomHeader.h + * + * (c)2006, @AUTHOR@, <@EMAIL@>. + * Released under the GNU GPLv2. See file COPYING or + * http://www.gnu.org/copyleft/gpl.html for details. +*/ + +#endif + +/* options for text editors +kate: replace-trailing-space-save true; space-indent true; tab-width 4; +vim: expandtab:ts=4:sw=4 +*/ diff --git a/scripts/build.c++.lib/TopHeader.h b/scripts/build.c++.lib/TopHeader.h new file mode 100644 index 0000000..5da4ccc --- /dev/null +++ b/scripts/build.c++.lib/TopHeader.h @@ -0,0 +1,16 @@ +/* @P@/src/@NAME@/TopHeader.h + * + * (c)2006, @AUTHOR@, <@EMAIL@>. + * Released under the GNU GPLv2. See file COPYING or + * http://www.gnu.org/copyleft/gpl.html for details. +*/ + +#ifndef HEADER_@CNAME@ +#define HEADER_@CNAME@ + +// standard includes, or includes needed for type declarations + +/* options for text editors +kate: replace-trailing-space-save true; space-indent true; tab-width 4; +vim: expandtab:ts=4:sw=4 +*/ diff --git a/scripts/build.c++.lib/TopSource.cpp b/scripts/build.c++.lib/TopSource.cpp new file mode 100644 index 0000000..234da73 --- /dev/null +++ b/scripts/build.c++.lib/TopSource.cpp @@ -0,0 +1,15 @@ +/* @P@/src/@NAME@/TopSource.cpp + * + * (c)2006, @AUTHOR@, <@EMAIL@>. + * Released under the GNU GPLv2. See file COPYING or + * http://www.gnu.org/copyleft/gpl.html for details. +*/ + +#include "@HEADER_NAME@" + +// Below are all the includes used throughout the library. + +/* options for text editors +kate: replace-trailing-space-save true; space-indent true; tab-width 4; +vim: expandtab:ts=4:sw=4 +*/ diff --git a/scripts/build.c++.lib/build.default b/scripts/build.c++.lib/build.default new file mode 100644 index 0000000..62274a9 --- /dev/null +++ b/scripts/build.c++.lib/build.default @@ -0,0 +1 @@ +source src/@NAME@/build.lib diff --git a/scripts/build.c++.lib/build.install b/scripts/build.c++.lib/build.install new file mode 100644 index 0000000..567d8f3 --- /dev/null +++ b/scripts/build.c++.lib/build.install @@ -0,0 +1 @@ +source src/@NAME@/build.install-lib diff --git a/scripts/build.c++.lib/build.install-lib b/scripts/build.c++.lib/build.install-lib new file mode 100644 index 0000000..d5b4ea7 --- /dev/null +++ b/scripts/build.c++.lib/build.install-lib @@ -0,0 +1,36 @@ +build_target @NAME@ + +# make paths (this is for Gentoo in particular) +build_dir_tree "${LIBDIR}" || return 1 +build_dir_tree "${PKGCONFDIR}" || return 1 +build_dir_tree "${INCLUDEDIR}" || return 1 + +# install library +echo "Installing libraries into '${LIBDIR}'" +install_file ${@CNAME@} ${LIBDIR} 0755 || return 1 +BASE="${@CNAME@_BASE}.so" +MAJOR="${BASE}.${SOMAJOR}" +MINOR="${MAJOR}.${SOMINOR}" +MICRO="${MINOR}.${SOMICRO}" +install_symlink "${MINOR}" "${MICRO}" "${LIBDIR}" +install_symlink "${MAJOR}" "${MINOR}" "${LIBDIR}" +install_symlink "${BASE}" "${MAJOR}" "${LIBDIR}" + +# install header +echo "Installing header file '${@CNAME@_HEADER}' into ${INCLUDEDIR}" +install_header ${@CNAME@_HEADER} ${INCLUDEDIR} 0644 || return 1 + +# install pkgconfig file +echo "Installing package config file into ${PKGCONFDIR}" +PKGCONFFILE=${PKGCONFDIR}/@CNAME@.pc +do_cmd rm -f ${PKGCONFFILE} +do_cmd_redir ${PKGCONFFILE} sed \ + -e "s,@VERSION@,${VERSION}," \ + -e "s,@LIBDIR@,${FINALLIBDIR}," \ + -e "s,@INCLUDEDIR@,${FINALINCLUDEDIR}," \ + src/@NAME@/pkgconf.in +do_cmd chmod 0644 ${PKGCONFFILE} +print_success "Done" + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c++.lib/build.lib b/scripts/build.c++.lib/build.lib new file mode 100644 index 0000000..dc01197 --- /dev/null +++ b/scripts/build.c++.lib/build.lib @@ -0,0 +1,51 @@ +# These are external variables, and shouldn't clash with anything else +# @CNAME@ +# @CNAME@_BUILT +# @CNAME@_HEADER +# @CNAME@_BASE + +if [ -z ${@CNAME@_BUILT} ] +then + @CNAME@_BASE=@NAME@ + source src/@NAME@/soversion + + @CNAME@="obj/${@CNAME@_BASE}.so.${SOMAJOR}.${SOMINOR}.${SOMICRO}" + SO_EXTRA="-lstdc++ -lc" # @TODO@ libs, cflags + + echo "Building library ${@CNAME@}..." + + do_cmd source src/@NAME@/build.monolithic || return 1 + + MODIFIED=0 + for test in ${MONOLITHIC_TESTS} ${HDR} ${SRC} + do + if [ ${test} -nt ${@CNAME@} ] + then + MODIFIED=1 + break + fi + done + + if [ ${MODIFIED} -ne 0 ] + then + echo " Compiling" + + SONAME="${@CNAME@_BASE}.so.${SOMAJOR}.${SOMINOR}" + do_cmd ${CXX} ${CFLAGS} -shared -fpic -o "${@CNAME@}" \ + -Wl,-soname,${SONAME} \ + ${SRC} ${SO_EXTRA} || return 1 + + # make tests work + do_cmd ln -sf $(basename ${@CNAME@}) obj/${SONAME} || return 1 + + print_success "Library built" + else + print_success "Library up to date" + fi + + @CNAME@_BUILT=1 + @CNAME@_HEADER=${HDR} + +fi +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c++.lib/build.monolithic b/scripts/build.c++.lib/build.monolithic new file mode 100644 index 0000000..9337e77 --- /dev/null +++ b/scripts/build.c++.lib/build.monolithic @@ -0,0 +1,21 @@ +# These are external variables, and shouldn't clash with anything else +# @CNAME@_MONOLITHIC + +SRC="obj/@NAME@.cpp" +HDR="obj/@HEADER_NAME@" + +MONOLITHIC_TESTS="src/@NAME@/build.lib src/@NAME@/build.monolithic" + +if [ -z "${@CNAME@_MONOLITHIC}" ] +then + MONOLITHIC_SOURCE="$(echo src/@NAME@/{TopHeader,BottomHeader}.h)" + make_monolithic ${HDR} C || return 1 + + MONOLITHIC_SOURCE="$(echo src/@NAME@/TopSource.cpp)" + make_monolithic ${SRC} C || return 1 + + @CNAME@_MONOLITHIC=1 + MONOLITHIC_DOC="${MONOLITHIC_DOC} ${HDR}" +fi +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c++.lib/instantiate b/scripts/build.c++.lib/instantiate new file mode 100644 index 0000000..9ef0cca --- /dev/null +++ b/scripts/build.c++.lib/instantiate @@ -0,0 +1,44 @@ +if [ $# -ne 2 ] +then + print_failure "Not enough arguments after module; need CNAME HEADER_NAME." + echo "CNAME is the C identifier version of the module name." + echo "HEADER_NAME is the name of the header file." + exit 1 +fi + +CNAME=$1 +shift +HEADER_NAME=$1 +shift + +if [ -e src/${NAME} ] +then + print_failure "src/${NAME} already exists." + exit 1 +fi + +if [ "$(echo ${NAME} | cut -b1-3)" != "lib" ] +then + echo "Warning: your module name does not begin with 'lib'. You will" + echo "have to fix up your pkgconfig file manually, etc." + NAMEMINUSL="@TODO@" +else + NAMEMINUSL="-l$(echo ${NAME} | sed -e 's,^lib,,')" +fi + +echo "Instantiating module src/${NAME}..." + +do_cmd mkdir src/${NAME} || exit 1 +do_cmd cp ${TEMPLATE}/* src/${NAME} || exit 1 + +do_cmd cd src/${NAME} || exit 1 +do_cmd rm instantiate || exit 1 +do_cmd find . -type f -exec sed -e "s,@NAME@,${NAME},g" -i {} \; || exit 1 +do_cmd find . -type f -exec sed -e "s,@CNAME@,${CNAME},g" -i {} \; || exit 1 +do_cmd find . -type f -exec sed -e "s,@NAMEMINUSL@,${NAMEMINUSL},g" -i {} \; || exit 1 +do_cmd find . -type f -exec sed -e "s,@HEADER_NAME@,${HEADER_NAME},g" -i {} \; || exit 1 +do_cmd grep "@TODO@" * || exit 1 +print_success "Module instantiated." + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c++.lib/pkgconf.in b/scripts/build.c++.lib/pkgconf.in new file mode 100644 index 0000000..2e9c46d --- /dev/null +++ b/scripts/build.c++.lib/pkgconf.in @@ -0,0 +1,21 @@ +# @P@/src/lib/@NAME@/pkgconf.in +# +# Metadata file for pkg-config +# ( http://www.freedesktop.org/software/pkgconfig/ ) +# +# (c)2006, @AUTHOR@, <@EMAIL@>. +# Released under the GNU GPLv2. See file COPYING or +# http://www.gnu.org/copyleft/gpl.html for details. +# + +# Name, description +Name: @TODO@ +Description: @TODO@ +Version: @VERSION@ + +# Requirements +Requires: + +# Compilation information +Libs: -L@LIBDIR@ @NAMEMINUSL@ +Cflags: -I@INCLUDEDIR@ diff --git a/scripts/build.c++.lib/soversion b/scripts/build.c++.lib/soversion new file mode 100644 index 0000000..faa4d94 --- /dev/null +++ b/scripts/build.c++.lib/soversion @@ -0,0 +1,17 @@ +# @P@/src/@NAME@/soversion +# +# (c)2006, @AUTHOR@, <@EMAIL@>. +# Released under the GNU GPLv2. See file COPYING or +# http://www.gnu.org/copyleft/gpl.html for details. +# + + + +# SOMAJOR and SOMINOR are included in the library's soname. They need to +# be bumped on a binary-incompatible release. They are both single +# integers. +SOMAJOR=0 +SOMINOR=0 + +# SOMICRO is bumped every time there is a binary-compatible release. +SOMICRO=0 diff --git a/scripts/build.c++.tests/build.default b/scripts/build.c++.tests/build.default new file mode 100644 index 0000000..29b4364 --- /dev/null +++ b/scripts/build.c++.tests/build.default @@ -0,0 +1,3 @@ +source src/@NAME@/build.tests +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c++.tests/build.tests b/scripts/build.c++.tests/build.tests new file mode 100644 index 0000000..e2ef355 --- /dev/null +++ b/scripts/build.c++.tests/build.tests @@ -0,0 +1,43 @@ +# These are external variables, and shouldn't clash with anything else +# @NAME@_BUILT +# + +#@TODO@ build_target libs || return 1 + +if [ -z ${@NAME@_BUILT} ] +then + LIBS="" # @TODO@ internal libs + EXTRAS="" # @TODO@ libs, cflags + + echo "Building test programs..." + do_cmd mkdir -p obj/tests || return 1 + + for SRC in src/@NAME@/*.cpp + do + TEST="obj/tests/$(basename ${SRC} | sed -e 's,.cpp$,,')" + MODIFIED=0 + for file in ${LIBS} ${SRC} src/@NAME@/build.tests + do + if [ ${file} -nt ${TEST} ] + then + MODIFIED=1 + break + fi + done + + if [ ${MODIFIED} -ne 0 ] + then + do_cmd ${CXX} -Iobj ${CFLAGS} -o ${TEST} ${SRC} ${LIBS} ${EXTRAS} || return 1 + print_success "Built ${TEST}" + else + print_success "${TEST} is up to date" + fi + done + + print_success "All tests built" + + @NAME@_BUILT=1 +fi + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c++.tests/instantiate b/scripts/build.c++.tests/instantiate new file mode 100644 index 0000000..49e9e24 --- /dev/null +++ b/scripts/build.c++.tests/instantiate @@ -0,0 +1,25 @@ +if [ $# -ne 0 ] +then + print_failure "Unexpected extra parameters." + exit 1 +fi + +if [ -e src/${NAME} ] +then + print_failure "src/${NAME} already exists." + exit 1 +fi + +echo "Instantiating module src/${NAME}..." + +do_cmd mkdir src/${NAME} || exit 1 +do_cmd cp ${TEMPLATE}/* src/${NAME} || exit 1 + +do_cmd cd src/${NAME} || exit 1 +do_cmd rm instantiate || exit 1 +do_cmd find . -type f -exec sed -e "s,@NAME@,${NAME},g" -i {} \; || exit 1 +do_cmd grep "@TODO@" * || exit 1 +print_success "Module instantiated." + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c++.tests/template b/scripts/build.c++.tests/template new file mode 100644 index 0000000..2e8f5ee --- /dev/null +++ b/scripts/build.c++.tests/template @@ -0,0 +1,44 @@ +/* @P@/src/@NAME@/???.cpp + * + * (c)2006, @AUTHOR@, <@EMAIL@>. + * Released under the GNU GPLv2. See file COPYING or + * http://www.gnu.org/copyleft/gpl.html for details. +*/ + +@TODO@ includes + +#include + + + +int main(int argc, char* argv[]) +{ + if(argc == 2 && !strcmp(argv[1], "--print-summary")) { + std::cout << "One line summary.\n"; + return 0; + } + + if(argc == 1) { + // empty argument list + } + + int ret = 0; + try { + // TODO + } + catch(std::exception& e) { + std::cerr << e.what() << std::endl; + ret = 1; + } + catch(...) { + std::cerr << "Unknown exception caught." << std::endl; + ret = 1; + } + + return ret; +} + +/* options for text editors +kate: replace-trailing-space-save true; space-indent true; tab-width 4; +vim: expandtab:ts=4:sw=4 +*/ diff --git a/scripts/build.c.app/TopHeader.h b/scripts/build.c.app/TopHeader.h new file mode 100644 index 0000000..4f989d5 --- /dev/null +++ b/scripts/build.c.app/TopHeader.h @@ -0,0 +1,13 @@ +/* @P@/src/capp/TopHeader.h + * + * (c)2006, @AUTHOR@, <@EMAIL@>. + * Released under the GNU GPLv2. See file COPYING or + * http://www.gnu.org/copyleft/gpl.html for details. +*/ + +// standard includes, or includes needed for type declarations + +/* options for text editors +kate: replace-trailing-space-save true; space-indent true; tab-width 4; +vim: expandtab:ts=4:sw=4 +*/ diff --git a/scripts/build.c.app/TopSource.c b/scripts/build.c.app/TopSource.c new file mode 100644 index 0000000..3e61cae --- /dev/null +++ b/scripts/build.c.app/TopSource.c @@ -0,0 +1,13 @@ +/* @P@/src/capp/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 all the includes used throughout the application. + +/* options for text editors +kate: replace-trailing-space-save true; space-indent true; tab-width 4; +vim: expandtab:ts=4:sw=4 +*/ diff --git a/scripts/build.c.app/build.app b/scripts/build.c.app/build.app new file mode 100644 index 0000000..f64db08 --- /dev/null +++ b/scripts/build.c.app/build.app @@ -0,0 +1,41 @@ +# These are external variables, and shouldn't clash with anything else +# @NAME@ +# @NAME@_BUILT +# + +if [ -z ${@NAME@_BUILT} ] +then + @NAME@="obj/@NAME@" + EXTRAS="@TODO@" # cflags, libs + + echo "Building application ${@NAME@}..." + + do_cmd source src/@NAME@/build.monolithic || return 1 + + MODIFIED=0 + for test in ${MONOLITHIC_TESTS} ${SRC} + do + if [ ${test} -nt ${@NAME@} ] + then + MODIFIED=1 + break + fi + done + + if [ ${MODIFIED} -ne 0 ] + then + echo " Compiling..." + + do_cmd ${CC} ${CFLAGS} -o "${@NAME@}" ${SRC} ${EXTRAS} || return 1 + + print_success "Application built" + else + print_success "Application up to date" + fi + + @NAME@_BUILT=1 + +fi + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c.app/build.default b/scripts/build.c.app/build.default new file mode 100644 index 0000000..5f2b4b0 --- /dev/null +++ b/scripts/build.c.app/build.default @@ -0,0 +1 @@ +source src/@NAME@/build.app diff --git a/scripts/build.c.app/build.install b/scripts/build.c.app/build.install new file mode 100644 index 0000000..ef2021c --- /dev/null +++ b/scripts/build.c.app/build.install @@ -0,0 +1 @@ +source src/@NAME@/build.install-app diff --git a/scripts/build.c.app/build.install-app b/scripts/build.c.app/build.install-app new file mode 100644 index 0000000..af436a7 --- /dev/null +++ b/scripts/build.c.app/build.install-app @@ -0,0 +1,12 @@ +build_target @NAME@ + +# make paths (this is for Gentoo in particular) +build_dir_tree "${BINDIR}" || return 1 + +# install binary +echo "Installing binaries into '${BINDIR}'" +install_file "${@NAME@}" "${BINDIR}" 0755 || return 1 +print_success "Done" + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c.app/build.monolithic b/scripts/build.c.app/build.monolithic new file mode 100644 index 0000000..cb1160c --- /dev/null +++ b/scripts/build.c.app/build.monolithic @@ -0,0 +1,18 @@ +# These are external variables, and shouldn't clash with anything else +# @NAME@_MONOLITHIC +# + +SRC="obj/@NAME@.c" +MONOLITHIC_TESTS="src/@NAME@/build.app src/@NAME@/build.monolithic" + +if [ -z "${@NAME@_MONOLITHIC}" ] +then + MONOLITHIC_SOURCE="$(echo src/@NAME@/TopHeader.h) $(echo src/@NAME@/TopSource.c)" + make_monolithic ${SRC} C || return 1 + + @NAME@_MONOLITHIC=1 + MONOLITHIC_DOC="${MONOLITHIC_DOC} ${SRC}" +fi + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c.app/instantiate b/scripts/build.c.app/instantiate new file mode 100644 index 0000000..f8f4e51 --- /dev/null +++ b/scripts/build.c.app/instantiate @@ -0,0 +1,25 @@ +if [ $# -ne 0 ] +then + print_failure "Too many arguments. None required for this module." + exit 1 +fi + +if [ -e src/${NAME} ] +then + print_failure "src/${NAME} already exists." + exit 1 +fi + +echo "Instantiating module src/${NAME}..." + +do_cmd mkdir src/${NAME} || exit 1 +do_cmd cp ${TEMPLATE}/* src/${NAME} || exit 1 + +do_cmd cd src/${NAME} || exit 1 +do_cmd rm instantiate || exit 1 +do_cmd find . -type f -exec sed -e "s,@NAME@,${NAME},g" -i {} \; || exit 1 +do_cmd grep "@TODO@" * || exit 1 +print_success "Module instantiated." + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c.lib/BottomHeader.h b/scripts/build.c.lib/BottomHeader.h new file mode 100644 index 0000000..f5a7be0 --- /dev/null +++ b/scripts/build.c.lib/BottomHeader.h @@ -0,0 +1,12 @@ +/* @P@/src/clib/BottomHeader.h + * + * (c)2006, @AUTHOR@, <@EMAIL@>. + * Released under the GNU GPLv2. See file COPYING or + * http://www.gnu.org/copyleft/gpl.html for details. +*/ + +#endif + +/* options for text editors +kate: replace-trailing-space-save true; space-indent true; tab-width 4; +*/ diff --git a/scripts/build.c.lib/TopHeader.h b/scripts/build.c.lib/TopHeader.h new file mode 100644 index 0000000..1d12a6f --- /dev/null +++ b/scripts/build.c.lib/TopHeader.h @@ -0,0 +1,15 @@ +/* @P@/src/@NAME@/TopHeader.h + * + * (c)2006, @AUTHOR@, <@EMAIL@>. + * Released under the GNU GPLv2. See file COPYING or + * http://www.gnu.org/copyleft/gpl.html for details. +*/ + +#ifndef HEADER_@CNAME@ +#define HEADER_@CNAME@ + +// standard includes, or includes needed for type declarations + +/* options for text editors +kate: replace-trailing-space-save true; space-indent true; tab-width 4; +*/ diff --git a/scripts/build.c.lib/TopSource.c b/scripts/build.c.lib/TopSource.c new file mode 100644 index 0000000..8bed521 --- /dev/null +++ b/scripts/build.c.lib/TopSource.c @@ -0,0 +1,14 @@ +/* @P@/src/@NAME@@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. +*/ + +#include "@HEADER_NAME@" + +// Below are all the includes used throughout the library. + +/* options for text editors +kate: replace-trailing-space-save true; space-indent true; tab-width 4; +*/ diff --git a/scripts/build.c.lib/build.default b/scripts/build.c.lib/build.default new file mode 100644 index 0000000..62274a9 --- /dev/null +++ b/scripts/build.c.lib/build.default @@ -0,0 +1 @@ +source src/@NAME@/build.lib diff --git a/scripts/build.c.lib/build.install b/scripts/build.c.lib/build.install new file mode 100644 index 0000000..567d8f3 --- /dev/null +++ b/scripts/build.c.lib/build.install @@ -0,0 +1 @@ +source src/@NAME@/build.install-lib diff --git a/scripts/build.c.lib/build.install-lib b/scripts/build.c.lib/build.install-lib new file mode 100644 index 0000000..d5b4ea7 --- /dev/null +++ b/scripts/build.c.lib/build.install-lib @@ -0,0 +1,36 @@ +build_target @NAME@ + +# make paths (this is for Gentoo in particular) +build_dir_tree "${LIBDIR}" || return 1 +build_dir_tree "${PKGCONFDIR}" || return 1 +build_dir_tree "${INCLUDEDIR}" || return 1 + +# install library +echo "Installing libraries into '${LIBDIR}'" +install_file ${@CNAME@} ${LIBDIR} 0755 || return 1 +BASE="${@CNAME@_BASE}.so" +MAJOR="${BASE}.${SOMAJOR}" +MINOR="${MAJOR}.${SOMINOR}" +MICRO="${MINOR}.${SOMICRO}" +install_symlink "${MINOR}" "${MICRO}" "${LIBDIR}" +install_symlink "${MAJOR}" "${MINOR}" "${LIBDIR}" +install_symlink "${BASE}" "${MAJOR}" "${LIBDIR}" + +# install header +echo "Installing header file '${@CNAME@_HEADER}' into ${INCLUDEDIR}" +install_header ${@CNAME@_HEADER} ${INCLUDEDIR} 0644 || return 1 + +# install pkgconfig file +echo "Installing package config file into ${PKGCONFDIR}" +PKGCONFFILE=${PKGCONFDIR}/@CNAME@.pc +do_cmd rm -f ${PKGCONFFILE} +do_cmd_redir ${PKGCONFFILE} sed \ + -e "s,@VERSION@,${VERSION}," \ + -e "s,@LIBDIR@,${FINALLIBDIR}," \ + -e "s,@INCLUDEDIR@,${FINALINCLUDEDIR}," \ + src/@NAME@/pkgconf.in +do_cmd chmod 0644 ${PKGCONFFILE} +print_success "Done" + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c.lib/build.lib b/scripts/build.c.lib/build.lib new file mode 100644 index 0000000..11324e0 --- /dev/null +++ b/scripts/build.c.lib/build.lib @@ -0,0 +1,51 @@ +# These are external variables, and shouldn't clash with anything else +# @CNAME@ +# @CNAME@_BUILT +# @CNAME@_HEADER +# @CNAME@_BASE + +if [ -z ${@CNAME@_BUILT} ] +then + @CNAME@_BASE=@NAME@ + source src/@NAME@/soversion + + @CNAME@="obj/${@CNAME@_BASE}.so.${SOMAJOR}.${SOMINOR}.${SOMICRO}" + SO_EXTRA="-lc" # @TODO@ libs, cflags + + echo "Building library ${@CNAME@}..." + + do_cmd source src/@NAME@/build.monolithic || return 1 + + MODIFIED=0 + for test in ${MONOLITHIC_TESTS} ${HDR} ${SRC} + do + if [ ${test} -nt ${@CNAME@} ] + then + MODIFIED=1 + break + fi + done + + if [ ${MODIFIED} -ne 0 ] + then + echo " Compiling" + + SONAME="${@CNAME@_BASE}.so.${SOMAJOR}.${SOMINOR}" + do_cmd ${CC} ${CFLAGS} -shared -fpic -o "${@CNAME@}" \ + -Wl,-soname,${SONAME} \ + ${SRC} ${SO_EXTRA} || return 1 + + # make tests work + do_cmd ln -sf $(basename ${@CNAME@}) obj/${SONAME} || return 1 + + print_success "Library built" + else + print_success "Library up to date" + fi + + @CNAME@_BUILT=1 + @CNAME@_HEADER=${HDR} + +fi +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c.lib/build.monolithic b/scripts/build.c.lib/build.monolithic new file mode 100644 index 0000000..680b456 --- /dev/null +++ b/scripts/build.c.lib/build.monolithic @@ -0,0 +1,21 @@ +# 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.lib src/@NAME@/build.monolithic" + +if [ -z "${@CNAME@_MONOLITHIC}" ] +then + MONOLITHIC_SOURCE="$(echo src/@NAME@/{TopHeader,BottomHeader}.h)" + make_monolithic ${HDR} C || return 1 + + MONOLITHIC_SOURCE="$(echo src/@NAME@/TopSource.c)" + make_monolithic ${SRC} C || return 1 + + @CNAME@_MONOLITHIC=1 + MONOLITHIC_DOC="${MONOLITHIC_DOC} ${HDR}" +fi +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c.lib/instantiate b/scripts/build.c.lib/instantiate new file mode 100644 index 0000000..9ef0cca --- /dev/null +++ b/scripts/build.c.lib/instantiate @@ -0,0 +1,44 @@ +if [ $# -ne 2 ] +then + print_failure "Not enough arguments after module; need CNAME HEADER_NAME." + echo "CNAME is the C identifier version of the module name." + echo "HEADER_NAME is the name of the header file." + exit 1 +fi + +CNAME=$1 +shift +HEADER_NAME=$1 +shift + +if [ -e src/${NAME} ] +then + print_failure "src/${NAME} already exists." + exit 1 +fi + +if [ "$(echo ${NAME} | cut -b1-3)" != "lib" ] +then + echo "Warning: your module name does not begin with 'lib'. You will" + echo "have to fix up your pkgconfig file manually, etc." + NAMEMINUSL="@TODO@" +else + NAMEMINUSL="-l$(echo ${NAME} | sed -e 's,^lib,,')" +fi + +echo "Instantiating module src/${NAME}..." + +do_cmd mkdir src/${NAME} || exit 1 +do_cmd cp ${TEMPLATE}/* src/${NAME} || exit 1 + +do_cmd cd src/${NAME} || exit 1 +do_cmd rm instantiate || exit 1 +do_cmd find . -type f -exec sed -e "s,@NAME@,${NAME},g" -i {} \; || exit 1 +do_cmd find . -type f -exec sed -e "s,@CNAME@,${CNAME},g" -i {} \; || exit 1 +do_cmd find . -type f -exec sed -e "s,@NAMEMINUSL@,${NAMEMINUSL},g" -i {} \; || exit 1 +do_cmd find . -type f -exec sed -e "s,@HEADER_NAME@,${HEADER_NAME},g" -i {} \; || exit 1 +do_cmd grep "@TODO@" * || exit 1 +print_success "Module instantiated." + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c.lib/pkgconf.in b/scripts/build.c.lib/pkgconf.in new file mode 100644 index 0000000..b450b9f --- /dev/null +++ b/scripts/build.c.lib/pkgconf.in @@ -0,0 +1,21 @@ +# @P@/src/lib/clib/pkgconf.in +# +# Metadata file for pkg-config +# ( http://www.freedesktop.org/software/pkgconfig/ ) +# +# (c)2006, @AUTHOR@, <@EMAIL@>. +# Released under the GNU GPLv2. See file COPYING or +# http://www.gnu.org/copyleft/gpl.html for details. +# + +# Name, description +Name: @TODO@ +Description: @TODO@ +Version: @VERSION@ + +# Requirements +Requires: + +# Compilation information +Libs: -L@LIBDIR@ @NAMEMINUSL@ +Cflags: -I@INCLUDEDIR@ diff --git a/scripts/build.c.lib/soversion b/scripts/build.c.lib/soversion new file mode 100644 index 0000000..faa4d94 --- /dev/null +++ b/scripts/build.c.lib/soversion @@ -0,0 +1,17 @@ +# @P@/src/@NAME@/soversion +# +# (c)2006, @AUTHOR@, <@EMAIL@>. +# Released under the GNU GPLv2. See file COPYING or +# http://www.gnu.org/copyleft/gpl.html for details. +# + + + +# SOMAJOR and SOMINOR are included in the library's soname. They need to +# be bumped on a binary-incompatible release. They are both single +# integers. +SOMAJOR=0 +SOMINOR=0 + +# SOMICRO is bumped every time there is a binary-compatible release. +SOMICRO=0 diff --git a/scripts/build.c.tests/build.default b/scripts/build.c.tests/build.default new file mode 100644 index 0000000..29b4364 --- /dev/null +++ b/scripts/build.c.tests/build.default @@ -0,0 +1,3 @@ +source src/@NAME@/build.tests +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c.tests/build.tests b/scripts/build.c.tests/build.tests new file mode 100644 index 0000000..27c71c6 --- /dev/null +++ b/scripts/build.c.tests/build.tests @@ -0,0 +1,43 @@ +# These are external variables, and shouldn't clash with anything else +# @NAME@_BUILT +# + +#@TODO@ build_target libs || return 1 + +if [ -z ${@NAME@_BUILT} ] +then + LIBS="" # @TODO@ internal libs + EXTRAS="" # @TODO@ libs, cflags + + echo "Building test programs..." + do_cmd mkdir -p obj/tests || return 1 + + for SRC in src/@NAME@/*.c + do + TEST="obj/tests/$(basename ${SRC} | sed -e 's,.c$,,')" + MODIFIED=0 + for file in ${LIBS} ${SRC} src/@NAME@/build.tests + do + if [ ${file} -nt ${TEST} ] + then + MODIFIED=1 + break + fi + done + + if [ ${MODIFIED} -ne 0 ] + then + do_cmd ${CC} -Iobj ${CFLAGS} -o ${TEST} ${SRC} ${LIBS} ${EXTRAS} || return 1 + print_success "Built ${TEST}" + else + print_success "${TEST} is up to date" + fi + done + + print_success "All tests built" + + @NAME@_BUILT=1 +fi + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c.tests/instantiate b/scripts/build.c.tests/instantiate new file mode 100644 index 0000000..49e9e24 --- /dev/null +++ b/scripts/build.c.tests/instantiate @@ -0,0 +1,25 @@ +if [ $# -ne 0 ] +then + print_failure "Unexpected extra parameters." + exit 1 +fi + +if [ -e src/${NAME} ] +then + print_failure "src/${NAME} already exists." + exit 1 +fi + +echo "Instantiating module src/${NAME}..." + +do_cmd mkdir src/${NAME} || exit 1 +do_cmd cp ${TEMPLATE}/* src/${NAME} || exit 1 + +do_cmd cd src/${NAME} || exit 1 +do_cmd rm instantiate || exit 1 +do_cmd find . -type f -exec sed -e "s,@NAME@,${NAME},g" -i {} \; || exit 1 +do_cmd grep "@TODO@" * || exit 1 +print_success "Module instantiated." + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c.tests/template b/scripts/build.c.tests/template new file mode 100644 index 0000000..aa03aff --- /dev/null +++ b/scripts/build.c.tests/template @@ -0,0 +1,34 @@ +/* @P@/src/@NAME@/???.c + * + * (c)2006, @AUTHOR@, <@EMAIL@>. + * Released under the GNU GPLv2. See file COPYING or + * http://www.gnu.org/copyleft/gpl.html for details. +*/ + +@TODO@ includes + +#include "stdio.h" + + + +int main(int argc, char* argv[]) +{ + if(argc == 2 && !strcmp(argv[1], "--print-summary")) { + printf("One line summary.\n"); + return 0; + } + + if(argc == 1) { + // empty argument list + } + + int ret = 0; + // TODO + + return ret; +} + +/* options for text editors +kate: replace-trailing-space-save true; space-indent true; tab-width 4; +vim: expandtab:ts=4:sw=4 +*/ diff --git a/scripts/build.doxygen.docs/Doxyfile.in b/scripts/build.doxygen.docs/Doxyfile.in new file mode 100644 index 0000000..cbf6337 --- /dev/null +++ b/scripts/build.doxygen.docs/Doxyfile.in @@ -0,0 +1,146 @@ +# @P@/src/@NAME@/Doxyfile.in +# +# (c)2006, @AUTHOR@, <@EMAIL@>. +# Released under the GNU GPLv2. See file COPYING or +# http://www.gnu.org/copyleft/gpl.html for details. +# + +PROJECT_NAME = @P@ +OUTPUT_DIRECTORY = +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +USE_WINDOWS_ENCODING = NO +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = YES +FULL_PATH_NAMES = NO +STRIP_FROM_PATH = +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = YES +DETAILS_AT_TOP = YES +INHERIT_DOCS = YES +DISTRIBUTE_GROUP_DOC = NO +TAB_SIZE = 4 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +SUBGROUPING = YES +EXTRACT_ALL = NO +EXTRACT_PRIVATE = NO +EXTRACT_STATIC = NO +EXTRACT_LOCAL_CLASSES = NO +EXTRACT_LOCAL_METHODS = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = YES +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = NO +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = NO +SHOW_DIRECTORIES = NO +FILE_VERSION_FILTER = +QUIET = YES +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = YES +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +FILE_PATTERNS = +RECURSIVE = NO +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = src/docs +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +VERBATIM_HEADERS = NO +ALPHABETICAL_INDEX = YES +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = NO +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = NO +TREEVIEW_WIDTH = 250 +GENERATE_LATEX = NO +GENERATE_RTF = NO +GENERATE_MAN = NO +GENERATE_XML = NO +GENERATE_AUTOGEN_DEF = NO +GENERATE_PERLMOD = NO +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = DOXYGEN +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +CLASS_DIAGRAMS = YES +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = YES +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = NO +UML_LOOK = NO +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = NO +INCLUDED_BY_GRAPH = NO +CALL_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = NO +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1024 +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = YES +DOT_MULTI_TARGETS = YES +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +SEARCHENGINE = NO diff --git a/scripts/build.doxygen.docs/MainPage.dox b/scripts/build.doxygen.docs/MainPage.dox new file mode 100644 index 0000000..44336a5 --- /dev/null +++ b/scripts/build.doxygen.docs/MainPage.dox @@ -0,0 +1,15 @@ +/* @P@/src/@NAME@/MainPage.dox + * + * (c)2006, @AUTHOR@, <@EMAIL@>. + * Released under the GNU GPLv2. See file COPYING or + * http://www.gnu.org/copyleft/gpl.html for details. +*/ + +/*! \mainpage + +*/ + +/* options for text editors +kate: replace-trailing-space-save true; space-indent true; tab-width 4; +vim: expandtab:ts=4:sw=4 +*/ diff --git a/scripts/build.doxygen.docs/build.default b/scripts/build.doxygen.docs/build.default new file mode 100644 index 0000000..d2e9d0d --- /dev/null +++ b/scripts/build.doxygen.docs/build.default @@ -0,0 +1 @@ +source src/@NAME@/build.docs diff --git a/scripts/build.doxygen.docs/build.docs b/scripts/build.doxygen.docs/build.docs new file mode 100644 index 0000000..a04b6e8 --- /dev/null +++ b/scripts/build.doxygen.docs/build.docs @@ -0,0 +1,43 @@ +# These are external variables, and shouldn't clash with anything else +# @NAME@_BUILT +# + +MONOLITHIC_@NAME@="${MONOLITHIC_DOC} $(echo src/@NAME@/*.dox)" +build_target monolithic + +if [ -z ${@NAME@_BUILT} ] +then + echo "Building documentation with Doxygen..." + + DOXYFILE=obj/Doxyfile.@NAME@ + + if [ ! -e ${DOXYFILE} ] + then + do_cmd cp src/docs/Doxyfile.in ${DOXYFILE} || return 1 + echo "INPUT = ${MONOLITHIC_DOC}" >> ${DOXYFILE} + echo "PROJECT_NUMBER = ${VERSION}" >> ${DOXYFILE} + fi + + MODIFIED=0 + for file in ${MONOLITHIC_@NAME@} + do + if [ ${file} -nt html/index.html ] + then + MODIFIED=1 + break + fi + done + + if [ ${MODIFIED} -ne 0 ] + then + do_cmd doxygen ${DOXYFILE} || return 1 + print_success "Documentation built" + else + print_success "Documentation is up to date" + fi + + @NAME@_BUILT=1 +fi + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.doxygen.docs/build.install b/scripts/build.doxygen.docs/build.install new file mode 100644 index 0000000..53e467a --- /dev/null +++ b/scripts/build.doxygen.docs/build.install @@ -0,0 +1 @@ +source src/@NAME@/build.install-docs diff --git a/scripts/build.doxygen.docs/build.install-docs b/scripts/build.doxygen.docs/build.install-docs new file mode 100644 index 0000000..66167d3 --- /dev/null +++ b/scripts/build.doxygen.docs/build.install-docs @@ -0,0 +1,21 @@ +build_target docs + +# create documentation directories +echo "Installing documentation into ${DOCSDIR}" +build_dir_tree "${DOCSDIR}/html" || return 1 + +# copy across the Doxygen-generated documentation +for file in html/* +do + install_file ${file} ${DOCSDIR}/html 0644 || return 1 +done + +# copy across the generic files +for file in COPYING README +do + install_file ${file} ${DOCSDIR} 0644 || return 1 +done + +print_success "Documentation installed" +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.doxygen.docs/instantiate b/scripts/build.doxygen.docs/instantiate new file mode 100644 index 0000000..f8f4e51 --- /dev/null +++ b/scripts/build.doxygen.docs/instantiate @@ -0,0 +1,25 @@ +if [ $# -ne 0 ] +then + print_failure "Too many arguments. None required for this module." + exit 1 +fi + +if [ -e src/${NAME} ] +then + print_failure "src/${NAME} already exists." + exit 1 +fi + +echo "Instantiating module src/${NAME}..." + +do_cmd mkdir src/${NAME} || exit 1 +do_cmd cp ${TEMPLATE}/* src/${NAME} || exit 1 + +do_cmd cd src/${NAME} || exit 1 +do_cmd rm instantiate || exit 1 +do_cmd find . -type f -exec sed -e "s,@NAME@,${NAME},g" -i {} \; || exit 1 +do_cmd grep "@TODO@" * || exit 1 +print_success "Module instantiated." + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.sdcc.firmware/TopHeader.h b/scripts/build.sdcc.firmware/TopHeader.h new file mode 100644 index 0000000..4f989d5 --- /dev/null +++ b/scripts/build.sdcc.firmware/TopHeader.h @@ -0,0 +1,13 @@ +/* @P@/src/capp/TopHeader.h + * + * (c)2006, @AUTHOR@, <@EMAIL@>. + * Released under the GNU GPLv2. See file COPYING or + * http://www.gnu.org/copyleft/gpl.html for details. +*/ + +// standard includes, or includes needed for type declarations + +/* options for text editors +kate: replace-trailing-space-save true; space-indent true; tab-width 4; +vim: expandtab:ts=4:sw=4 +*/ diff --git a/scripts/build.sdcc.firmware/TopSource.c b/scripts/build.sdcc.firmware/TopSource.c new file mode 100644 index 0000000..3e61cae --- /dev/null +++ b/scripts/build.sdcc.firmware/TopSource.c @@ -0,0 +1,13 @@ +/* @P@/src/capp/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 all the includes used throughout the application. + +/* options for text editors +kate: replace-trailing-space-save true; space-indent true; tab-width 4; +vim: expandtab:ts=4:sw=4 +*/ diff --git a/scripts/build.sdcc.firmware/build.default b/scripts/build.sdcc.firmware/build.default new file mode 100644 index 0000000..7575e55 --- /dev/null +++ b/scripts/build.sdcc.firmware/build.default @@ -0,0 +1 @@ +source src/@NAME@/build.firmware diff --git a/scripts/build.sdcc.firmware/build.firmware b/scripts/build.sdcc.firmware/build.firmware new file mode 100644 index 0000000..397b457 --- /dev/null +++ b/scripts/build.sdcc.firmware/build.firmware @@ -0,0 +1,41 @@ +# These are external variables, and shouldn't clash with anything else +# @NAME@ +# @NAME@_BUILT +# + +if [ -z ${@NAME@_BUILT} ] +then + @NAME@="obj/@NAME@.hex" + EXTRAS="@TODO@" # cflags, libs + + echo "Building firmware ${@NAME@}..." + + do_cmd source src/@NAME@/build.monolithic || return 1 + + MODIFIED=0 + for test in ${MONOLITHIC_TESTS} ${SRC} + do + if [ ${test} -nt ${@NAME@} ] + then + MODIFIED=1 + break + fi + done + + if [ ${MODIFIED} -ne 0 ] + then + echo " Compiling..." + + do_cmd ${SDCC} ${SDCCFLAGS} -o "${@NAME@}" ${SRC} ${EXTRAS} || return 1 + + print_success "Firmware built" + else + print_success "Firmware up to date" + fi + + @NAME@_BUILT=1 + +fi + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.sdcc.firmware/build.install b/scripts/build.sdcc.firmware/build.install new file mode 100644 index 0000000..9869fed --- /dev/null +++ b/scripts/build.sdcc.firmware/build.install @@ -0,0 +1 @@ +source src/@NAME@/build.install-firmware diff --git a/scripts/build.sdcc.firmware/build.install-firmware b/scripts/build.sdcc.firmware/build.install-firmware new file mode 100644 index 0000000..a141de6 --- /dev/null +++ b/scripts/build.sdcc.firmware/build.install-firmware @@ -0,0 +1,12 @@ +build_target @NAME@ + +# make paths (this is for Gentoo in particular) +build_dir_tree "${HEXDIR}" || return 1 + +# install binary +echo "Installing firmware into '${HEXDIR}'" +install_file "${@NAME@}" "${HEXDIR}" 0755 || return 1 +print_success "Done" + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.sdcc.firmware/build.monolithic b/scripts/build.sdcc.firmware/build.monolithic new file mode 100644 index 0000000..6691075 --- /dev/null +++ b/scripts/build.sdcc.firmware/build.monolithic @@ -0,0 +1,18 @@ +# These are external variables, and shouldn't clash with anything else +# @NAME@_MONOLITHIC +# + +SRC="obj/@NAME@.c" +MONOLITHIC_TESTS="src/@NAME@/build.firmware src/@NAME@/build.monolithic" + +if [ -z "${@NAME@_MONOLITHIC}" ] +then + MONOLITHIC_SOURCE="$(echo src/@NAME@/TopHeader.h) $(echo src/@NAME@/TopSource.c)" + make_monolithic ${SRC} C || return 1 + + @NAME@_MONOLITHIC=1 + MONOLITHIC_DOC="${MONOLITHIC_DOC} ${SRC}" +fi + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.sdcc.firmware/instantiate b/scripts/build.sdcc.firmware/instantiate new file mode 100644 index 0000000..f8f4e51 --- /dev/null +++ b/scripts/build.sdcc.firmware/instantiate @@ -0,0 +1,25 @@ +if [ $# -ne 0 ] +then + print_failure "Too many arguments. None required for this module." + exit 1 +fi + +if [ -e src/${NAME} ] +then + print_failure "src/${NAME} already exists." + exit 1 +fi + +echo "Instantiating module src/${NAME}..." + +do_cmd mkdir src/${NAME} || exit 1 +do_cmd cp ${TEMPLATE}/* src/${NAME} || exit 1 + +do_cmd cd src/${NAME} || exit 1 +do_cmd rm instantiate || exit 1 +do_cmd find . -type f -exec sed -e "s,@NAME@,${NAME},g" -i {} \; || exit 1 +do_cmd grep "@TODO@" * || exit 1 +print_success "Module instantiated." + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/functions.sh b/scripts/functions.sh new file mode 100755 index 0000000..c6b1e5b --- /dev/null +++ b/scripts/functions.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# @P@/scripts/functions.sh +# +# (c)2006, @AUTHOR@, <@EMAIL@>. +# Released under the GNU GPLv2. See file COPYING or +# http://www.gnu.org/copyleft/gpl.html for details. +# + +# Common functions + + + +# Print a success message +print_success() { + if [ -z "${TERM}" -o "${TERM}" == "dumb" ] + then + echo -n " - " + else + (echo -n -e " \E[32m* "; tput sgr0) + fi + echo $* +} + + + +# Print a failure message +print_failure() { + if [ -z "${TERM}" -o "${TERM}" == "dumb" ] + then + echo -n " *** " + else + (echo -n -e " \E[31m*** "; tput sgr0) + fi + echo $* +} + + + +# This function carries out a command, but reports its failure if +# necessary. +do_cmd() { + [ "${VERBOSE}" != "0" ] && echo "$@" + "$@" + if [ $? -ne 0 ] + then + print_failure "'$@' failed." + return 1 + fi +} + + + +# This function carries out a command, but reports its failure if +# necessary. +do_cmd_redir() { + DEST=$1 + shift + [ "${VERBOSE}" != "0" ] && echo "$@ >> ${DEST}" + "$@" >> ${DEST} + if [ $? -ne 0 ] + then + print_failure "'$@' failed." + return 1 + fi +} + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/module-create.sh b/scripts/module-create.sh new file mode 100755 index 0000000..9b48b27 --- /dev/null +++ b/scripts/module-create.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# @P@/scripts/module-create.sh +# +# (c)2006, @AUTHOR@, <@EMAIL@>. +# Released under the GNU GPLv2. See file COPYING or +# http://www.gnu.org/copyleft/gpl.html for details. +# + +# Creates a new source module. + + + +# Get the directory of the repository (needed to include functions file) +cd $(dirname $0) +cd $(dirname $(pwd)) +[ -z "${VERBOSE}" ] && VERBOSE="0" +source scripts/functions.sh || exit 1 + + + +# Get arguments. +if [ $# -lt 3 ] +then + echo "Usage: scripts/module-create.sh [args]" + echo " available modules:" + for i in scripts/build.* + do + echo $i | sed "s,scripts/build\.\([^.]*\)\.\(.*\), lang: \1 type: \2," + done + exit 1 +fi +LANG=$1 +shift +TYPE=$1 +shift +NAME=$1 +shift +TEMPLATE=scripts/build.${LANG}.${TYPE} + +if [ ! -e ${TEMPLATE}/instantiate ] +then + echo "No such module type." + exit 1 +fi + +source ${TEMPLATE}/instantiate + + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/module-rename.sh b/scripts/module-rename.sh new file mode 100755 index 0000000..0a43cab --- /dev/null +++ b/scripts/module-rename.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# @P@/scripts/module-rename.sh +# +# (c)2006, @AUTHOR@, <@EMAIL@>. +# Released under the GNU GPLv2. See file COPYING or +# http://www.gnu.org/copyleft/gpl.html for details. +# + +# Renames a source module (e.g. "src/oldlib" -> "src/newlib") by running +# a sed script on all files to change filenames / headers. + + + +# Get the directory of the repository (needed to include functions file) +cd $(dirname $0) +cd $(dirname $(pwd)) +[ -z "${VERBOSE}" ] && VERBOSE="0" +source scripts/functions.sh || exit 1 + + + +# Get version etc. +if [ $# -ne 2 ] +then + echo "Usage: scripts/module-rename.sh " + exit 1 +fi +OLD="src/$1" +NEW="src/$2" + + +if [ ! -e ${OLD} ] +then + print_failure "${OLD} does not exist" + exit 1 +fi + +if [ -e ${NEW} ] +then + print_failure "${NEW} already exists" + exit 1 +fi + +echo "Moving ${OLD} -> ${NEW}" +do_cmd mv ${OLD} ${NEW} || exit 1 +do_cmd find ${NEW} -type f -exec sed -e "s,${OLD},${NEW},g" -i {} \; || exit 1 +print_success "Done" + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4 diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100755 index 0000000..e592048 --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# @P@/scripts/release.sh +# +# (c)2006, @AUTHOR@, <@EMAIL@>. +# Released under the GNU GPLv2. See file COPYING or +# http://www.gnu.org/copyleft/gpl.html for details. +# + +# Prepares package for release. Expects the version number on the +# command line. + + + +# Get the directory of the repository (needed to include functions file) +cd "$(dirname $0)" +REPOS=$(dirname "$(pwd)") +[ -z "${VERBOSE}" ] && VERBOSE=0 +source "${REPOS}/scripts/functions.sh" || exit 1 + + + +# Get version etc. +if [ $# -ne 2 ] +then + echo "Usage: scripts/release.sh " + exit 1 +fi +VER=$1 +DIR=$2 + +PKGNAME="@P@-${VER}" + + + +# move to output directory and clone git repository +echo "Cloning repository..." +do_cmd cd "${DIR}" || exit 1 +do_cmd rm -rf "${PKGNAME}" "${PKGNAME}-doc" || exit 1 +do_cmd git-clone --local --shared -n "${REPOS}" "${PKGNAME}" || exit 1 +do_cmd cd "${PKGNAME}" || exit 1 +print_success "Done" + + + +# Check out a new copy of the library from git +echo "Checking out tag ${VER}..." +do_cmd git-checkout -b releaseprivate "${VER}" || exit 1 +print_success "Done" + + + +# Check that the default build operation runs; also, build and save the +# documentation whilst we're at it +do_cmd ./make.sh default docs || exit 1 +do_cmd mv html "../${PKGNAME}-doc" || exit 1 + + + +# Clean up +do_cmd ./make.sh clean || exit 1 +do_cmd rm -rf .git || exit 1 + + + +# Build archive, md5sum and signature +cd .. +tar c "${PKGNAME}" | bzip2 > "${PKGNAME}.tar.bz2" +tar c "${PKGNAME}-doc" | bzip2 > "${PKGNAME}-doc.tar.bz2" +sha1sum "${PKGNAME}.tar.bz2" > "${PKGNAME}.sha1" +sha1sum "${PKGNAME}-doc.tar.bz2" > "${PKGNAME}-doc.sha1" +gpg -a -b "${PKGNAME}.tar.bz2" +gpg -a -b "${PKGNAME}-doc.tar.bz2" + + + +# clean up +rm -rf "${PKGNAME}" "${PKGNAME}-doc" + +# kate: replace-trailing-space-save true; space-indent true; tab-width 4; +# vim: expandtab:ts=4:sw=4