Make Q's

bruce.labitt at autoliv.com bruce.labitt at autoliv.com
Thu Sep 17 10:48:02 EDT 2009


Derek Atkins <warlord at MIT.EDU> wrote on 09/17/2009 10:25:44 AM:

> bruce.labitt at autoliv.com writes:
> 
> >
> > Nonetheless, allow me to ask for a critique (do I dare?) for this 
> > construct:
> >
> > CC=g++
> > CCOPTS=
> > INCLUDES=
> > DEPS=
> >
> > %.o: %.cpp $(DEPS)
> >         $(CC) -c $< $(CCOPTS) $(INCLUDES)
> >
> > This will process all .cpp files with the rule?
> 
> But it would also process all .c files with g++ which probably isn't
> what you want.
> 
> > Can I just add this?
> >
> > %.o: %.c $(DEPS)
> >         gcc -c $< $(CCOPTS) $(INCLUDES)
> 
> You could, but why not just use:
> 
> CXX=g++
> CC=gcc
> 

I am confused by your confusion... Perhaps, I've not framed the situation 
properly.
There are two files that need to be compiled with gcc, and five with g++.

One could set up two objects lists,

OBJ1=file1.o file2.o                                    <== use gcc
OBJ2=file3.o file4.o file5.o file6.o file7.o    <== use g++
SRC1=file1.c file2.c
SRC2=file3.cpp file4.cpp file5.cpp file6.cpp file7.cpp
CXX=g++
CC=gcc
CCOPTS=
INCLUDES=
DEPS=

I'm trying, quite unsucessfully, I may add, to design a rule that compiles 
things appropriately.

Might this work?

project: $(OBJS1) $(OBJ2)
        $(CXX) -o project $(OBJ1) $(OBJ2) $(LIBS)

$(OBJ1): $(SRC1) $(DEPS)
        $(CC) -c $< $(CCOPTS) $(INCLUDES)

$(OBJ2): $(SRC2) $(DEPS)
        $(CXX) -c $< $(CCOPTS) $(INCLUDES)


> ???
> 
> -derek
> 
> -- 
>        Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
>        Member, MIT Student Information Processing Board  (SIPB)
>        URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
>        warlord at MIT.EDU                        PGP key available


******************************
Neither the footer nor anything else in this E-mail is intended to or constitutes an <br>electronic signature and/or legally binding agreement in the absence of an <br>express statement or Autoliv policy and/or procedure to the contrary.<br>This E-mail and any attachments hereto are Autoliv property and may contain legally <br>privileged, confidential and/or proprietary information.<br>The recipient of this E-mail is prohibited from distributing, copying, forwarding or in any way <br>disseminating any material contained within this E-mail without prior written <br>permission from the author. If you receive this E-mail in error, please <br>immediately notify the author and delete this E-mail.  Autoliv disclaims all <br>responsibility and liability for the consequences of any person who fails to <br>abide by the terms herein. <br>
******************************



More information about the gnhlug-discuss mailing list