45 lines
1.3 KiB
Plaintext
45 lines
1.3 KiB
Plaintext
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
|