9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Boyd Roberts <boyd@strakt.com>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] correcting old failures, and NJ vs MA
Date: Thu, 11 Oct 2001 17:26:55 +0200	[thread overview]
Message-ID: <3BC5BA3F.B7BC29D3@strakt.com> (raw)
In-Reply-To: <006501c15261$226a9440$8e8b0241@sumt1.nj.home.com>

david presotto wrote:
> I'm happy just composing du -a, grep, sed, and `{}.

#!/bin/rc

dot=`{pwd}
incs=-I^($dot/Plan9 $dot/Include)
cpp=(pcc -I/sys/include $incs -E)
line='^#line [0-9]+ "'
mkfile=mkfile
mkdeps=mkdeps
except=$dot/Plan9/except

# refuse to deal with unecessary/replaced files/directories
fn except {
	echo $1 | grep -s -f $except && echo $1: ignored >[1=2]
}

# generate a prototype mkfile
fn mkproto {
	echo '</$objtype/mkfile'
	echo 'CC=$CC -p'
	echo 'CFLAGS='$"incs
	echo '<'$mkdeps
	echo '</sys/src/cmd/mkone'
	echo '</sys/src/cmd/mklib'
	echo '</sys/src/cmd/mksyslib'
}

# indent mkfile dependancies
fn mkindent {
	tr ' ' '
' | sed -e 's/$/ \\/' -e '2,$s/^/	/' -e '$s/ \\$//'
}

for (d in `{du | awk '{print substr($2, 3)}'}) {
	if (! except $d) @{
		cd $d
		echo $d $all >[1=2]

		rm -f $mkdeps

		all=`{ls *.c >[2] /dev/null}

		for (c in $all) {
			if (! except $d/$c) {
				o=`{basename $c .c}^'.$O'
				ofiles=($ofiles $o)
			}
		}
		
		if (! ~ $ofiles '') {
			echo 'OFILES= '$"ofiles | mkindent
			ofiles=()
		} >> $mkdeps

		for (c in $all) {
			if (! except $d/$c) {
				echo $c >[1=2]
	
				o=`{basename $c .c}^'.$O'
				hfiles=()
	
				for (h in `{$cpp $c | sed -n -e 's;'$line'(.*\.h)"$;\1;p' | sort -u}) {
					switch ($h) {
					case $d/*
						hfiles=($hfiles `{basename $h})
	
					case $dot/*
						hfiles=($hfiles $h)
					}
				}
	
				if (! ~ $hfiles '') {
					{
						echo
						echo $o': '$"hfiles | mkindent
				} >> $mkdeps

				hfiles=()
				}
			}
		}

		if (test -f $mkdeps) {
			if (! test -f $mkfile) {
				mkproto > $mkfile
			}
		}	
	}
}


  reply	other threads:[~2001-10-11 15:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-10 13:04 presotto
2001-10-11  9:10 ` Thomas Bushnell, BSG
2001-10-11 14:29   ` david presotto
2001-10-11 15:26     ` Boyd Roberts [this message]
2001-10-11 15:54       ` andrey mirtchovski
  -- strict thread matches above, loose matches on Subject: below --
2001-10-11 11:39 forsyth
2001-10-09 21:51 bwc
2001-10-09 21:44 forsyth
2001-10-09 17:43 anothy
2001-10-10  8:56 ` Thomas Bushnell, BSG
2001-10-10  9:16   ` Boyd Roberts
2001-10-11  4:27   ` Alexander Viro
2001-10-11  9:11     ` Thomas Bushnell, BSG

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3BC5BA3F.B7BC29D3@strakt.com \
    --to=boyd@strakt.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).