aboutsummaryrefslogtreecommitdiff
path: root/build/c/gnu/dep
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-02-05 18:01:45 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-02-05 18:01:45 +0200
commitd7b7e218bfe92516f525568a6c1c9e1a9eb241fe (patch)
tree6cbc3155d7188f65e4b806c6edeecdd53393da69 /build/c/gnu/dep
Start tracking build with git
Diffstat (limited to 'build/c/gnu/dep')
-rwxr-xr-xbuild/c/gnu/dep58
1 files changed, 58 insertions, 0 deletions
diff --git a/build/c/gnu/dep b/build/c/gnu/dep
new file mode 100755
index 0000000..e0c0544
--- /dev/null
+++ b/build/c/gnu/dep
@@ -0,0 +1,58 @@
+#! /usr/bin/env bash
+
+# file : build/c/gnu/dep
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC
+# license : GNU GPL v2; see accompanying LICENSE file
+
+# Post-process generated dependency information.
+#
+# $1 current project's $(out_base)
+# $2 - $N optional .cpp-options files
+
+out_base=$1
+shift
+
+files=$*
+
+#echo $out_base
+#echo $files
+
+script=
+
+function gen_script ()
+{
+ while [ "$1" ]; do
+ prefix=$1
+ shift
+
+ path=$1
+ shift
+
+ # Besides unresolved paths also replace default installation
+ # targets (/usr/include and /usr/local/include).
+ #
+ script="$script"\
+"s \\ $prefix \\ $path$prefix g;"\
+"s \\ /usr/include/$prefix \\ $path$prefix g;"\
+"s \\ /usr/local/include/$prefix \\ $path$prefix g;"\
+"s ^$prefix $path$prefix ;"\
+"s ^/usr/include/$prefix $path$prefix ;"\
+"s ^/usr/local/include/$prefix $path$prefix ;"
+ done
+}
+
+if [ "$files" ]; then
+ prefixes=`sed -e 's%^prefix: \(.*\)$%\1%' -e t -e d $files`
+ gen_script $prefixes
+fi
+
+# The last part of the script translates all file names that don't start
+# with / (that is, local generated files) to files in $out_base. Note that
+# it is assumed that such files are never installed and therefore there is
+# no way get around the situation where this file is picket up from some
+# other place (e.g., /usr/include).
+#
+epilogue="s% \([^/ \\\\]\)% $out_base/\1%g;s%^\([^/ ].*:\)%$out_base/\1%"
+
+exec sed -e "$script$epilogue"