> How do I pass a compiler switch into a make file?
In your Makefile, you code MACRO definition lines that specify the flags
CFLAGS = <flags for the C compilation units>
CPPFLAGS = <flags for the C++ compilation units>
GNU make exposes a number of other macros, so check the documentation for
macros suitable to your needs.
--
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
---------- Slackware - Because I know what I'm doing. ------
Lew Pitcher <lpit...@teksavvy.com> writes:
> On June 16, 2009 08:59, in comp.os.linux.development.apps, General
> Schvantzkoph (schvan...@yahoo.com) wrote:
>
>> How do I pass a compiler switch into a make file?
>
> In your Makefile, you code MACRO definition lines that specify the flags
>
> CFLAGS = <flags for the C compilation units>
> CPPFLAGS = <flags for the C++ compilation units>
More precisely:
CXXFLAGS = <extra flags to give the C++ compiler>,
whereas
CPPFLAGS = <extra flags to give the C preprocessor and programs that
use it>
I found this by looking at the info files for make.
Most of the time, this is a distinction without a difference. The only
time this would matter is when you want the C preprocessor to have
different flags than the C++ compiler.
--
Art Werschulz (8-{)} "Metaphors be with you." -- bumper sticker
GCS/M (GAT): d? -p+ c++ l++ u+ P++ e--- m* s n+ h f g+ w+ t+ r-
Net: a...@dsm.fordham.edu http://www.dsm.fordham.edu/~agw
Phone: Fordham U. (212) 636-6325, Columbia U. (212) 939-7060
> Hi.
>
> Lew Pitcher <lpit...@teksavvy.com> writes:
>
>> On June 16, 2009 08:59, in comp.os.linux.development.apps, General
>> Schvantzkoph (schvan...@yahoo.com) wrote:
>>
>>> How do I pass a compiler switch into a make file?
>>
>> In your Makefile, you code MACRO definition lines that specify the flags
>>
>> CFLAGS = <flags for the C compilation units>
>> CPPFLAGS = <flags for the C++ compilation units>
>
> More precisely:
> CXXFLAGS = <extra flags to give the C++ compiler>,
> whereas
> CPPFLAGS = <extra flags to give the C preprocessor and programs that
> use it>
D*mn, I always get those two mixed up. For some reason, I associate CPP
to "C Plus Plus" rather than "C Pre Processor"
Thanks for the correction
This sounds like the right thing. To pass the arguments args I would do
setenv args +define+fpga
and then have the following in my make file
foo: foo.v
vlog $$args foo.v
No, that's not idiomatic at all. Usually you have the following in your
makefile:
foo: foo.v
vlog $(VLOG_FLAGS) foo.v
And then run make like this:
$ make VLOG_FLAGS="+define+fpga"
-- Sergei.
Is there a way to set a default value for the flags in the Makefile which
would be overwritten by the command line argument?
Sure,
VLOG_FLAGS = whatever
in the Makefile will do. Command line always overrides what's written
in the Makefile.
Why don't you just RTFM:
<http://www.gnu.org/software/make/manual/make.html#Using-Variables>
and
<http://www.gnu.org/software/make/manual/make.html#Overriding>
in particular.
-- Sergei.
> Is there a way to set a default value for the flags in the Makefile which
> would be overwritten by the command line argument?
RTFM. Here's a quick example that you might find enlightening:
bash-3.2$ make clean a
rm -f a.o b.o c.o
cc -pg -Dbubba -c -o b.o b.c
cc -pg -Dbubba -c -o c.o c.c
cc -pg -Dbubba a.c b.o c.o -o a
bash-3.2$ make clean a CFLAGS=-g
rm -f a.o b.o c.o
cc -g -Dbubba -c -o b.o b.c
cc -g -Dbubba -c -o c.o c.c
cc -g -Dbubba a.c b.o c.o -o a
bash-3.2$ make clean a CFLAGS=-g CPPFLAGS=-Dfoo
rm -f a.o b.o c.o
cc -g -Dfoo -c -o b.o b.c
cc -g -Dfoo -c -o c.o c.c
cc -g -Dfoo a.c b.o c.o -o a
bash-3.2$ cat Makefile
CPPFLAGS = -Dbubba
CFLAGS = -pg
a: b.o c.o
clean:
rm -f a.o b.o c.o
Thanks to all