By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,804 Members | 1,627 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,804 IT Pros & Developers. It's quick & easy.

Makefile Macro Substitution Help

P: n/a
OK...I'm new to this and I'm sure I'm missing something obvious, so
please be kind.

I've tried several different approaches to this problem (including
various if, ifeq, and case constructs), and I'm about to give up. Can
any tell me why this doesn't work? In a nutshell, I want a Makefile
that will "include" either a Linux.mk or a SunOS.mk without having to
rely on an explicit command line parameter or env var.

Here is the segment that is giving me trouble:
################################################## #######################
#
#
# Sample Makefile #
#
#
################################################## #######################

#.SILENT:

# Use a known shell
SHELL=/bin/sh

# Obtain OS name (e.g., "Linux" or "SunOS")
THE_OS := `uname`

# Name the INCFILE using the OS name (e.g., "Macros.Linux.mk")
INCFILE := $(HOME)/src/Macros.$(THE_OS).mk

# Test defined macros to see if I have what I expect
echo:
@echo "THE_OS = :"$(THE_OS)":"
@echo "INCFILE = :"$(INCFILE)":"
ls -al $(INCFILE)

# Include the project default macros
include $(INCFILE)

<EOF>

-----------------------And here is the error I get
---------------------------

localhost.localdomain]/home/tponko/src% make
Makefile:20: /home/tponko/src/Macros.`uname`.mk: No such file or
directory
make: *** No rule to make target `/home/tponko/src/Macros.`uname`.mk'.
Stop.
Any/all help will be greatly appreciated.

Thanks...
Jul 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
The Makefile is fine. Simply running the command "make", though, is not. The parser thinks that
THE_OS :=
is a command-rule. Simply run "make echo", and you should get what you're looking for!

Hope I helped!
-Elliot :)

On 16 Dec 2003 14:19:30 -0800
tm*****@yahoo.com (tmponko) wrote:
OK...I'm new to this and I'm sure I'm missing something obvious, so
please be kind.

I've tried several different approaches to this problem (including
various if, ifeq, and case constructs), and I'm about to give up. Can
any tell me why this doesn't work? In a nutshell, I want a Makefile
that will "include" either a Linux.mk or a SunOS.mk without having to
rely on an explicit command line parameter or env var.

Here is the segment that is giving me trouble:
################################################## #######################
#
#
# Sample Makefile #
#
#
################################################## #######################

#.SILENT:

# Use a known shell
SHELL=/bin/sh

# Obtain OS name (e.g., "Linux" or "SunOS")
THE_OS := `uname`

# Name the INCFILE using the OS name (e.g., "Macros.Linux.mk")
INCFILE := $(HOME)/src/Macros.$(THE_OS).mk

# Test defined macros to see if I have what I expect
echo:
@echo "THE_OS = :"$(THE_OS)":"
@echo "INCFILE = :"$(INCFILE)":"
ls -al $(INCFILE)

# Include the project default macros
include $(INCFILE)

<EOF>

-----------------------And here is the error I get
---------------------------

localhost.localdomain]/home/tponko/src% make
Makefile:20: /home/tponko/src/Macros.`uname`.mk: No such file or
directory
make: *** No rule to make target `/home/tponko/src/Macros.`uname`.mk'.
Stop.
Any/all help will be greatly appreciated.

Thanks...

--
"Serpent!" screamed the Pigeon.
"I'm not a serpent!" said Alice indignantly. "Let me alone!"
"Serpent, I say again!" repeated the Pigeon, but in a more subdued tone, and added with a kind of sob, "I've tried every way, and nothing seems to suit them!"
- L. Carroll
-==++==++==++==++==++==-
"Always the hours."
Jul 22 '05 #2

P: n/a
a_*****@hotpop.com wrote in message news:<20031216181717.0101e2ac.a_*****@hotpop.com>. ..
The Makefile is fine. Simply running the command "make", though, is not. The parser thinks that
THE_OS :=
is a command-rule. Simply run "make echo", and you should get what you're looking for!

Hope I helped!
-Elliot :)


Elliot,
I gave your suggestion another shot (see below), but got the same
result.

From the reading I've done I get the impression that make performs two
passes, and macro substitution for the "include $(INCFILE)" statement
is not resolving to the value of function `uname` used in the INCFILE
declaration.

So I'm still stumped...

Thanks

[tponko@localhost src]$ make echo
Makefile:19: /home/tponko/src/Macros.`uname`.mk: No such file or
directory
make: *** No rule to make target `/home/tponko/src/Macros.`uname`.mk'.
Stop.
Jul 22 '05 #3

P: n/a
So I gave up and moved the compiler definition to my login script.
Since make recognizes env vars, this brute force approach was
sufficient.
Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.