Make Q's

Derek Atkins warlord at MIT.EDU
Thu Sep 17 10:25:44 EDT 2009


bruce.labitt at autoliv.com writes:

>> On Wed, 2009-09-16 at 23:28 -0400, Kevin D. Clark wrote:
>> > Look, I could write a big writeup here, giving you a complete example
>> > of a Makefile that is similar to what I know you are looking for, but
>> > in actuality let me just tell you that I happen to be a big fan of the
>> > GNU Make manual.  I think that in 20 minutes of skimming you'll be
>> > well on your way.
>> 
>> Lloyd Kvam
>> I also like the GNU Make manual, but I found it vary hard to use when
>> first learning make.  Once you have a bit of feel for what you are doing
>> the manual is clear and concise.
>> http://www.gnu.org/software/make/
>> 
>
> It is hard to 'skim' 182 pages. :0
>
> 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

???

-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


More information about the gnhlug-discuss mailing list