Skip to content

Latest commit

 

History

History
executable file
·
62 lines (57 loc) · 1.84 KB

makedep.sh

File metadata and controls

executable file
·
62 lines (57 loc) · 1.84 KB
 
1
2
3
4
#!/bin/sh
#
# Generate dependencies from a list of source files
Feb 20, 2006
Feb 20, 2006
5
6
7
8
9
BUILDC="\\\$\\(LIBTOOL\\) --mode=compile \\\$\\(CC\\) \\\$\\(CFLAGS\\) -c \$src -o \\\$@"
BUILDCC=$BUILDC
BUILDM=$BUILDC
BUILDASM="\\\$\\(LIBTOOL\\) --tag=CC --mode=compile \\\$\\(auxdir\\)/strip_fPIC.sh \\\$\\(NASM\\) \$src -o \\\$@"
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Check to make sure our environment variables are set
if test x"$INCLUDE" = x -o x"$SOURCES" = x -o x"$objects" = x -o x"$output" = x; then
echo "SOURCES, INCLUDE, objects, and output needs to be set"
exit 1
fi
cache_prefix=".#$$"
generate_var()
{
echo $1 | sed -e 's|^.*/||' -e 's|\.|_|g'
}
search_deps()
{
base=`echo $1 | sed 's|/[^/]*$||'`
grep '#include "' <$1 | sed -e 's|.*"\([^"]*\)".*|\1|' | \
while read file
do cache=${cache_prefix}_`generate_var $file`
if test -f $cache; then
Feb 20, 2006
Feb 20, 2006
29
30
31
32
33
34
35
36
37
38
39
: # We already ahve this cached
else
: >$cache
for path in $base `echo $INCLUDE | sed 's|-I||g'`
do dep="$path/$file"
if test -f "$dep"; then
echo " $dep \\" >>$cache
search_deps $dep >>$cache
break
fi
done
Feb 20, 2006
Feb 20, 2006
41
cat $cache
42
43
44
45
46
47
48
49
done
}
:>${output}.new
for src in $SOURCES
do echo "Generating dependencies for $src"
ext=`echo $src | sed 's|.*\.\(.*\)|\1|'`
obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|$objects/\1.lo|g"`
Feb 20, 2006
Feb 20, 2006
50
51
52
echo "$obj: $src \\" >>${output}.new
search_deps $src | sort | uniq >>${output}.new
echo "" >>${output}.new
Feb 20, 2006
Feb 20, 2006
54
55
56
57
c) eval echo \\" $BUILDC\\" >>${output}.new;;
cc) eval echo \\" $BUILDCC\\" >>${output}.new;;
m) eval echo \\" $BUILDM\\" >>${output}.new;;
asm) eval echo \\" $BUILDASM\\" >>${output}.new;;
58
59
60
61
62
*) echo "Unknown file extension: $ext";;
esac
echo "" >>${output}.new
done
mv ${output}.new ${output}