Subject: Re: MAKE_PROGRAM and tools.mk [Was: Re: CVS commit: pkgsrc/security/openssl]
To: Lubomir Sedlacik <salo@Xtrmntr.org>
From: Johnny C. Lam <jlam@netbsd.org>
List: tech-pkg
Date: 08/26/2003 04:21:31
--jRHKVT23PllUwdXP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Mon, Aug 25, 2003 at 11:23:33PM +0200, Lubomir Sedlacik wrote:
> On Mon, Aug 25, 2003 at 04:36:17PM -0400, Jan Schaumann wrote:
> >
> > I see.  The problem (AFAICT after a brief look at tools.mk) is that
> > MAKE_PROGRAM and MAKE do not contain the full path, but just the name
> > of the exectuable.  We'd have to either provide a full path for MAKE,
> > or otherwise treat it in a special way to make this work.
> 
> it's not really that difficult.  if USE_GMAKE is set, MAKE_PROGRAM does
> contain the full path for MAKE.  if it's not set, we are using bmake and
> 
>  MAKE_PROGRAM=`${TYPE} ${MAKE} | ${AWK} '{print $$NF}'`
> 
> would do the trick (thank jlam for the hint).
> 
> > But it does seem to me that we actually do want to make sure that the
> > invoked 'make' is always in fact what we think it is, and this
> > approach is probably a way to achieve this.
> 
> johnny went even further and suggested moving USE_GMAKE to tools.mk as
> USE_GNU_TOOLS+=make.  i think that's the way to go.

I've attached a patch relative to the HEAD on today's pkgsrc that does
the following things:

    (*) Create a symlink from the "make" requested by the package
        into ${TOOLS_DIR}/bin/make.

    (*) If a package wants GNU make, then it should set
        USE_GNU_TOOLS+=make in the package Makefile.

    (*) Allow for USE_GMAKE to continue to work until we get a chance
        to sweep through package Makefiles in pkgsrc and kill it.

I prefer this approach only because we'd have fewer patches.  I recall
several packages where I had to repeatedly patch around the assumption
that MAKE=make, and it usually takes a surprising amount of patches to
do so.  Using tools.mk as a workaround lets more packages Just Work.

Of course, if you want to keep those patches and send them back to
the software author, that's always good, too.  These changes merely
change things so that the patches aren't strictly required.

	Cheers,

	-- Johnny Lam <jlam@netbsd.org>

--jRHKVT23PllUwdXP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="gmake.diff"

Index: bsd.pkg.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.1245
diff -u -r1.1245 bsd.pkg.mk
--- bsd.pkg.mk	2003/08/24 08:51:11	1.1245
+++ bsd.pkg.mk	2003/08/26 04:10:08
@@ -145,17 +145,23 @@
 .  endif
 .endif	# USE_IMAKE
 
+.if defined(USE_GNU_TOOLS) && !empty(USE_GNU_TOOLS:Mmake)
+_USE_GMAKE=		yes
+.endif
+
+# XXX This should be obsoleted.  Packages that want GNU make should use
+# XXX 	USE_GNU_TOOLS+=	make.
+#
 .if defined(USE_GMAKE)
-.  if ${_OPSYS_HAS_GMAKE} == "no"
-BUILD_DEPENDS+=		gmake>=3.78:../../devel/gmake
-.  endif
+_USE_GMAKE=		yes
+.endif
+
+.if defined(_USE_GMAKE)
 MAKE_PROGRAM=		${GMAKE}
-.else
-.  if defined(USE_IMAKE)
+.elif defined(USE_IMAKE)
 MAKE_PROGRAM=		${_IMAKE_MAKE}
-.  else
+.else
 MAKE_PROGRAM=		${MAKE}
-.  endif
 .endif
 CONFIGURE_ENV+=		MAKE="${MAKE_PROGRAM}"
 
@@ -4324,7 +4330,7 @@
 .  if defined(USE_PERL5) && (${USE_PERL5} == "run")
 	@${ECHO} "PERL=`${PERL5} --version 2>/dev/null | ${GREP} 'This is perl'`" >> ${BUILD_INFO_FILE}
 .  endif
-.  ifdef USE_GMAKE
+.  ifdef _USE_GMAKE
 	@${ECHO} "GMAKE=`${GMAKE} --version | ${GREP} Make`" >> ${BUILD_INFO_FILE}
 .  endif
 .  if ${CHECK_SHLIBS} == "YES"
