tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: (b)make: generating multiple targets at once



On Fri, Oct 25, 2019 at 04:42:23PM +0200, Edgar Fu? wrote:
 > May be I need to re-phrase what I'm seeking. Think of a compiler able to 
 > efficiently compile several source files (to individual object files) 
 > in one invocation (even skipping those which are up-to-date anyway) 
 > but needing ages to start up. Once I decide to start the beast, It doesn't 
 > matter if I give it more input than needed, but I never want to start it 
 > in case I can get away without.

Ah, that's a different thing, and not something make was ever really
intended to support.

It can be done, but not tidily. For example, one might do something
like this:

   --------
SRCS=foo.c bar.c ...
SRCSTAMPS=$(SRCS:.c=.stamp)
OBJS=$(SRCS:.c=.o)

all: $(PROG)

$(PROG): $(OBJS)
	$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $(PROG)

$(OBJS): .stamp.build

.stamp.build: .buildlist
	$(CC) $(CFLAGS) -c `cat .buildlist`
.for S in $(SRCS)
	touch -r $(S:R).o $(S:R).stamp
.endfor
	touch $@

.buildlist: $(SRCSTAMPS)

.for S in $(SRCS)
$(S:R).stamp: $(S)
	echo $(S) >> .buildlist
.endfor

.BEGIN:
	echo -n > .buildlist
   --------

in which the sources that need to be rebuilt are listed out first and
then anything that gets listed gets recompiled.

But you'll note that this involves lying to make about the actual data
flow, and in the long run that's rarely a good idea.

I remember that back in the DOS era there were at least a couple
variant versions of make that included extensions for batching
commands (within make, not by hand like the above), but I don't
remember anything about any of them. I suspect the limited demand for
the feature dried up around the time parallel builds became
useful. :-/

It would probably not be that hard to teach bmake to batch commands;
the hardest part would likely be to figure out a non-awful makefile
syntax.

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index