comparison build-scripts/makedep.sh @ 1391:7dc446173e37

Blargle-fnargle dependencies and build rules
author Sam Lantinga <slouken@libsdl.org>
date Mon, 20 Feb 2006 12:45:51 +0000
parents 9a9b87172b4b
children a4c05c115bb7
comparison
equal deleted inserted replaced
1390:67781f790694 1391:7dc446173e37
1 #!/bin/sh 1 #!/bin/sh
2 # 2 #
3 # Generate dependencies from a list of source files 3 # Generate dependencies from a list of source files
4
5 BUILDC="\\\$\\(LIBTOOL\\) --mode=compile \\\$\\(CC\\) \\\$\\(CFLAGS\\) -c \$src -o \\\$@"
6 BUILDCC=$BUILDC
7 BUILDM=$BUILDC
8 BUILDASM="\\\$\\(LIBTOOL\\) --tag=CC --mode=compile \\\$\\(auxdir\\)/strip_fPIC.sh \\\$\\(NASM\\) \$src -o \\\$@"
4 9
5 # Check to make sure our environment variables are set 10 # Check to make sure our environment variables are set
6 if test x"$INCLUDE" = x -o x"$SOURCES" = x -o x"$objects" = x -o x"$output" = x; then 11 if test x"$INCLUDE" = x -o x"$SOURCES" = x -o x"$objects" = x -o x"$output" = x; then
7 echo "SOURCES, INCLUDE, objects, and output needs to be set" 12 echo "SOURCES, INCLUDE, objects, and output needs to be set"
8 exit 1 13 exit 1
19 base=`echo $1 | sed 's|/[^/]*$||'` 24 base=`echo $1 | sed 's|/[^/]*$||'`
20 grep '#include "' <$1 | sed -e 's|.*"\([^"]*\)".*|\1|' | \ 25 grep '#include "' <$1 | sed -e 's|.*"\([^"]*\)".*|\1|' | \
21 while read file 26 while read file
22 do cache=${cache_prefix}_`generate_var $file` 27 do cache=${cache_prefix}_`generate_var $file`
23 if test -f $cache; then 28 if test -f $cache; then
24 # We already ahve this cached 29 : # We already ahve this cached
25 if test x$2 = x; then 30 else
26 cat $cache 31 : >$cache
27 else 32 for path in $base `echo $INCLUDE | sed 's|-I||g'`
28 cat $cache >>$2 33 do dep="$path/$file"
29 fi 34 if test -f "$dep"; then
30 continue; 35 echo " $dep \\" >>$cache
36 search_deps $dep >>$cache
37 break
38 fi
39 done
31 fi 40 fi
32 for path in $base `echo $INCLUDE | sed 's|-I||g'` 41 cat $cache
33 do dep="$path/$file"
34 if test -f "$dep"; then
35 echo " $dep \\" >>$cache
36 if test x$2 = x; then
37 echo " $dep \\"
38 else
39 echo " $dep \\" >>$2
40 fi
41 search_deps $dep $cache
42 break
43 fi
44 done
45 done 42 done
46 } 43 }
47 44
48 :>${output}.new 45 :>${output}.new
49 for src in $SOURCES 46 for src in $SOURCES
52 obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|$objects/\1.lo|g"` 49 obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|$objects/\1.lo|g"`
53 echo "$obj: $src \\" >>${output}.new 50 echo "$obj: $src \\" >>${output}.new
54 search_deps $src | sort | uniq >>${output}.new 51 search_deps $src | sort | uniq >>${output}.new
55 echo "" >>${output}.new 52 echo "" >>${output}.new
56 case $ext in 53 case $ext in
57 asm) echo " \$(BUILDASM)" >>${output}.new;; 54 c) eval echo \\" $BUILDC\\" >>${output}.new;;
58 cc) echo " \$(BUILDCC)" >>${output}.new;; 55 cc) eval echo \\" $BUILDCC\\" >>${output}.new;;
59 c) echo " \$(BUILDC)" >>${output}.new;; 56 m) eval echo \\" $BUILDM\\" >>${output}.new;;
60 m) echo " \$(BUILDM)" >>${output}.new;; 57 asm) eval echo \\" $BUILDASM\\" >>${output}.new;;
61 *) echo "Unknown file extension: $ext";; 58 *) echo "Unknown file extension: $ext";;
62 esac 59 esac
63 echo "" >>${output}.new 60 echo "" >>${output}.new
64 done 61 done
65 rm -f ${cache_prefix}*
66 mv ${output}.new ${output} 62 mv ${output}.new ${output}