Index: defs.Darwin.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/defs.Darwin.mk,v
retrieving revision 1.51
diff -u -r1.51 defs.Darwin.mk
--- defs.Darwin.mk	2003/08/23 09:07:07	1.51
+++ defs.Darwin.mk	2003/08/26 04:10:08
@@ -103,7 +103,6 @@
 
 _DO_SHLIB_CHECKS=	yes	# on installation, fixup PLIST for shared libs
 _IMAKE_MAKE=		${MAKE}	# program which gets invoked by imake
-_OPSYS_HAS_GMAKE=	yes	# GNU make is standard
 .if ${OS_VERSION} >= 6.0
 _OPSYS_HAS_INET6=	yes	# IPv6 is standard
 .else
Index: defs.FreeBSD.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/defs.FreeBSD.mk,v
retrieving revision 1.21
diff -u -r1.21 defs.FreeBSD.mk
--- defs.FreeBSD.mk	2003/04/15 05:29:46	1.21
+++ defs.FreeBSD.mk	2003/08/26 04:10:08
@@ -118,7 +118,6 @@
 
 _DO_SHLIB_CHECKS=	yes	# fixup PLIST for shared libs/run ldconfig
 _IMAKE_MAKE=		${MAKE}	# program which gets invoked by imake
-_OPSYS_HAS_GMAKE=	no	# GNU make is not standard
 .if exists(/usr/include/netinet6)
 _OPSYS_HAS_INET6=	yes	# IPv6 is standard
 .else
Index: defs.IRIX.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/defs.IRIX.mk,v
retrieving revision 1.30
diff -u -r1.30 defs.IRIX.mk
--- defs.IRIX.mk	2003/07/11 15:40:19	1.30
+++ defs.IRIX.mk	2003/08/26 04:10:08
@@ -107,7 +107,6 @@
 
 _DO_SHLIB_CHECKS=	yes		# fixup PLIST for shared libs
 _IMAKE_MAKE=		${MAKE}		# program which gets invoked by imake
-_OPSYS_HAS_GMAKE=	no		# GNU make is not standard
 .if exists(/usr/include/netinet6)
 _OPSYS_HAS_INET6=	yes		# IPv6 is standard
 .else
Index: defs.Linux.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/defs.Linux.mk,v
retrieving revision 1.55
diff -u -r1.55 defs.Linux.mk
--- defs.Linux.mk	2003/08/25 15:47:15	1.55
+++ defs.Linux.mk	2003/08/26 04:10:09
@@ -39,10 +39,9 @@
 FIND?=		/usr/bin/find
 .if exists(/usr/bin/make)
 GMAKE?=		/usr/bin/make
-_OPSYS_HAS_GMAKE=	yes 		# GNU make is standard
+_TOOLS_OPSYS_HAS_GNU.make+=	${MACHINE_PLATFORM}
 .else
 GMAKE?=		${LOCALBASE}/bin/gmake
-_OPSYS_HAS_GMAKE=	no		# rare, but possible
 .endif
 .if exists(/bin/grep)
 GREP?=		/bin/grep
Index: defs.NetBSD.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/defs.NetBSD.mk,v
retrieving revision 1.50
diff -u -r1.50 defs.NetBSD.mk
--- defs.NetBSD.mk	2003/07/23 20:13:47	1.50
+++ defs.NetBSD.mk	2003/08/26 04:10:09
@@ -114,7 +114,6 @@
 
 _DO_SHLIB_CHECKS=	yes	# fixup PLIST for shared libs/run ldconfig
 _IMAKE_MAKE=		${MAKE}	# program which gets invoked by imake
-_OPSYS_HAS_GMAKE=	no	# GNU make is not standard
 .if exists(/usr/include/netinet6)
 _OPSYS_HAS_INET6=	yes	# IPv6 is standard
 .else
Index: defs.OpenBSD.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/defs.OpenBSD.mk,v
retrieving revision 1.17
diff -u -r1.17 defs.OpenBSD.mk
--- defs.OpenBSD.mk	2003/04/15 05:29:47	1.17
+++ defs.OpenBSD.mk	2003/08/26 04:10:09
@@ -110,7 +110,6 @@
 
 _DO_SHLIB_CHECKS=	yes	# fixup PLIST for shared libs/run ldconfig
 _IMAKE_MAKE=		${MAKE}	# program which gets invoked by imake
-_OPSYS_HAS_GMAKE=	no	# GNU make is not standard
 .if exists(/usr/include/netinet6)
 _OPSYS_HAS_INET6=	yes	# IPv6 is standard
 .else
Index: defs.SunOS.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/defs.SunOS.mk,v
retrieving revision 1.63
diff -u -r1.63 defs.SunOS.mk
--- defs.SunOS.mk	2003/08/21 11:59:22	1.63
+++ defs.SunOS.mk	2003/08/26 04:10:09
@@ -118,7 +118,6 @@
 
 _DO_SHLIB_CHECKS=	yes		# fixup PLIST for shared libs
 _IMAKE_MAKE=	/usr/ccs/bin/make	# program which gets invoked by imake
