🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #162

Long argument lines generated by Make

#162
From: Skip Montanaro
Date: Mon, 27 Jul 1992 16:44
42 lines
2395 bytes
I have a long list of filenames generated by the Make automatic variable $?
(all dependency files newer than the target) that I'd like to feed to a
depend file generator script. Unfortunately, on many (most? all?) System V
machines the space for environment variables and command line args is too
small.

We have three ways of generating this depend target, either link to a
production version (the fastest), perform an update of the local version
(medium fast), or create one from scratch (excruciatingly slow on machines
whose compiler doesn't understand "-M"). The actions for the depend target
look roughly like this (we use GNU make):

%.depend : GNUmakefile and lots of other files
	if [ we can link to the production version ] ; then \
	    ln -s $(production)/$@ $@ ; \
	elif [ $? is made up of just .c files ] ; then \
	    depend -u -f $@ $? ; \
	else \
	    depend -f $@ $(filter %.c,$^) ; \
	fi

Our System V machines sometimes give us "Arg list too long" errors on the
above command. The test arg in the elif branch and the two depend commands
can each have lots of files, thus combining to making the whole if statement
too long to execute (I think). Both of the individual depend commands are
short enough to run.

I'd like to use xargs to generate a series of depend update commands ("xargs
depend -u -f $@"), but I can't think of any way to generate stdin for xargs
that doesn't involve putting most or all of the $? contents on the command
line (using a series of echo commands or a for loop, for instance),
consequently generating an if statement that is too long.

Short of breaking up some of the libraries we build into smaller chunks
(which isn't really a viable option), can anybody see a way to get around
the small env/arglist space on System V machines for this problem?

Thanks,

--
Skip (montanaro@crd.ge.com)
Technical Details
Message-ID: <MONTNARO.92Jul27114410@ausable.crd.ge.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!crdgw1!rdsunx.crd.ge.com!rdsunx!montnaro

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!crdgw1!rdsunx.crd.ge.com!rdsunx!montnaro
From: montnaro@ausable.crd.ge.com (Skip Montanaro)
Newsgroups: comp.unix.shell
Subject: Long argument lines generated by Make
Message-ID: <MONTNARO.92Jul27114410@ausable.crd.ge.com>
Date: 27 Jul 92 16:44:10 GMT
Sender: usenet@crd.ge.com (Required for NNTP)
Reply-To: montanaro@crd.ge.com (Skip Montanaro)
Distribution: comp
Organization: GE Corporate Research & Development, Schenectady, NY
Lines: 42
Nntp-Posting-Host: ausable.crd.ge.com