public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Template
       [not found] <1048847584.6083.ezmlm@gcc.gnu.org>
@ 2003-03-29  7:39 ` Eduardo Cesar Cabrera Flores
  2003-03-31 15:07   ` Template Matthias Oltmanns
  0 siblings, 1 reply; 4+ messages in thread
From: Eduardo Cesar Cabrera Flores @ 2003-03-29  7:39 UTC (permalink / raw)
  To: Mathias.Oltmanns.Oltmanns; +Cc: gcc-help


compiling that way a template example the compiler compiles the whole
program not only the main

>g++ -o testCounter.o -c -frepo -fno-implicit-templates testCounter.cc

>g++ -o testCounter testCounter.o
>collect: recompiling testCounter.cc
>collect: relinking

i'm trying to compile with a makefile to compile only those files that
were modified!

Any idea how to do this with a makefile??

cafe







^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Template
  2003-03-29  7:39 ` Template Eduardo Cesar Cabrera Flores
@ 2003-03-31 15:07   ` Matthias Oltmanns
  2003-04-07 18:19     ` Template Eduardo Cesar Cabrera Flores
  0 siblings, 1 reply; 4+ messages in thread
From: Matthias Oltmanns @ 2003-03-31 15:07 UTC (permalink / raw)
  To: Eduardo Cesar Cabrera Flores; +Cc: gcc-help

Am Fre, 2003-03-28 um 19.15 schrieb Eduardo Cesar Cabrera Flores:
> 
> compiling that way a template example the compiler compiles the whole
> program not only the main
> 
> >g++ -o testCounter.o -c -frepo -fno-implicit-templates testCounter.cc
> 
> >g++ -o testCounter testCounter.o
> >collect: recompiling testCounter.cc
> >collect: relinking
> 
> i'm trying to compile with a makefile to compile only those files that
> were modified!
> 
> Any idea how to do this with a makefile??
> 

Hi Eduardo, 

i'm not sure if you asking for "How to write a makefile". If so i would
suggest to read first info-pages via "info make".

The small example i send, used already two phases of building. First
compilation of (one) source file. In more real-life projects there are
more source files to compile. Note: you must not compile the template
definition files, even if they end with .cc (or .C). You should treat
template definition files as header files (included from your template
declaration files).
The second phase is linking the program, as indicated by the second run
of g++ in the example.

With some knowledge about makefiles it should be straigt forward to
compile your sources (with templates).

If i miss your point ... sorry. Don't heasetate to ask again.

cu
Matthias

> cafe
> 
> 
> 
> 
> 
> 
-- 
Matthias Oltmanns

Tel: 04421-1543-274
mail: Mathias.Oltmanns.Oltmanns@sysde.eads.net

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Template
  2003-03-31 15:07   ` Template Matthias Oltmanns
@ 2003-04-07 18:19     ` Eduardo Cesar Cabrera Flores
  2003-04-08  8:10       ` Template Matthias Oltmanns
  0 siblings, 1 reply; 4+ messages in thread
From: Eduardo Cesar Cabrera Flores @ 2003-04-07 18:19 UTC (permalink / raw)
  To: Matthias Oltmanns; +Cc: gcc-help



On 31 Mar 2003, Matthias Oltmanns wrote:

> Hi Eduardo,
>
> i'm not sure if you asking for "How to write a makefile". If so i would
> suggest to read first info-pages via "info make".

nop, i've already known how to do that!

>
> The small example i send, used already two phases of building. First
> compilation of (one) source file. In more real-life projects there are
> more source files to compile. Note: you must not compile the template
> definition files, even if they end with .cc (or .C). You should treat
> template definition files as header files (included from your template
> declaration files).
> The second phase is linking the program, as indicated by the second run
> of g++ in the example.
>
> With some knowledge about makefiles it should be straigt forward to
> compile your sources (with templates).
>

If i got a lot of sources definition files (.C or .cc or .cpp) some of
them are template definitions and some aren't. i have to compile with "-c"
option those files that do not have any template, and then link all
together with the second phase?

v.gr.
	Main.C Base.C Base.h Derived.C Derived.h Derived2.C Derived2.h
	Template.C Template.h Template2.C Template2.h

How do i compile with a makefile to only compile those files that were
modified & not to compile the whole project properly with a makefile?


cafe


> If i miss your point ... sorry. Don't heasetate to ask again.
>
> cu
> Matthias
>
> > cafe
> >
> >
> >
> >
> >
> >
> --
> Matthias Oltmanns
>
> Tel: 04421-1543-274
> mail: Mathias.Oltmanns.Oltmanns@sysde.eads.net
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Template
  2003-04-07 18:19     ` Template Eduardo Cesar Cabrera Flores
@ 2003-04-08  8:10       ` Matthias Oltmanns
  0 siblings, 0 replies; 4+ messages in thread
From: Matthias Oltmanns @ 2003-04-08  8:10 UTC (permalink / raw)
  To: Eduardo Cesar Cabrera Flores; +Cc: gcc-help

Am Mon, 2003-04-07 um 15.18 schrieb Eduardo Cesar Cabrera Flores:
 
 
> >
> > i'm not sure if you asking for "How to write a makefile". If so i would
> > suggest to read first info-pages via "info make".
> 
> nop, i've already known how to do that!

Ok.

> 
> If i got a lot of sources definition files (.C or .cc or .cpp) some of
> them are template definitions and some aren't. i have to compile with "-c"
> option those files that do not have any template, and then link all
> together with the second phase?
> 
> v.gr.
> 	Main.C Base.C Base.h Derived.C Derived.h Derived2.C Derived2.h
> 	Template.C Template.h Template2.C Template2.h
> 
> How do i compile with a makefile to only compile those files that were
> modified & not to compile the whole project properly with a makefile?
> 

I'm sure there are many ways to solve this.

One of them i would go is:

# Your main executable depends on the following source files
SRC = Main.C Base.C Derived.C Derived2.C
OBJ = $(SRC:.C=.o)

# your main target
all : $(OBJ)
	$(LINK.cc) -o <name_of_exe> $+ $(LIBS)

# how to compile
%.o: %.C
	$(COMPILE.cc) $(CPPINCLUDES) -o $@ $<

## make dependencies based on header files
DEPFILE = Makefile.dep
DEPEND.cc = $(filter-out -c, $(COMPILE.cc)) -MM -MG

depend.removed:
	-@$(RM) -r $(DEPFILE)

depend.%o: %.C
	@$(DEPEND.cc) $(CPPINCLUDES) -o $(subst depend.,,$@) $< >> $(DEPFILE)

depend: depend.removed $(addprefix depend., $(OBJ))

-include $(DEPFILE)

hope that helps

cu
Matthias

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-04-08  8:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1048847584.6083.ezmlm@gcc.gnu.org>
2003-03-29  7:39 ` Template Eduardo Cesar Cabrera Flores
2003-03-31 15:07   ` Template Matthias Oltmanns
2003-04-07 18:19     ` Template Eduardo Cesar Cabrera Flores
2003-04-08  8:10       ` Template Matthias Oltmanns

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 read-only IMAP folder(s) and NNTP newsgroup(s).