Subject: Re: custom CFLAGS not getting set
To: Jeremy C. Reed <reed@reedmedia.net>
From: Simon Gerraty <sjg@juniper.net>
List: tech-pkg
Date: 12/02/2002 11:03:26
On Mon, 2 Dec 2002 10:38:45 -0800 (PST), "Jeremy C. Reed" writes:
>> Huh?  sys.mk is read before anything else, so Makefile settings should
>> not be impacted.  settings on the command line override anything, so
>> only CFLAGS set in the environment should be impacted?  Or is
>> something reading sys.mk directly?

Yep pkgsrc/mk/bsd.prefs.mk reads sys.mk:

# Preload all default values for CFLAGS, LDFLAGS, etc. before bsd.pkg.mk
# or a pkg Makefile modifies them.
.include <sys.mk>

and bsd.prefs.mk does not protect itself from multiple inclusion and
is included by multiple *.mk:

bsd.buildlink.mk:.include "../../mk/bsd.prefs.mk"
bsd.pkg.defaults.mk:# Default: defaults for various machine_archs are set in mk/bsd.prefs.mk
bsd.pkg.defaults.mk:# Default: defaults for various machine_archs are set in mk/bsd.prefs.mk
bsd.pkg.install.mk:.include "../../mk/bsd.prefs.mk"
bsd.pkg.mk:.include "../../mk/bsd.prefs.mk"
bsd.pkg.subdir.mk:.if exists(${.CURDIR}/mk/bsd.prefs.mk)
bsd.pkg.subdir.mk:.include "${.CURDIR}/mk/bsd.prefs.mk"
bsd.pkg.subdir.mk:.if exists(${.CURDIR}/../mk/bsd.prefs.mk)
bsd.pkg.subdir.mk:.include "${.CURDIR}/../mk/bsd.prefs.mk"
bsd.pkg.subdir.mk:.endif        # exists(${.CURDIR}/../mk/bsd.prefs.mk)
bsd.pkg.subdir.mk:.endif        # exists(${.CURDIR}/mk/bsd.prefs.mk)
emacs.mk:.include "../../mk/bsd.prefs.mk"
endian.mk:.include "../../mk/bsd.prefs.mk"
ghostscript.mk:.include "../../mk/bsd.prefs.mk"
motif.buildlink2.mk:.include "../../mk/bsd.prefs.mk"
ossaudio.buildlink2.mk:.include "../../mk/bsd.prefs.mk"
pthread.buildlink.mk:.include "../../mk/bsd.prefs.mk"
pthread.buildlink2.mk:.include "../../mk/bsd.prefs.mk"
x11.buildlink2.mk:.include "../../mk/bsd.prefs.mk"
xaw.buildlink2.mk:.include "../../mk/bsd.prefs.mk"

This seems highly inefficient at best.

>I can provide entire 1835014 byte log (99889 bytes bzip2'd) of building
>simple net/gethost.

No need - the answer is above.  Changing sys.mk will work around it,
but the fact that sys.mk is getting read that many times is (I
suspect) a bug, the pkgsrc folk will likely know best why bsd.prefs.mk
allows multiple inclusion.

--sjg