lw-build-system/install.sh

95 lines
2.1 KiB
Bash
Raw Normal View History

2006-07-24 14:24:06 +01:00
#!/bin/bash
#
# (c)2006, Laurence Withers. Released under the GNU GPL. See file
# COPYING for details.
#
# Used to create a new project. You pass it the template parameters, it
# does the rest.
2006-07-24 14:49:31 +01:00
[ -z "${VERBOSE}" ] && VERBOSE="0"
2006-07-24 14:24:06 +01:00
# Sanity checks
2006-07-24 14:29:53 +01:00
if [ $# -ne 4 ]
2006-07-24 14:24:06 +01:00
then
echo "Wrong number of arguments. Expecting:"
echo " ./install.sh <dest_dir> @P@ @PC@ @HEADER_NAME@"
echo " dest_dir directory in which project subdir will be created"
echo " @P@ package name (e.g. \"libnmc\")"
echo " @PC@ C identifier version of @P@, used in header etc."
echo " @HEADER_NAME@ name of header (e.g. \"lw-support\" or \"nmc\")"
exit 1
fi
cd "$(dirname $0)"
2006-07-24 14:29:53 +01:00
TEMPLATE="$(pwd)/skel"
2006-07-24 14:24:06 +01:00
# Get arguments, include standard functions
2006-07-24 14:29:53 +01:00
source ${TEMPLATE}/scripts/functions.sh || exit 1
2006-07-24 14:24:06 +01:00
DEST_DIR="$1"; shift
P="$1"; shift
PC="$1"; shift
HEADER_NAME="$1"; shift
2006-07-24 14:37:44 +01:00
DEST_DIR="${DEST_DIR}/${P}"
2006-07-24 17:13:01 +01:00
PMINUSL="-l$(echo ${P} | sed -e 's,^lib,,')"
2006-07-24 14:37:44 +01:00
2006-07-24 14:24:06 +01:00
# Copy to destination directory. Deal with the case where the user has
# specified the name of the resulting directory, and the case where the
# user simply specified where the directory should be created.
echo "Copying ${TEMPLATE} directory..."
do_cmd cp -rp "${TEMPLATE}" "${DEST_DIR}" || exit 1
cd "${DEST_DIR}"
print_success "Done: $(pwd)"
# Move the project files to something more sensible
mv project.kdevelop ${P}.kdevelop
mv project.kdevelop.filelist ${P}.kdevelop.filelist
# Build sed script
echo "Changing variables..."
2006-07-24 17:13:01 +01:00
echo -n " Building script ( "
2006-07-24 14:24:06 +01:00
SED_SCRIPT="script.sed"
2006-07-24 17:13:01 +01:00
for param in P PC HEADER_NAME PMINUSL
2006-07-24 14:24:06 +01:00
do
echo "s,@${param}@,${!param},g" >> "${SED_SCRIPT}"
2006-07-24 17:13:01 +01:00
echo -n "${PARAM} "
2006-07-24 14:24:06 +01:00
done
2006-07-24 17:13:01 +01:00
echo ")"
2006-07-24 14:24:06 +01:00
# Create a list of all the files.
echo " Building list of files"
ALL_FILES=$(find . -type f -not -name script.sed)
# Run sed script on all files.
echo " Running script"
for f in ${ALL_FILES}
do
do_cmd sed -f "${SED_SCRIPT}" -i "${f}" || exit 1
done
print_success "Done"
# Print the todo list
echo
echo " ======== TODO list ========"
grep -Hn @TODO@ ${ALL_FILES}
print_success "Done"
# Clean up
rm "${SED_SCRIPT}"