#! /bin/bash
## @file
##
## $Id$
##
## $Date: 2004/08/31 15:57:19 $
## $Author: marc $
##
## @copy © Marc Wäckerlin
## @license LGPL, see file COPYING
##
## $Log: bootstrap.sh,v $
## Revision 1.3 2004/08/31 15:57:19 marc
## added file header
##
configure=0
while test $# -gt 0; do
case "$1" in
(--configure|-c) configure=1;;
(*) break;;
esac
shift;
done
MY_NAME=${0##*/}
PROJECT_PATH=$(pwd)
DEFAULT_PROJECT_NAME=${PROJECT_PATH##*/}
HEADER='## @id $Id$
#
# This file has been added by '${MY_NAME}' on '$(date -R)'
# Feel free to change it or even remove and rebuild it, up to your needs
#
## 1 2 3 4 5 6 7 8
## 45678901234567890123456789012345678901234567890123456789012345678901234567890
'
run() {
check=1
while test $# -gt 0; do
case "$1" in
(--no-check) check=0;;
(*) break;;
esac
shift;
done
echo -en "\e[1m-> running:\e[0m $* ..."
result=$($* 2>&1)
res=$?
if test $res -ne 0; then
if test $check -eq 1; then
echo -e " \e[31merror\e[0m"
echo -e "\e[1m*** Failed with return code: $res\e[0m"
if test -n "$result"; then
echo "$result"
fi
exit 1
else
echo -e " \e[33mignored\e[0m"
fi
else
echo -e " \e[32msuccess\e[0m"
fi
}
testtag() {
egrep -q '^ *'"$1" configure.ac
}
checkdir() {
if ! test -d "$1"; then # create path
run mkdir -p "$1"
run svn add "$1"
fi
}
to() {
while test $# -gt 0; do
case "$1" in
(--condition) shift # test for a tag, abort if not set
if ! testtag "$1" configure.ac; then
return
fi;;
(*) break;;
esac
shift;
done
if test -f "$1"; then # file already exists
return
fi
checkdir "$(dirname ${1})"
echo -en "\e[1m-> generating:\e[0m $1 ..."
result=$(cat > "$1" 2>&1)
res=$?
if test $res -ne 0; then
echo -e " \e[31merror\e[0m"
echo -e "\e[1m*** Failed with return code: $res\e[0m"
if test -n "$result"; then
echo "$result"
fi
exit 1
else
echo -e " \e[32msuccess\e[0m"
fi
run svn add "$1"
run svn propset svn:keywords "Id" "$1"
}
copy() {
if ! test -f "$1"; then
run cp "${0%/*}/$1" "$1"
run svn add "$1"
run svn propset svn:keywords "Id" "$1"
fi
}
doxyreplace() {
echo -en "\e[1m-> doxyfile:\e[0m configure $1 ..."
if sed -i 's|\(^'"$1"' *=\) *|\1'" $2"'|g' doc/doxyfile.in; then
echo -e " \e[32msuccess\e[0m"
else
echo -e " \e[31merror\e[0m"
echo -e "\e[1m**** command: sed -i 's|\(^'"$1"' *=\) *|\1'" $2"'|g' doc/doxyfile.in;\e[0m"
exit 1
fi
}
# Initialize the environment:
copy ${MY_NAME}
copy ax_init_standard_project.m4
copy ax_cxx_compile_stdcxx_11.m4
copy ax_check_qt.m4
copy AUTHORS
if ! test -f configure.ac; then
to configure.ac <
namespace NAMESPACE {
std::string package_string();
std::string package_name();
std::string version();
std::string build_date();
std::string author();
std::string description();
std::string logo();
std::string icon();
extern const std::string WHAT;
extern const std::string IDENT;
}
EOF
to --condition AX_USE_CXX src/version.cxx <
namespace NAMESPACE {
std::string package_string() {
return PACKAGE_STRING;
}
std::string package_name() {
return PACKAGE_NAME;
}
std::string version() {
return PACKAGE_VERSION;
}
std::string build_date() {
return BUILD_DATE_STR;
}
std::string author() {
return AUTHOR_STR;
}
std::string description() {
return README_STR;
}
std::string logo() {
return PROJECT_LOGO_STR;
}
std::string icon() {
return PROJECT_ICON_STR;
}
const std::string WHAT("#(@) " PACKAGE_STRING);
const std::string IDENT("\$Id: " PACKAGE_STRING);
}
EOF
echo "${HEADER}" | to --condition AX_USE_DOXYGEN doc/makefile.am
to --condition AX_USE_CPPUNIT test/makefile.am <