summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2006-03-03 16:31:31 +0000
committerMarc Kleine-Budde <mkl@pengutronix.de>2006-03-03 16:31:31 +0000
commit17485f9321feab019fca4e51294084a6cab5a8fe (patch)
tree72fc0ec63ddaad7652cd4cdf25587687d5ee2d64 /scripts
parentd1db70b5f5ebb5840780f38ae9bbbea6dbdaa81c (diff)
downloadptxdist-17485f9321feab019fca4e51294084a6cab5a8fe.tar.gz
ptxdist-17485f9321feab019fca4e51294084a6cab5a8fe.tar.xz
git-svn-id: https://svn.pengutronix.de/svn/ptxdist/trunks/ptxdist-0.10-trunk@4990 33e552b5-05e3-0310-8538-816dae2090ed
Diffstat (limited to 'scripts')
-rw-r--r--scripts/create_configdeps.sh167
1 files changed, 167 insertions, 0 deletions
diff --git a/scripts/create_configdeps.sh b/scripts/create_configdeps.sh
new file mode 100644
index 000000000..6faebc782
--- /dev/null
+++ b/scripts/create_configdeps.sh
@@ -0,0 +1,167 @@
+#!/bin/bash
+#
+# Autogenerate Dependencies for Package-Makefiles
+#
+
+FULLARGS="$@"
+
+DEBUG=true
+
+#
+# helper functions
+#
+
+debug_out(){
+ [ $DEBUG ] && echo "$0: $1" >&2
+}
+
+my_exit(){
+ debug_out "$0: $1"
+ exit $2
+}
+
+usage() {
+ echo
+ [ -n "$1" ] && echo -e "${PREFIX} error: $1\n"
+ echo "usage: $0 <args>"
+ echo
+ echo " Arguments:"
+ echo
+ echo " --action defaults"
+ echo " --statedir <dir> PTX State Directory"
+ echo " --rulesdir <dir> PTX Rules Directory"
+ echo " --projectrulesdir <dir> optional local Rules Directory"
+ echo " --dependency-file <file> optional outfile for default dependencies"
+ echo
+ exit 0
+}
+
+check_argument(){
+ case "$1" in
+ --*|"")
+ debug_out "missing argument"
+ return 1
+ ;;
+ [[:alnum:]/]*)
+ #debug_out "argument $1 accepted"
+return 0
+;;
+esac
+}
+
+#
+# Option parser
+#
+while [ $# -gt 0 ]; do
+ case "$1" in
+ --help) usage ;;
+ --action)
+ check_argument $2
+ if [ "$?" == "0" ] ; then
+ ACTION="$2";
+ shift 2 ;
+ else
+ debug_out "skipping option $1";
+ shift 1 ;
+ fi
+ ;;
+ --statedir)
+ check_argument $2
+ if [ "$?" == "0" ] ; then
+ STATEDIR="$2";
+ shift 2 ;
+ else
+ debug_out "skipping option $1";
+ shift 1 ;
+ fi
+ ;;
+ --rulesdir)
+ check_argument $2
+ if [ "$?" == "0" ] ; then
+ RULESDIR="$2";
+ shift 2 ;
+ else
+ debug_out "skipping option $1";
+ shift 1 ;
+ fi
+ ;;
+ --projectrulesdir)
+ check_argument $2
+ if [ "$?" == "0" ] ; then
+ PROJECTRULESDIR="$2";
+ shift 2 ;
+ else
+ debug_out "skipping option $1";
+ shift 1 ;
+ fi
+ ;;
+ --dependency-file)
+ check_argument $2
+ if [ "$?" == "0" ] ; then
+ OUTFILE="$2";
+ shift 2 ;
+ else
+ debug_out "skipping option $1";
+ shift 1 ;
+ fi
+ ;;
+ *)
+ usage "unknown option $1"
+ ;;
+ esac
+done
+
+#
+# Sanity checks
+#
+
+[ -z "$RULESDIR" ] || rulesfiles="$RULESDIR/*.make $rulesfiles"
+[ -z "$PROJECTRULESDIR" ] || rulesfiles="$PROJECTRULESDIR/*.make $rulesfiles"
+[ -z "$rulesfiles" ] && my_exit "Insufficient Arguments - Rules missing" 1
+[ -z "$STATEDIR" ] && my_exit "Insufficient Arguments State Directory missing" 1
+
+debug_out "Rules set to $rulesfiles"
+
+do_fixup(){
+ sed -n "s/PACKAGES-\$(PTXCONF_\(.*\)).*+=[[:space:]]\(.*\)/PACKAGE_\1 \2/p" $rulesfiles | while read package filename; do
+ eval $package=$filename echo ${!package}
+ done
+
+ read
+
+ la_IFS="$IFS"
+ IFS=:
+ cat $STATEDIR/configdeps | while read foo label deps; do
+ ptxconf_label=PTXCONF_${label}
+ if test "${!ptxconf_label}" = "y"; then
+ echo -n "DEP:$label"
+ for dep in $deps; do
+ ptxconf_dep=PTXCONF_${dep}
+ if test "${!ptxconf_dep}" = "y"; then
+ echo -n ":$dep"
+ fi
+ done
+ echo
+ fi
+ done
+ IFS="$la_IFS"
+}
+
+#
+# argument handling
+#
+# case $ACTION in
+# defaults)
+# do_defaults
+# ;;
+# *)
+# my_exit "Sorry, unknown --action specified: $ACTION"
+# ;;
+# esac
+
+. ptxconfig
+
+do_fixup
+
+# vim: syntax=sh
+# vim: tabstop=4