in reply to [OT] Makefiles - nmake syntax v dmake syntax

if is not a program but a shell (cmd) builtin, so invoke the shell.
clean: -cmd /c if exist glversion.txt del glversion.txt -cmd /c if exist glversion.exe del glversion.exe -cmd /c if exist glversion.o del glversion.o

By the way, I fixed the file name in the last one.

Replies are listed 'Best First'.
Re^2: [OT] Makefiles - nmake syntax v dmake syntax
by syphilis (Archbishop) on Jul 16, 2008 at 14:15 UTC
    By the way, I fixed the file name in the last one.

    Yeah ... I was wunderin' how come glversion.o never got removed :-)

    Your solution works fine, btw - thanks. At some stage (in a rare moment of enlightened inspiration) I also got around to trying:
    clean: -if exist "glversion.txt" del "glversion.txt" -if exist "glversion.exe" del "glversion.exe" -if exist "glversion.o" del "glversion.o"
    and that works, too. I was surprised that those double quotes would have such a marked effect on the way that the commands are parsed.

    Reading through the rest of the thread I'm struck with the notion that TMTOWTDI .... which would be sooooo typical of this place :-)

    Thanks guys.

    Cheers,
    Rob

      I was surprised that those double quotes would have such a marked effect on the way that the commands are parsed.

      system does the same thing in Perl. The presence of shell meta characters forces the invocation of the shell.