Re: CONFIGURE_ENV and do-configure

From: Ronald Klop <ronald-lists_at_klop.ws>
Date: Fri, 16 May 2025 12:39:34 UTC
Van: Alex Dupre <ale@FreeBSD.org>
Datum:vrijdag, 16 mei 2025 12:27
Aan:Ronald Klop <ronald-lists@klop.ws>, ports@freebsd.org
Onderwerp:Re: CONFIGURE_ENV and do-configure
> 
> On 16/05/2025 12:09, Ronald Klop wrote:
> > Hi,
> >
> > I have some variables in CONFIGURE_ENV in my port database/mongodb70, > but I do not see those used in the do-configure action.
> >
> > CONFIGURE_ENV+= M4=${LOCALBASE}/bin/gm4
> >
> > do-configure:
> > # Replacement of ${WRKSRC}/src/third_party/mozjs/get-sources.sh
> >          ${LN} -sF ${WRKDIR}/spidermonkey-${MOZJS_TAG} ${WRKSRC}/src/ > third_party/mozjs/mozilla-release
> >          cd ${WRKSRC}/src/third_party/mozjs && PYTHON3="${PYTHON_CMD}" > ${SH} ./gen-config.sh ${MOZJS_ARCH} freebsd
> 
> If you override the 'do-configure' stage you need to use CONFIGURE_ENV there, like:
> 
> ${CONFIGURE_ENV} PYTHON3="${PYTHON_CMD}" ${SH} ./gen-config.sh ${MOZJS_ARCH} freebsd
> 
> -- 
> Alex Dupre
>  
> 
> 
> 



Thank you for all the feedback. The suggestions made me read up on Mk/bsd.port.mk again and another supported solution is:

+HAS_CONFIGURE= yes
+CONFIGURE_SCRIPT=      gen-config.sh
+CONFIGURE_ARGS+=       ${MOZJS_ARCH} freebsd
+CONFIGURE_WRKSRC=      ${WRKSRC}/src/third_party/mozjs

-do-configure:
+pre-configure:
 # Replacement of ${WRKSRC}/src/third_party/mozjs/get-sources.sh
        ${LN} -sF ${WRKDIR}/spidermonkey-${MOZJS_TAG} ${WRKSRC}/src/third_party/mozjs/mozilla-release
-       cd ${WRKSRC}/src/third_party/mozjs && PYTHON3="${PYTHON_CMD}" ${SH} ./gen-config.sh ${MOZJS_ARCH} freebsd


But by the option of adding ${CONFIGURE_ENV} to do-configure it prints a nice line of the command+env it is executing which makes debugging a lot easier.
This same debug output could be created by committing this patch:
diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk
index 4596b773b6d3..fec87785533c 100644
--- a/Mk/bsd.port.mk
+++ b/Mk/bsd.port.mk
@@ -3305,7 +3305,7 @@ do-configure:
 .      endif
 .      if defined(HAS_CONFIGURE)
        @${MKDIR} ${CONFIGURE_WRKSRC}
-       @(cd ${CONFIGURE_WRKSRC} && \
+       (cd ${CONFIGURE_WRKSRC} && \
            ${SET_LATE_CONFIGURE_ARGS} \
                if ! ${SETENVI} ${WRK_ENV} CC="${CC}" CPP="${CPP}" CXX="${CXX}" \
            CFLAGS="${CFLAGS}" CPPFLAGS="${CPPFLAGS}" CXXFLAGS="${CXXFLAGS}" \

Would it be ok to commit this bsd.port.mk change?

Regards,
Ronald.