473,748 Members | 8,530 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Makefile Macro Substitution Help

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.m k")
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.local domain]/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
3 4079
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.c om (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.m k")
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.local domain]/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
a_*****@hotpop. com wrote in message news:<200312161 81717.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@localhos t 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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2250
by: Raghuveer Pallikonda | last post by:
Hi, I am trying to stub out debug log messages in my application, if the logging subsystem is not enabled.. For e.g a invocation #define LOGMSG !Logger::Enabled() ? false : Logger::LogMsg so that LOGMSG("Log Me\n"); will be a NO-OP if the Logger::Enabled() returns false, else the
8
5347
by: Siemel Naran | last post by:
#define EXPECT_ASSERT(x) { if (!x) expect_assert(localVariable, __FILE__, __LINE__, #x); } MSVC7 gives an error: "error C2014: preprocessor command must start as first nonwhite space".
7
23554
by: Newbie_sw2003 | last post by:
Where should I use them? I am giving you my understandings. Please correct me if I am wrong: MACRO: e.g.:#define ref-name 99 The code is substituted by the MACRO ref-name. So no overhead. Execution is faster. Where will it be stotred?(Is it in bss/stack/?) FUNCTION:
1
2134
by: Casanova | last post by:
Hello!!! I have been using C for a very short while. I am used to macros in C, but while i was reading the code for LittleOS (an open source OS), i came across a type of macro wherein no value was given to substitute the text. What does this imply? The code i came across is as follows: #ifndef _TIME_H #define _TIME_H
14
2069
by: Malcolm | last post by:
Hi, I have the following which fails with "disagreement in number of macro arguments" when compiling with Imagecraft ICCAVR. Has anyone got any ideas - its not vital but would make the code a lot nicer to read: #define SET(x,y) (x |=(1<<y)) #define PIEZO PORTB,5
1
5440
by: Rodolfo | last post by:
Hello, there's another languages that can do a macro substitution, how can I do this in Csharp. This is an example of what I want to do Dataset ds = new Dataset; string a = "ds"; DataSet ds2 = &a;
4
6923
by: Don | last post by:
I think "macro substitution" is the correct term for what I want to do, but, to be sure, here is a description of what I'd like to know is possible: I want to be able to create a create an object of a type whose name is stored in a constant. For example: Const FORM_NAME_1 as String = "frmThisForm" Const FORM_NAME_2 as String = "frmThatForm"
37
8997
by: junky_fellow | last post by:
hi guys, Can you please suggest that in what cases should a macro be preferred over inline function and viceversa ? Is there any case where using a macro will be more efficient as compared to inline function ? thanks for any help in advance ...
1
5043
by: rpjanaka | last post by:
I am using an open source library called IGI_UDP for measure the available bandwidth of a link (http://www.cs.cmu.edu/%7Ehnn/igi/ ). with that library they have provided a "Makefile" which is not an auto generated one. the following is the given Makefile, ***************************************************************** CC = gcc INCS = -I. CFLAGS = -g -Wall $(DEFS) $(INCS)
0
8828
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9537
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9243
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.