[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
-f <filename> incorrectly implying a make *of* "filename"?
From: |
Stan Sieler |
Subject: |
-f <filename> incorrectly implying a make *of* "filename"? |
Date: |
Thu, 12 May 2005 10:36:56 -0700 |
Hi,
My apologies if this is a case of "user misunderstanding"...
I scanned the bug list for gmake, and various documentation,
but didn't see this mentioned.
(Using GNU Make 3.80)
It seems that gmake incorrectly handles "-f <filename>" by
first acting as if I had typed "gmake <filename>".
E.g, assume I have a makefile (an ASCII file of make rules),
called "foo" (without quotes). Normally, I'd say:
gmake -f foo
That works fine ... unless I happen to also have
a file called "foo.c" (or "foo.cc", etc.).
In that case, "gmake -f foo" acts as though I'd done:
gmake foo
followed by a run of gmake with "foo" as the makefile.
To me, that's radically different than what the man page
leads me to think should happen.
And, of course, if "foo.c" doesn't happen to really be
a compilable C sourc code, the "gmake foo" fails.
If it *is* compilable/linkable, the "second" gmake fails
because "foo" doesn't have nice ASCII rules in it ...
it's got compiled code instead.
The man page for gmake documents "-f" as saying that
it specifies a "makefile". "makefile" is documented as:
To prepare to use gmake, you must write a file called the
makefile that describes the relationships among files in
your program [...]
I.e., the man page clearly implies that the makefile is not
something that gets compiled and executed, but a file with
information/rules (not executable bits) in it. Given that
definition, it seems like having "-f" try to compile the
makefile first is just wrong.
I stumbled over this because I was switching from HP-UX's make
(which doesn't act this way) to gmake, and I had several
different makefiles (one for each architecture/compiler combination
that I was making my application for).
I had: Makefile.gcc for compiling with gcc, Makefile.gcc.11 for
compiling with gcc -march=1.1 (on PA-RISC),
Makefile.cc for compiling with HP's C ...
and that's the one that triggered the problem.
Doing "gmake -f Makefile" (or just "gmake", which had an
implied "-f Makefile" for me) tried to compile "Makefile.cc"
as a C++ program :)
Sample problem output...
If "foo.cc" happens to not be compilable:
gmake -f foo
g++ foo.cc -o foo
foo.cc:1: error: expected constructor, destructor, or type conversion before
'=' token
foo.cc:1: error: expected `,' or `;' before '=' token
foo.cc:2:2: invalid preprocessing directive #CC
If "foo.cc" happens to be compilable/linkable:
gmake -f foo
g++ foo.cc -o foo
foo:1: warning: NUL character seen; rest of line ignored
foo:1: *** missing separator. Stop.
Note: for reasons I haven't ascertained yet, sometimes
"gmake -f foo" *doesn't* try to compile foo.c first.
If I'm using "Makefile" and "Makefile.cc", the problem occurs
every time.
thanks,
Stan
address@hidden
--
Stan Sieler
address@hidden
www.allegro.com/sieler/wanted/index.html
- -f <filename> incorrectly implying a make *of* "filename"?,
Stan Sieler <=