]> git.sesse.net Git - rdpsrv/blob - Xserver/config/util/gccmdep.cpp
Support RDP5 logon packets.
[rdpsrv] / Xserver / config / util / gccmdep.cpp
1 XCOMM!/bin/sh
2
3 XCOMM
4 XCOMM makedepend which uses 'gcc -M'
5 XCOMM
6 XCOMM $XFree86: xc/config/util/gccmdep.cpp,v 3.3 1996/02/25 01:16:15 dawes Exp $
7 XCOMM
8 XCOMM Based on mdepend.cpp and code supplied by Hongjiu Lu <hjl@nynexst.com>
9 XCOMM
10
11 TMP=/tmp/mdep$$
12 CC=CCCMD
13 RM=RMCMD
14 LN=LNCMD
15 MV=MVCMD
16
17 trap "$RM ${TMP}*; exit 1" 1 2 15
18 trap "$RM ${TMP}*; exit 0" 1 2 13
19
20 files=
21 makefile=
22 endmarker=
23 magic_string='# DO NOT DELETE'
24 append=n
25 args=
26 asmfiles=
27
28 while [ $# != 0 ]; do
29     if [ "$endmarker"x != x -a "$endmarker" = "$1" ]; then
30         endmarker=
31     else
32         case "$1" in
33             -D*|-I*)
34                 args="$args '$1'"
35                 ;;
36             -g|-o)
37                 ;;
38             *)
39                 if [ "$endmarker"x = x ]; then
40                     case $1 in
41 XCOMM ignore these flags
42                         -w|-o|-cc)
43                             shift
44                             ;;
45                         -v)
46                             ;;
47                         -s)
48                             magic_string="$2"
49                             shift
50                             ;;
51                         -f-)
52                             makefile="-"
53                             ;;
54                         -f)
55                             makefile="$2"
56                             shift
57                             ;;
58                         --*)
59                             endmarker=`echo $1 | sed 's/^\-\-//'`
60                             if [ "$endmarker"x = x ]; then
61                                 endmarker="--"
62                             fi
63                             ;;
64                         -a)
65                             append=y
66                             ;;
67                         -*)
68                             echo "Unknown option '$1' ignored" 1>&2
69                             ;;
70                         *)
71                             files="$files $1"
72                             ;;
73                     esac
74                 fi
75                 ;;
76         esac
77     fi
78     shift
79 done
80
81 if [ x"$files" = x ]; then
82 XCOMM Nothing to do
83     exit 0
84 fi
85
86 case "$makefile" in
87     '')
88         if [ -r makefile ]; then
89             makefile=makefile
90         elif [ -r Makefile ]; then
91             makefile=Makefile
92         else
93             echo 'no makefile or Makefile found' 1>&2
94             exit 1
95         fi
96         ;;
97 esac
98
99 if [ X"$makefile" != X- ]; then
100     if [ x"$append" = xn ]; then
101         sed -e "/^$magic_string/,\$d" < $makefile > $TMP
102         echo "$magic_string" >> $TMP
103     else
104         cp $makefile $TMP
105     fi
106 fi
107
108 XCOMM need to link .s files to .S
109 for i in $files; do
110     case $i in
111         *.s)
112             dir=`dirname $i`
113             base=`basename $i .s`
114             (cd $dir; $RM ${base}.S; $LN ${base}.s ${base}.S)
115             asmfiles="$asmfiles ${base}.S"
116             ;;
117     esac
118 done
119
120 CMD="$CC -M $args `echo $files | sed -e 's,\.s$,\.S,g' -e 's,\.s ,\.S ,g'` | \
121         sed -e 's,\.S$,\.s,g' -e 's,\.S ,\.s ,g'"
122 if [ X"$makefile" != X- ]; then
123     CMD="$CMD >> $TMP"
124 fi
125 eval $CMD
126 if [ X"$makefile" != X- ]; then
127     $RM ${makefile}.bak
128     $MV $makefile ${makefile}.bak
129     $MV $TMP $makefile
130 fi
131
132 if [ x"$asmfiles" != x ]; then
133     $RM $asmfiles
134 fi
135 $RM ${TMP}*
136 exit 0