source: gpfs_3.1_ker2.6.20/lpp/mmfs/src/bin/depend.sh @ 195

Last change on this file since 195 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 4.1 KB
Line 
1#!/bin/ksh
2# $Id: depend.sh,v 1.10.16.2 2006/10/06 22:33:17 yuri Exp $
3## ###################################################################### ##
4##        Copyright IBM 1993                                              ##
5## ###################################################################### ##
6
7#set nonomatch
8################################################
9if [ $# -lt 2 ] || [ $# -gt 5 ]; then
10  echo 'usage: depends $DEPEND $INCLUDES [$DEFINES [$KDEFINES [$PKDEFINES]]]'
11  exit 1
12fi
13################################################
14DEPEND="$1"
15INCLUDES="$2"
16DEFINES="$3"
17KDEFINES="$4"
18PKDEFINES="$5"
19
20################################################
21CFILES=$(/bin/ls *.[cC])
22if [ "$CFILES" = "" ]; then
23  echo "No Dependencies to Check ...continuing...."
24  exit 0
25fi
26################################################
27CDEPENDS=/tmp/Dep1_$$
28DEPENDERR=/tmp/Dep2_$$
29DEPENDS=.depends
30################################################
31
32# make backup copy of makefile and remove old dependencies
33mv makefile makefile.BAK
34sed -n -e '1,/##### DEPENDENCY LINE - DO NOT DELETE #####/p' makefile.BAK > makefile
35
36# run the compiler with option to generate dependencies
37# output goes into $CDEPENDS, error messages go into $DEPENDERR
38if [[ $DEFINES = *GPFS_LINUX* ]]
39then
40   rm -f *.d >/dev/null 2>&1
41   $DEPEND -w -MD -E >/dev/null $DEFINES $INCLUDES $CFILES 2> $DEPENDERR
42   echo "" > $CDEPENDS
43   cat *.d >> $CDEPENDS
44   rm -f *.d >/dev/null 2>&1
45else
46   rm -f *.u >/dev/null 2>&1
47   $DEPEND -qonce -M -E >/dev/null $DEFINES $INCLUDES $CFILES 2> $DEPENDERR
48   echo "" > $CDEPENDS
49   cat *.u >> $CDEPENDS
50   rm -f *.u >/dev/null 2>&1
51fi
52
53# show error messages, but filter out certain uninteresting messages
54fgrep -v -e 'unknown directive == "#error' \
55         -e 'Option lm is not valid' \
56         -e 'Suboption compat is not valid for option langlvl' $DEPENDERR
57
58# Copy output to $DEPENDS
59"cp" $CDEPENDS $DEPENDS
60
61# remove temporary output files
62for i in $CDEPENDS $DEPENDERR
63do
64  rm -f $i $i.bak
65done
66
67# If $KDEFINES is non-empty, certain files need to be compiled
68# twice: once without and once with $KDEFINES to generate .ko file to
69# be linked into kernel code.  If this is the case, we need to generate
70# dependencies for the .ko files.
71if [[ "$KDEFINES" != "" ]]
72then
73  # generate dependencies with $KDEFINES
74  if [[ $DEFINES = *GPFS_LINUX* ]]; then
75    rm -f *.d >/dev/null 2>&1
76    $DEPEND -w -MD -E >/dev/null $KDEFINES $INCLUDES $CFILES 2> $DEPENDERR
77    echo "" > $CDEPENDS
78    cat *.d >> $CDEPENDS
79    rm -f *.d >/dev/null 2>&1
80  else
81    rm -f *.u >/dev/null 2>&1
82    $DEPEND -qonce -M -E >/dev/null $KDEFINES $INCLUDES $CFILES 2> $DEPENDERR
83    echo "" > $CDEPENDS
84    cat *.u >> $CDEPENDS
85    rm -f *.u >/dev/null 2>&1
86  fi
87
88  # show error messages, but filter out certain uninteresting messages
89  fgrep -v -e 'unknown directive == "#error' \
90           -e 'Suboption compat is not valid for option langlvl' $DEPENDERR
91
92  # Append output to $DEPENDS, but change ".o:" to ".ko:"
93  sed -e 's/\.o:/.ko:/g' $CDEPENDS >> $DEPENDS
94
95  # remove temporary output files
96  for i in $CDEPENDS $DEPENDERR
97  do
98    rm -f $i $i.bak
99  done
100fi
101
102# On Linux, if $PKDEFINES is non-empty, also generate dependencies
103# for .pko files.
104if [[ "$PKDEFINES" != "" ]]
105then
106  # generate dependencies with $KDEFINES and $PKDEFINES
107  if [[ $DEFINES = *GPFS_LINUX* ]]; then
108    rm -f *.d >/dev/null 2>&1
109    $DEPEND -w -MD -E >/dev/null $KDEFINES $PKDEFINES $INCLUDES $CFILES 2> $DEPENDERR
110    echo "" > $CDEPENDS
111    cat *.d >> $CDEPENDS
112    rm -f *.d >/dev/null 2>&1
113  else
114    rm -f *.u >/dev/null 2>&1
115    $DEPEND -qonce -M -E >/dev/null $PKDEFINES $INCLUDES $CFILES 2> $DEPENDERR
116    echo "" > $CDEPENDS
117    cat *.u >> $CDEPENDS
118    rm -f *.u >/dev/null 2>&1
119  fi
120
121  # show error messages, but filter out certain uninteresting messages
122  fgrep -v -e 'unknown directive == "#error' \
123           -e 'Suboption compat is not valid for option langlvl' $DEPENDERR
124
125  # Append output to $DEPENDS, but change ".o:" to ".pko:"
126  sed -e 's/\.o:/.pko:/g' $CDEPENDS >> $DEPENDS
127
128  # remove temporary output files
129  for i in $CDEPENDS $DEPENDERR
130  do
131    rm -f $i $i.bak
132  done
133fi
134
135# append all the dependencies to the makefile
136cat $DEPENDS >> makefile
Note: See TracBrowser for help on using the repository browser.