-_OPSYS_HAS_GMAKE=	no		# GNU make is not standard
 .if exists(/usr/include/netinet/ip6.h)
 _OPSYS_HAS_INET6=	yes		# IPv6 is standard
 .else
Index: tools.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/tools.mk,v
retrieving revision 1.9
diff -u -r1.9 tools.mk
--- tools.mk	2003/08/17 04:06:36	1.9
+++ tools.mk	2003/08/26 04:10:09
@@ -113,7 +113,7 @@
 # defining e.g. USE_GNU_TOOLS+="awk sed".  Version numbers are not
 # considered.
 
-_TOOLS=		awk grep sed
+_TOOLS=		awk grep make sed
 
 .if defined(_IGNORE_USE_GNU_TOOLS)
 USE_GNU_TOOLS:=		# empty
@@ -128,6 +128,7 @@
 _TOOLS_OPSYS_HAS_GNU.awk+=	FreeBSD-*-* Linux-*-* NetBSD-*-* OpenBSD-*-*
 _TOOLS_OPSYS_HAS_GNU.grep+=	Darwin-*-* FreeBSD-*-* Linux-*-*
 _TOOLS_OPSYS_HAS_GNU.grep+=	NetBSD-*-* OpenBSD-*-*
+_TOOLS_OPSYS_HAS_GNU.make+=	Darwin-*-*
 _TOOLS_OPSYS_HAS_GNU.sed+=	Linux-*-*
 
 # These platforms have GNUish versions of the tools available in the base
@@ -137,6 +138,7 @@
 #
 _TOOLS_REPLACE_OPSYS.awk+=	SunOS-*-*
 _TOOLS_REPLACE_OPSYS.grep+=	SunOS-*-*
+_TOOLS_REPLACE_OPSYS.make+=	# empty
 _TOOLS_REPLACE_OPSYS.sed+=	SunOS-*-*
 
 # These platforms have completely unusable versions of these tools, and
@@ -144,6 +146,7 @@
 #
 _TOOLS_OPSYS_INCOMPAT.awk+=	# empty
 _TOOLS_OPSYS_INCOMPAT.grep+=	# empty
+_TOOLS_OPSYS_INCOMPAT.make+=	# empty
 _TOOLS_OPSYS_INCOMPAT.sed+=	# empty
 
 # Default to not requiring GNU tools.
@@ -214,6 +217,21 @@
 MAKEFLAGS+=		_IGNORE_USE_GNU_TOOLS=
 .endif
 
+.if ${_TOOLS_REPLACE.make} == "YES"
+_TOOLS_OVERRIDE.make=	YES
+_TOOLS_PROGNAME.make=	${GMAKE}
+.endif
+.if (${_TOOLS_NEED_GNU.make} == "YES") && empty(PKGPATH:Mdevel/gmake)
+BUILD_DEPENDS+=		gmake>=3.78:../../devel/gmake
+_TOOLS_OVERRIDE.make=	YES
+_TOOLS_PROGNAME.make=	${LOCALBASE}/bin/${GNU_PROGRAM_PREFIX}make
+GREP:=			${_TOOLS_PROGNAME.make}
+.endif
+.if !empty(PKGPATH:Mdevel/gmake)
+_TOOLS_OVERRIDE.make=	NO
+MAKEFLAGS+=		_IGNORE_USE_GNU_TOOLS=
+.endif
+
 .if ${_TOOLS_REPLACE.sed} == "YES"
 _TOOLS_OVERRIDE.sed=	YES
 _TOOLS_PROGNAME.sed=	${SED}
@@ -245,5 +263,21 @@
 	fi
 .  endif
 .endfor
+
+# Always provide a symlink from ${TOOLS_DIR}/bin/make to the "make"
+# used to build the package.  The following only creates the symlink
+# if GNU make isn't required (and already symlinked from above).
+#
+override-tools: ${TOOLS_DIR}/bin/make
+
+.if !target(${TOOLS_DIR}/bin/make)
+${TOOLS_DIR}/bin/make:
+	${_PKG_SILENT}${_PKG_DEBUG}					\
+	src=`${TYPE} ${MAKE_PROGRAM} | ${AWK} '{ print $$NF }'`;	\
+	if [ -x $$src -a ! -f ${.TARGET} ]; then			\
+		${MKDIR} ${.TARGET:H};					\
+		${LN} -sf $$src ${.TARGET};				\
+	fi
+.endif
 
 .endif	# TOOLS_MK

--jRHKVT23PllUwdXP--