So you have some other problem. I took you example and put it into a
functional sources file, and added a !message line:
!if $(NEW_API)
RM_SOURCES=a.c
!message IF ENTERED
!else
RM_SOURCES=d.c
!message ELSE ENTERED
!endif
And this works just as expected. If NEW_API is ‘1’ “IF ENTERED” is in
the logfile and “ELSE ENTERED” is not. If NEW_API is ‘0’ “IF ENTERED” is
not in the logfile and “ELSE ENTERED” is.
The problem is not what you think it is. The nmake preprocessor works as
documented. The problem is the way build works.
I would suggest that you reorganize your sources. In a simplified
example with an a.c and a d.c as separate sources and common source
file, call it event.c, I would create two separate subdirectories,
buildA and buildB. In BuildA my sources file would look like this:
TARGETNAME=event
TARGETTYPE=DRIVER
INCLUDES=$(INCLUDES) …\
SOURCES=…\event.c \
…\a.c \
…\event.rc
In BuildB my sources file looks like this:
TARGETNAME=event
TARGETTYPE=DRIVER
INCLUDES=$(INCLUDES) …\
SOURCES=…\event.c \
…\d.c \
…\event.rc
This works, even though the support for including source files ‘up one
level’ is undocumented.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Praveen Kumar
Amritaluru
Sent: Thursday, April 20, 2006 12:24 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Re:How to build library from object files created in
You are right. I meant SOURCES=$(RM_SOURCES)
But any idea why both if-part and else-part are getting executed incase
if(condition) is true.
Regds,
-Praveen
“Roddy, Mark” wrote in message
news:xxxxx@ntdev…
No you have some bug. Your sources file is interpreted as part of a
makefile and follows the rules documented in the nmake references. I
assume you meant SOURCES=$(RM_SOURCES) rather than SOURCES=$RM_SOURCES.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Praveen Kumar
Amritaluru
Sent: Thursday, April 20, 2006 9:38 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Re:How to build library from object files created in
Thanks very much to all those who replied.
Now I changed to overcome this problem.
The way I have done now is:
!if $(NEW_API)
C_DEFINES=$(C_DEFINES) -DAPI
LINKLIBS= a.lib b.lib
RM_SOURCES=a.c b.c c.c
!else
C_DEFINES=$(C_DEFINES)
LINKLIBS=a.lib
RM_SOURCES=d.c e.c
!endif
SOURCES=$RM_SOURCES
The problem I face here is that:
If the env variable NEW_API is set to 0, it executes only else clause.
But
if I set NEW_API to 1, it executes if-clause code
followed by else-clause code. So incase NEW_API==1, this undo’s
whatever is
present in if-clause and SOURCES always ends up being d.c e.c
Is this there any restriction similar to SOURCES on LINKLIBS or C_DEFI
NES
too wherein both if-caluse and else-clause
statements are executed?
Regards,
-Praveen
“Tim Roberts” wrote in message news:xxxxx@ntdev…
> Praveen Kumar Amritaluru wrote:
>
>>Thanks again.
>>
>>One last question.
>>
>> I want to source files to compile conditionally like:
>>
>>!if ()
>>SOURCES= a.c
>>!else
>>SOURCES= b.c
>>!endif.
>>
>>Build utility is giving an error if I try this. The error i get is as
>>follows:
>>1>sources(21) : warning U1018: directive and/or expression part
missing
>>
>>
>
> Right. There can only be one line that says “SOURCES=”. That’s one
of
> the amusing little quirks of build, which is essentially a
pre-processor
> for nmake. Other than a few quirks, the rest of the sources file must
> be nmake-compatible.
>
> So, just make it:
>
> SOURCES = <br>> a1.c <br>> a2.c <br>> !if ()
> a.c <br>> !else
> b.c <br>> !endif
> c.c
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer