Subject: Re: devel/nbitools needs to set compiler flags
To: None <tech-pkg@netbsd.org>
From: Idar Tollefsen <idart@performancedesign.no>
List: tech-pkg
Date: 07/26/2005 19:10:29
This is a multi-part message in MIME format.
--------------000709040209060803020500
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
I'm following up on this myself.
It turns out that if you set CC and CXX for the SunPro compiler (as the
documentation tells you do to:
http://www.netbsd.org/Documentation/pkgsrc/platforms.html#solaris), then ${CC},
${CXX} and ${LD} are no longer (of course) aliased to gcc, g++ and gcc
respectively. As a side effect ${CFLAGS} or ${CXXFLAGS} aren't present when
linking. Normally, that simply means adding ${CFLAGS} to ${LDFLAGS} in mk.conf
since the compiler is used as the link driver anyway.
In my original patch, I had set LdCmd to simply ${LD}, but when ${LD} now
becomes "ld" instead of "gcc", the ${CFLAGS} part of ${LDFLAGS} aren't accepted.
And of course they're not, their compiler flags, not linker flags. Furthermore,
I can't find a way to force in ${LDFLAGS}. There's a define for SHLIBLDFLAGS,
but it's already set by the various platform configurations and should not be
overwritten.
A revised patch is attached (still incorporating changes suggested in pkg/30341)
in witch LdCmd is set to "${CC} ${LDFLAGS}" and ${LDFLAGS} is removed from the C
and C++ options since it's now part of the link command. I believe this should
work for all compilers.
--------------000709040209060803020500
Content-Type: text/plain;
name="Makefile.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="Makefile.diff"
--- nbitools.orig/Makefile Tue Jul 26 16:41:48 2005
+++ nbitools/Makefile Tue Jul 26 18:36:04 2005
@@ -19,6 +19,8 @@
.include "../../mk/bsd.prefs.mk"
+MAKE_ENV+= BOOTSTRAPCFLAGS="${CFLAGS} ${LDFLAGS}"
+
.if ${OPSYS} == "Linux"
USE_TOOLS+= gmake
.endif
@@ -27,5 +29,23 @@
@${MV} ${WRKSRC}/config/cf/site.def ${WRKSRC}/config/cf/site.def.orig
@${SED} -e 's|^\(\#define[ \t]*ProjectRoot\).*|\1 ${PREFIX}|' \
${WRKSRC}/config/cf/site.def.orig > ${WRKSRC}/config/cf/site.def
+post-configure:
+ @${ECHO} "#define CcCmd ${CC}" >> ${WRKSRC}/config/cf/host.def
+ @${ECHO} "#define CplusplusCmd ${CXX}" >> ${WRKSRC}/config/cf/host.def
+ @${ECHO} "#define CplusplusIncludes" >> ${WRKSRC}/config/cf/host.def
+ @${ECHO} "#define LdCmd ${CC} ${LDFLAGS}" >> ${WRKSRC}/config/cf/host.def
+ @${ECHO} "#define DefaultCCOptions ${CFLAGS}" >> ${WRKSRC}/config/cf/host.def
+ @${ECHO} "#define DefaultCplusplusOptions ${CXXFLAGS}" >> ${WRKSRC}/config/cf/host.def
+.if ${OPSYS} == "SunOS"
+. if ${PKGSRC_COMPILER} == "gcc"
+ @${ECHO} "#define HasSunC NO" >> ${WRKSRC}/config/cf/host.def
+ @${ECHO} "#define HasGcc2 YES" >> ${WRKSRC}/config/cf/host.def
+ @${ECHO} "#define HasSunCplusplus NO" >> ${WRKSRC}/config/cf/host.def
+ @${ECHO} "#define HasGcc2ForCplusplus YES" >> ${WRKSRC}/config/cf/host.def
+. elif ${PKGSRC_COMPILER} == "sunpro"
+ @${ECHO} "#define CCompilerMajorVersion 5" >> ${WRKSRC}/config/cf/host.def
+ @${ECHO} "#define CplusplusCompilerMajorVersion 5" >> ${WRKSRC}/config/cf/host.def
+. endif
+.endif
.include "../../mk/bsd.pkg.mk"
--------------000709040209060803020500--