make-w32
[Top][All Lists]
Advanced

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

Re: Compiling multiple files with one command


From: Michael Mounteney
Subject: Re: Compiling multiple files with one command
Date: Fri, 20 Jun 2003 18:44:15 +1000
User-agent: KMail/1.5

<< [...] There is some efficiency to be had by compiling more than one file 
using a single instantiation of the compiler.

Is there any way to express this? >>

This solution is not tested at all but it is based on near memory of something 
I did myself about three weeks ago.  I had to abandon my attempt as the 
compiler I was using (Watcom C++ 11.0b) grinds to a halt when it compiles 
more than about 250 sources in one run.

------------------------------

sources := file1.cpp file2.cpp

objects  :=  $(notdir $(addsuffix .obj,$(basename $(sources))))

common: $(OBJDIR) $(objects)

TEMPORARY=/tmp/what.cni
# This next line is cunning, and dirty.
# It forces the creation and initialisation of an empty file.
$(shell echo "" >$(TEMPORARY))

%.obj: %.cpp
        @$(ECHO) "Compilation file set: $?"
# Don't attempt to compile now, just save the name.
        @$(ECHO) $(@:.obj=.cpp) >>$(TEMPORARY)

a.out:
# First, compile all the saved up names.
        $(CC) $(CPPFLAGS) $(CFLAGS) -c $(shell cat $(TEMPORARY))
# Then link.
        $(CC) $(CPPFLAGS) $(CFLAGS) -o a.out $(sources:.cpp=.obj)

$(OBJDIR):
        @$(ECHO) "Creating directory [$(OBJDIR)]"
        @$(MKDIR) $@

VPATH = src;$(OBJDIR)

-----------------------------------


-- 
Michael Mounteney,
technical director,
Landcroft Computing Ltd.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]