annotate build-scripts/makedep.sh @ 1392:4a203b442650

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