Drop support for dirty rectangles.
[SDL.s60v3.git] / build-scripts / makedep.sh
blobceffe275b0550ffff82c39c06be0cf23e9b2cbde
1 #!/bin/sh
3 # Generate dependencies from a list of source files
5 # Check to make sure our environment variables are set
6 if test x"$INCLUDE" = x -o x"$SOURCES" = x -o x"$output" = x; then
7 echo "SOURCES, INCLUDE, and output needs to be set"
8 exit 1
9 fi
10 cache_prefix=".#$$"
12 generate_var()
14 echo $1 | sed -e 's|^.*/||' -e 's|\.|_|g'
17 search_deps()
19 base=`echo $1 | sed 's|/[^/]*$||'`
20 grep '#include "' <$1 | sed -e 's|.*"\([^"]*\)".*|\1|' | \
21 while read file
22 do cache=${cache_prefix}_`generate_var $file`
23 if test -f $cache; then
24 : # We already ahve this cached
25 else
26 : >$cache
27 for path in $base `echo $INCLUDE | sed 's|-I||g'`
28 do dep="$path/$file"
29 if test -f "$dep"; then
30 echo " $dep \\" >>$cache
31 search_deps $dep >>$cache
32 break
34 done
36 cat $cache
37 done
40 :>${output}.new
41 for src in $SOURCES
42 do echo "Generating dependencies for $src"
43 ext=`echo $src | sed 's|.*\.\(.*\)|\1|'`
44 if test x"$ext" = x"rc"; then
45 obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|\1.o|g"`
46 else
47 obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|\1.lo|g"`
49 echo "\$(objects)/$obj: $src \\" >>${output}.new
50 search_deps $src | sort | uniq >>${output}.new
51 case $ext in
52 c) cat >>${output}.new <<__EOF__
54 \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src -o \$@
56 __EOF__
58 cc) cat >>${output}.new <<__EOF__
60 \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src -o \$@
62 __EOF__
64 m) cat >>${output}.new <<__EOF__
66 \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src -o \$@
68 __EOF__
70 asm) cat >>${output}.new <<__EOF__
72 \$(LIBTOOL) --tag=CC --mode=compile \$(auxdir)/strip_fPIC.sh \$(NASM) $src -o \$@
74 __EOF__
76 S) cat >>${output}.new <<__EOF__
78 \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src -o \$@
80 __EOF__
82 rc) cat >>${output}.new <<__EOF__
84 \$(WINDRES) $src \$@
86 __EOF__
88 *) echo "Unknown file extension: $ext";;
89 esac
90 echo "" >>${output}.new
91 done
92 mv ${output}.new ${output}
93 rm -f ${cache_prefix}*