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

The unixy way of doing things is this:
clean: rm -f glversion.txt glversion.exe glversion.o

The -f option tells rm (among other things) that it's not an error if some of the files don't exist. Maybe there's a similar option for del?

Another way is it let the command fail, and ignore the failure by prepending a dash to the command:

clean: - rm glversion.txt glversion.exe glversion.o

This way rm will fail if some of these files don't exist, but make will ignore that error. Again I don't know if the various make dialects understand that.

To me it seems overkill to both add the leading dash and have the if exists in the makefile.

Replies are listed 'Best First'.
Re^2: [OT] Makefiles - nmake syntax v dmake syntax
by Corion (Patriarch) on Jul 16, 2008 at 09:07 UTC

    Except that rm is not available under Windows. If you don't want to use my hand-rolled Perl solution, ExtUtils::Command has the rm_f subroutine which does what my oneliner does, except likely better:

    perl -MExtUtils::Command -e rm_f glversion.txt glversion.exe glversion +.o