[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Remove files with make clean
From: |
Nicola Pero |
Subject: |
Re: Remove files with make clean |
Date: |
Tue, 7 Jun 2005 14:55:30 +0100 (BST) |
> Hi,
>
> I need to remove a generated file when doing a "make clean" in my
> project. Is there any way to "hook" into the clean target or any other
> way to achieve this.
Just add an after-clean:: command at the end of your GNUmakefile. :-)
(often those commands are put in a GNUmakefile.postamble and then that
file is included, but you can also just add them at the end or your
GNUmakefile).
If it's just for a single file, just copy from this example that will
remove the file 'MyFile' --
include $(GNUSTEP_MAKEFILES)/common.make
TOOL_NAME = WorldPeaceMaker
WorldPeaceMaker_OBJC_FILES = WorldPeaceMaker.m
include $(GNUSTEP_MAKEFILES)/tool.make
after-clean::
-$(RM) MyFile
'after-clean' commands are executed after all the other clean operations.
You can also have a 'before-clean' section if you want.
don't forget the TAB before the '-'. It won't work without it, as make
uses it to know it's a rule.
the '::' in after-clean are because it's a special rule, you're adding to
an existing rule (a normal rule would have ':').
the '-' before the command means that if MyFile does not exist, no error
is generated.
the '$(RM)' expands to 'rm' or whatever the shell command to remove files
is.
This 'after-clean::' way of adding commands is considered part of the
gnustep-make public API so it is fully supported. :-)
Sorry for being pedantic, I imagine you already know most of this :-),
anyway it's also for future reference/help.
Hope that helps, thanks!