📄 mdepend.cpp
字号:
XCOMM!/bin/shXCOMMXCOMM $TOG: mdepend.cpp /main/13 1997/06/20 21:12:18 kaleb $XCOMMXCOMM Do the equivalent of the 'makedepend' program, but do it right.XCOMMXCOMM Usage:XCOMMXCOMM makedepend [cpp-flags] [-w width] [-s magic-string] [-f makefile]XCOMM [-o object-suffix]XCOMMXCOMM Notes:XCOMMXCOMM The C compiler used can be overridden with the environmentXCOMM variable "CC".XCOMMXCOMM The "-v" switch of the "makedepend" program is not supported.XCOMMXCOMMXCOMM This script shouldXCOMM work on both USG and BSD systems. However, when System V.4 comes out,XCOMM USG users will probably have to change "silent" to "-s" instead ofXCOMM "-" (at least, that is what the documentation implies).XCOMMXCOMM $XFree86: xc/config/util/mdepend.cpp,v 3.1.8.1 1997/06/29 08:43:27 dawes Exp $XCOMMCC=PREPROCsilent='-'TMP=/tmp/mdep$$CPPCMD=${TMP}aDEPENDLINES=${TMP}bTMPMAKEFILE=${TMP}cMAGICLINE=${TMP}dARGS=${TMP}etrap "rm -f ${TMP}*; exit 1" 1 2 15trap "rm -f ${TMP}*; exit 0" 1 2 13echo " \c" > $CPPCMDif [ `wc -c < $CPPCMD` -eq 1 ]then c="\c" n=else c= n="-n"fiecho $n "$c" >$ARGSfiles=makefile=magic_string='# DO NOT DELETE'objsuffix='.o'width=78endmarker=""verbose=nappend=nwhile [ $# != 0 ]do if [ "$endmarker"x != x ] && [ "$endmarker" = "$1" ]; then endmarker="" else case "$1" in -D*|-I*) echo $n " '$1'$c" >> $ARGS ;; -g|-O) # ignore so we can just pass $(CFLAGS) in ;; *) if [ "$endmarker"x = x ]; then case "$1" in -w) width="$2" shift ;; -s) magic_string="$2" shift ;; -f*) if [ "$1" = "-f-" ]; then makefile="-" else makefile="$2" shift fi ;; -o) objsuffix="$2" shift ;; --*) echo "$1" | sed 's/^\-\-//' >${TMP}end endmarker="`cat ${TMP}end`" rm -f ${TMP}end if [ "$endmarker"x = x ]; then endmarker="--" fi ;; -v) verbose="y" ;; -a) append="y" ;; -cc) CC="$2" shift ;; -*) echo "Unknown option '$1' ignored" 1>&2 ;; *) files="$files $1" ;; esac fi ;; esac fi shiftdoneecho ' $*' >> $ARGSecho "#!/bin/sh" > $CPPCMDecho "exec $CC `cat $ARGS`" >> $CPPCMDchmod +x $CPPCMDrm $ARGScase "$makefile" in '') if [ -r makefile ] then makefile=makefile elif [ -r Makefile ] then makefile=Makefile else echo 'no makefile or Makefile found' 1>&2 exit 1 fi ;; -) makefile=$TMPMAKEFILE ;;esacif [ "$verbose"x = "y"x ]; then cat $CPPCMDfiecho '' > $DEPENDLINESfor i in $filesdo $CPPCMD $i \ | sed -n "/^#/s;^;$i ;p"done \ | sed -e 's|/[^/.][^/]*/\.\.||g' -e 's|/\.[^.][^/]*/\.\.||g' \ -e 's|"||g' -e 's| \./| |' \ | awk '{ if ($1 != $4 && $2 != "#ident" && $2 != "#pragma") { ofile = substr ($1, 1, length ($1) - 2) "'"$objsuffix"'" print ofile, $4 } }' \ | sort -u \ | awk ' { newrec = rec " " $2 if ($1 != old1) { old1 = $1 if (rec != "") print rec rec = $1 ": " $2 } else if (length (newrec) > '"$width"') { print rec rec = $1 ": " $2 } else rec = newrec } END \ { if (rec != "") print rec }' \ | egrep -v '^[^:]*:[ ]*$' >> $DEPENDLINEStrap "" 1 2 13 15 # Now we are committedcase "$makefile" in $TMPMAKEFILE) ;; *) rm -f $makefile.bak cp $makefile $makefile.bak echo "Appending dependencies to $makefile" ;;esacXCOMMXCOMM If not -a, append the magic string and a blank line so thatXCOMM /^$magic_string/+1,\$d can be used to delete everything from afterXCOMM the magic string to the end of the file. Then, append a blankXCOMM line again and then the dependencies.XCOMMif [ "$append" = "n" ]then cat >> $makefile << END_OF_APPEND$magic_stringEND_OF_APPEND ed $silent $makefile << END_OF_ED_SCRIPT/^$magic_string/+1,\$dwqEND_OF_ED_SCRIPT echo '' >>$makefileficat $DEPENDLINES >>$makefilecase "$makefile" in $TMPMAKEFILE) cat $TMPMAKEFILE ;;esacrm -f ${TMP}*exit 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -