Unix Programming - Passing options to gcc with make?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > October 2007 > Passing options to gcc with make?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Passing options to gcc with make?
desktop

2007-10-02, 7:33 am

In a makefile I have:

main: main.cpp
g++ -o main -D bob main.cpp

but is there someway to either set or unset 'bob' when running make, like:

make -D bob

(which does not work)

I know that I could just make another target without the '-D bob'
option, but would like to know if there is a way.
Andrei Voropaev

2007-10-02, 7:33 am

On 2007-10-02, desktop <fff@sss.com> wrote:
> In a makefile I have:
>
> main: main.cpp
> g++ -o main -D bob main.cpp
>
> but is there someway to either set or unset 'bob' when running make, like:
>
> make -D bob
>
> (which does not work)


Usually people use environment variables and/or make variales. For
example if you write your command

g++ -o main $(MORE_FLAGS) main.cpp

then you can call make as

make MORE_FLAGS='-D bob'

There are even some "standart" variables like CFLAGS, LDFLAGS etc. Read
`info make`.


--
Minds, like parachutes, function best when open
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com