File: depnexe.sh

package info (click to toggle)
allegro4.2 2:4.2.0-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 24,436 kB
  • ctags: 14,714
  • sloc: ansic: 126,425; asm: 17,011; cpp: 3,846; sh: 2,120; objc: 925; makefile: 715; python: 216; pascal: 179; perl: 73
file content (84 lines) | stat: -rwxr-xr-x 2,194 bytes parent folder | download | duplicates (11)
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
44
45
46
47
48
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
80
81
82
83
84
#! /bin/sh

# Generate dependencies and rules for building simple programs
# from one source file.

missing=
symbols=
for file in .. $*; do
  if test -f $file; then
    dir=`echo $file | sed 's,/[^/]*$,,'`
    name=`echo $file | sed 's,^.*/,,' | sed 's,\.[^.]*$,,'`
    ext=`echo $file | sed 's,^.*\.,,'`
    includes=
    deps="$file"
    while test -n "$deps"; do
      newdeps=
      for dep in $deps; do
        includes1=`grep '^[ 	]*#[ 	]*include[ 	]*[a-zA-Z0-9_][a-zA-Z0-9_]*' $dep | \
          sed 's,^[ 	]*#[ 	]*include[ 	]*\([a-zA-Z0-9_]*\),\1,'`
        includes2=`grep '^[ 	]*#[ 	]*include[ 	]*".*"' $dep | \
          sed 's,^[ 	]*#[ 	]*include[ 	]*"\(.*\)",\1,'`
        if test -n "$includes1"; then
          for include in $includes1; do
            includes="$includes \$($include)"
            case "$symbols" in
	    *$include* )
	      ;;
	    * )
	      symbols="$symbols $include"
	      ;;
	    esac
          done
        fi
        if test -n "$includes2"; then
          for include in $includes2; do
	    if test -f "$dir/$include"; then
              includes="$includes \$(srcdir)/$dir/$include"
	      newdeps="$newdeps $dir/$include"
	    else
	      include=`echo $include | sed 's,[-./],_,g'`
	      includes="$includes \$($include)"
	      case "$symbols" in
	      *$include* )
	        ;;
	      * )
	        symbols="$symbols $include"
	        ;;
	      esac
	    fi
          done
        fi
      done
      deps="$newdeps"
    done

    # Program.
    echo "$dir/$name\$(EXE): \$(OBJDIR)/$name\$(OBJ)"
    echo "	\$(LINK) -o $dir/$name\$(EXE) \$(OBJDIR)/$name\$(OBJ)"
    echo ""

    # Object file.
    echo "\$(OBJDIR)/$name\$(OBJ): \$(srcdir)/$file$includes"
    if test "$ext" = "c"; then
      echo "	\$(COMPILE_PROGRAM) -c \$(srcdir)/$file -o \$(OBJDIR)/$name\$(OBJ)"
    else
      echo "	\$(COMPILE_S_PROGRAM) -c \$(srcdir)/$file -o \$(OBJDIR)/$name\$(OBJ)"
    fi
    echo ""
  elif test "$file" != ..; then
    missing="$missing $file"
  fi
done

if test -n "$symbols"; then
  echo "# Headers referred by symbols:"
  echo "#$symbols"
  echo ""
fi

if test -n "$missing"; then
  echo "# Missing source files:"
  echo "#$missing"
  echo ""
fi