Makefiles etc

Simon Marlow simonmar@microsoft.com
Mon, 30 Sep 2002 12:02:46 +0100


> I've been looking at the fputils build system, and amongst=20
> various typos
> and pet peeves[0] there are a few more serious things I have=20
> noticed and
> I also have a few questions. I will refer mostly to names of the final
> built Makefiles as that is what it was easiest to follow.

Wow, a code review of the build system!  You obviously have too much
time on your hands, but many thanks anyway :-)

Most of these small problems have arisen because the build system has
been hacked for some time by various people with varying degrees of
familiarity with the whole system - the problem with a build system is
that it isn't interesting enough to motivate folk to become truly
familiar with it; most people just want it to work.

Most of the problems you point out I've just gone in and fixed.  Some of
them are less clear cut, and/or I didn't think it was worth making
unforced changes:

> mk/config.mk:
>=20
>     # Yuckage: for ghc/utils/parallel -- todo: nuke this dependency!!
>     BASH                    =3D /usr/local/bin/bash
>=20
> If it's going to be there shouldn't the correct location of bash be
> detected? [just hardcoded in mk/config.mk.in]

Sure.  However these utils are not used except by the GPH folk, so I'll
leave it to them.

> mk/suffix.mk:
>     ifneq "$(BootingFromHc)" "YES"
>     %_hsc.c %_hsc.h %.hs : %.hsc
>         $(HSC2HS) $(HSC2HS_OPTS) $<
>         @touch $(patsubst %.hsc,%_hsc.c,$<)
>     endif
>=20
> Am I right in thinking that the touch is done because hsc2hs won't
> always generate all the files and the rule doesn't want to be=20
> triggered next time make is called if one of them isn't created?

I believe so, yes.

> mk/suffix.mk:
> %.$(way_)o : %.$(way_)s
>     @$(RM) $@
>     $(HC) $(GHC_CC_OPTS) -c $< -o $@
>=20
> Why is the target first deleted?

I have no idea, but this is the way it has been done since the Beginning
of Time (ie. I believe this code was copied from the original
incarnation of the build system).  It may be because some makes aren't
as good as others at checking whether a target was actually built before
continuing, or it may be just paranoia.  I have a vague recollection
that at one time deleting the target was considered "good practice".
Either way, it's harmless.

> mk/suffix.mk:
>     %.tab.c %.tab.h : %.y
>         @$(RM) $*.tab.h $*.tab.c y.tab.c y.tab.h y.output
>         $(YACC) $(YACC_OPTS) $<
>         $(MV) y.tab.c $*.tab.c
>         @chmod 444 $*.tab.c
>         $(MV) y.tab.h $*.tab.h
>         @chmod 444 $*.tab.h
>=20
> This of course has potential problems make -j. Also, why are=20
> the chmods hidden?

Yes.  Fortunately this rule isn't in use at the moment.

> mk/suffix.mk:
>     %.html : %.sgml
>         @$(RM) $@
>     #   $(PERL) $(COLLATEINDEX) -N -o index.sgml
>     #   $(JADE) -t sgml -V html-index -d $(SGMLSTYLESHEET) -c=20
> $(DOCBOOK_CATALOG) $<
>     #   $(PERL) $(COLLATEINDEX) -N -o index.sgml
>         $(SGML2HTML) $(SGML2HTML_OPTS) $<
>     # touch the .html file so that it is seen to be built
>         @touch $@
>=20
> What is the touch for here?

Because $(SGML2HTML) doesn't actually create $@, it creates a
subdirectory with the files in.  We therefore use $@ as a stamp file.

>     touch $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in
>=20
> in Makefile is unneccesary as various things are about to be=20
> appended to it.

You can only append to a file if it exists, so the touch is there to
create the empty file first.

Cheers,
	Simon
_______________________________________________
Cvs-ghc mailing list
Cvs-ghc@haskell.org
http://www.haskell.org/mailman/listinfo/cvs-ghc