1#! /usr/bin/env bash 2 3# file : build/c/gnu/dep 4# copyright : Copyright (c) 2004-2012 Code Synthesis Tools CC 5# license : GNU GPL v2; see accompanying LICENSE file 6 7# Post-process generated dependency information. 8# 9# $1 current project's $(out_base) 10# $2 - $N optional .cpp-options files 11 12out_base=$1 13shift 14 15files=$* 16 17#echo $out_base 18#echo $files 19 20script= 21 22function gen_script () 23{ 24 while [ "$1" ]; do 25 prefix=$1 26 shift 27 28 path=$1 29 shift 30 31 # Besides unresolved paths also replace default installation 32 # targets (/usr/include and /usr/local/include). 33 # 34 script="$script"\ 35"s \\ $prefix \\ $path$prefix g;"\ 36"s \\ /usr/include/$prefix \\ $path$prefix g;"\ 37"s \\ /usr/local/include/$prefix \\ $path$prefix g;"\ 38"s ^$prefix $path$prefix ;"\ 39"s ^/usr/include/$prefix $path$prefix ;"\ 40"s ^/usr/local/include/$prefix $path$prefix ;" 41 done 42} 43 44if [ "$files" ]; then 45 prefixes=`sed -e 's%^prefix: \(.*\)$%\1%' -e t -e d $files` 46 gen_script $prefixes 47fi 48 49# The last part of the script translates all file names that don't start 50# with / or . (that is, local generated files) to files in $out_base. Note 51# that it is assumed that such files are never installed and therefore there 52# is no way to get around the situation where this file is picket up from 53# some other place (e.g., /usr/include). 54# 55epilogue="s% \([^/. \\\\]\)% $out_base/\1%g;s%^\([^/. ].*:\)%$out_base/\1%" 56 57exec sed -e "$script$epilogue" 58