Skip to content

Latest commit

 

History

History
executable file
·
83 lines (69 loc) · 2.06 KB

makedep.sh

File metadata and controls

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