[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
On Thu, Nov 08, 2007 at 01:15:54PM +0000, Robin Cornelius wrote:
> Arrg, having another braindead day
>
> How can i do a conditional make file as such :-
>
> distclean:
> if [ -f Makefile.qmake ]
> ${MAKE} -f Makefile.qmake distclean
> rm -f Makefile
> endif
>
> I'm trying to use a GNU makefile to bootstrap a qmake process but if
> someone runs distclean twice or on a fresh install it creates a fatal
> make error. I've found a number of examples on google but none seem to
> actually work.
You can make make ignore errors in a rule by prepending a '-':
distclean:
-${MAKE} -f Makefile.qmake distclean
-rm -f Makefile
Alternatively, you can embed the shell command:
distclean:
if [ -f Makefile.qmake ]; \
${MAKE} -f Makefile.qmake distclean; \
rm -f Makefile; \
fi
Note that you need to escape the shell code for this to work. To escape
a variable, so that it's parsed by the shell instead of by make, prepend
an extra '$'.
If you were using BSD make, you could use a conditional:
distclean:
.if exists(Makefile.qmake)
${MAKE} -f Makefile.qmake distclean
rm -f Makefile
.endif
Unfortunately, GNU make can't do this, AFAIK.
--
Benjamin A'Lee :: benjamin.alee@xxxxxxxxxxxxxx
Subvert Technologies :: http://subvert.org.uk/
Attachment:
pgp8kFObVe8My.pgp
Description: PGP signature
-- The Mailing List for the Devon & Cornwall LUG http://mailman.dclug.org.uk/listinfo/list FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html