Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

NMAKE Loops?

1,025 views
Skip to first unread message

JagerEd

unread,
May 15, 2003, 3:08:57 PM5/15/03
to
Is there any kind of loop structure in NMAKE? For example, if I could use
the DOS
bach file FOR syntax:

JUNK = c:\dir1\junk1.obj k:\dir2\junk2.obj

CLEAN:
for %%x in ($(JUNK)) do erase %%x

However, this doesn't work. Seems to get confused with the %%.


TIA

Ed


Arnaud Debaene

unread,
May 15, 2003, 4:54:46 PM5/15/03
to
JagerEd wrote:
> Is there any kind of loop structure in NMAKE? For example, if I could
> use the DOS
> bach file FOR syntax:
>
> JUNK = c:\dir1\junk1.obj k:\dir2\junk2.obj
>
> CLEAN:
> for %%x in ($(JUNK)) do erase %%x
del $(JUNK)

... should work just fine...
On the other hand, if you have several dependents and a rule that doesn't
use batch build mode (":" instead of "::") that describes how to build those
dependents, the command will be called for each dependent.

Arnaud
MVP - VC


Larry Brasfield

unread,
May 15, 2003, 5:11:02 PM5/15/03
to
In article <u1HbwVxG...@TK2MSFTNGP10.phx.gbl>,
JagerEd (JagerEd_R_E__M*OV...@myrealbox.com) says...

> Is there any kind of loop structure in NMAKE?

Not really. You should appreciate that make
languages are declarative, not procedural.
Anything like looping is purely a (possible)
feature of the underlying shell, which can
change according to COMSPEC env-var setting.

> For example, if I could use the DOS bach file FOR syntax:
>
> JUNK = c:\dir1\junk1.obj k:\dir2\junk2.obj
>
> CLEAN:
> for %%x in ($(JUNK)) do erase %%x
>
> However, this doesn't work. Seems to get confused with the %%.

I have found a good solution for making
more portable makefile's that avoids a
lot of problems with quoting rules and
differing behavior of command-line
shells. That is to have anything tricky
done by Perl scripts, and require that
Perl be available in any build machine.

Here are some excerpts from a makefile
written that way:

# How to make a various chars that confound nmake and CLI shells.
PERCENT=%%%%
SHARP=^#
HAT=^^
# (With sane shells:) PERCENT=%% HAT=^^

ZAPGLOB = $(PERL) -e "while(@ARGV){foreach (glob(shift)) { unlink($$_); } }"

# Remove the generated headers.
zap_headers :
@$(ZAPGLOB) $(GEN_HEADERS)

# Remove stuff not needed after the build, leave deliverables.
tidy :
@$(ZAPGLOB) $(INT_PRODUCTS) $(LINK_PRODUCTS)

# Remove all (known) build results.
clean : tidy zap_headers
@$(ZAPGLOB) $O\*.ofl $O\*.ld $O\dhp.sym $O\upburn.4
@$(ZAPGLOB) $(HEX_PRODUCTS) $O\features.txt

You might find that $(PERCENT)$(PERCENT)
does what you want, but I really recommend
not catering to the default shell's rules
as they happen to exist at the moment.

I've also given up on making things work
with cmd.exe . It's just too quirky and it
keeps changing with OS releases. A better
CLI shell for anybody who is serious about
doing stuff at the command line (and who
has not gravitated to bash, etc.), is:
http://www.jpsoft.com/4ntdes.htm

--
-Larry Brasfield
(address munged, s/sn/h/ to reply)

JagerEd

unread,
May 15, 2003, 9:11:05 PM5/15/03
to
Arnaud ,

Thanks. Yes, I find that it does work. I must have had some kind of a typo
when I first tried it.

Ed

"Arnaud Debaene" <adeb...@club-internet.fr> wrote in message
news:uarizQyG...@TK2MSFTNGP11.phx.gbl...

JagerEd

unread,
May 15, 2003, 9:20:57 PM5/15/03
to

> Not really. You should appreciate that make
> languages are declarative, not procedural.
> Anything like looping is purely a (possible)
> feature of the underlying shell, which can
> change according to COMSPEC env-var setting.

Yes, I realize that. Guess I should have said it differently. I did get the
MSDOS for loop to work now.


> I have found a good solution for making
> more portable makefile's that avoids a
> lot of problems with quoting rules and
> differing behavior of command-line
> shells. That is to have anything tricky
> done by Perl scripts, and require that
> Perl be available in any build machine.
>

I am still smarting from two attempts to "sanitize" the makefile for
multiplatform usage. In one approach
I wrote C++ programs that set up and dispatched makefiles that were venilla,
putting a lot of the
variable stuff in a separate file with an hierarchical structure. It works,
but I still have to customize the
base makefile on a per-platform basis, as well as the separtae structured
file, so I really have just
doubled my maintenance work. Also tried Tk/TCL, which was also (for me) a
maintenance nightmare.
I'll study your Perl stuff, if I can bring myself to learn YAPL (yet another
programming language).

Thanks, Larry.

Ed


0 new messages