Skip to content

Latest commit

 

History

History
executable file
·
93 lines (77 loc) · 2.19 KB

makedep.sh

File metadata and controls

executable file
·
93 lines (77 loc) · 2.19 KB
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
#
# Generate dependencies from a list of source files
# Check to make sure our environment variables are set
if test x"$SOURCES" = x -o x"$output" = x; then
echo "SOURCES, 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
: # We already ahve this cached
else
: >$cache
for path in $base
do dep="$path/$file"
if test -f "$dep"; then
echo " $dep \\" >>$cache
search_deps $dep >>$cache
break
fi
done
fi
cat $cache
done
}
:>${output}.new
for src in $SOURCES
do echo "Generating dependencies for $src"
ext=`echo $src | sed 's|.*\.\(.*\)|\1|'`
Jul 18, 2007
Jul 18, 2007
44
45
46
47
48
if test x"$ext" = x"rc"; then
obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|\1.o|g"`
else
obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|\1.lo|g"`
fi
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
echo "\$(objects)/$obj: $src \\" >>${output}.new
search_deps $src | sort | uniq >>${output}.new
case $ext in
c) cat >>${output}.new <<__EOF__
\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src -o \$@
__EOF__
;;
cc) cat >>${output}.new <<__EOF__
\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src -o \$@
__EOF__
;;
m) cat >>${output}.new <<__EOF__
\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src -o \$@
__EOF__
;;
asm) cat >>${output}.new <<__EOF__
\$(LIBTOOL) --tag=CC --mode=compile \$(auxdir)/strip_fPIC.sh \$(NASM) $src -o \$@
__EOF__
;;
S) cat >>${output}.new <<__EOF__
\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src -o \$@
Jul 18, 2007
Jul 18, 2007
80
81
82
83
84
85
__EOF__
;;
rc) cat >>${output}.new <<__EOF__
\$(WINDRES) $src \$@
86
87
88
89
90
91
92
93
__EOF__
;;
*) echo "Unknown file extension: $ext";;
esac
echo "" >>${output}.new
done
mv ${output}.new ${output}
rm -f ${cache_prefix}*