Subject: Re: Preliminary patch for Linux emulation
To: Jeremy C. Reed <reed@reedmedia.net>
From: Johnny C. Lam <jlam@pkgsrc.org>
List: tech-pkg
Date: 12/11/2005 03:21:29
On Sat, Dec 10, 2005 at 01:24:35PM -0800, Jeremy C. Reed wrote:
> Thanks for your work on this. This will be helpful for me on my Linux 
> systems.
> 
> Maybe instead of hardcoding use of including 
> ../../emulators/suse_linux/Makefile.application create some generic 
> ../../mk/linux.mk (or linux-compat.mk) that does some of the same and then 
> (for now) just uses the suse_linux.
> 
> In pkgsrc-wip there is a wip/mk/linuxbin.pkg.mk that also may give some 
> ideas.
> 
> The idea is to later use Debian, Fedora and/or other Linux distributions 
> instead of just SuSE Linux.

I think Joerg's idea of only listing ONLY_FOR_PLATFORM in a single
location is the correct one, and we should definitely move toward
that.  Joerg's posted patch is fairly limited in scope and does fix
up this one problem.  However, it would be really nice if we could
scrap that whole Linux emulation mess and put in something better.

wip/mk/linuxbin.pkg.mk is mostly the right way to do this, but I would
rename it to /usr/pkgsrc/emulators/linux/binpkg.mk and extend it with
something like the code below (completely untested).  The idea is that
a package Makefile for a Linux binary package would include a snippet
like the following:

    USE_LINUX_MODULES=	gtk2 locale openmotif
    .include "../../emulators/linux/binpkg.mk"

I wish I had time to do this, but I don't; however, I hope the idea gets
across and someone else will feel motivated to do the real work.

	Cheers,

	-- Johnny Lam <jlam@pkgsrc.org>



.include "../../mk/bsd.prefs.mk"

# LINUX_DISTRO_DEFAULT is a user-settable variable whose value is the
#	default Linux distribution (in pkgsrc) to use.
#
# LINUX_DISTRO_ACCEPTED is a package-settable list of Linux distributions
#	that may be used by the package.
#
# USE_LINUX_MODULES is a package-settable list of Linux run-time modules
#	that are needed by the package, e.g. x11, gtk, libc5, jpeg, etc.
#
.if ${OPSYS} == "Linux"
LINUX_DISTRO_DEFAULT?=	native
.else
LINUX_DISTRO_DEFAULT?=	suse
.endif
LINUX_DISTRO_ACCEPTED?=	${_LINUX_DISTROS}

# _LINUX_DISTROS is an exhaustive list of all of the linux distributions
#	that we support.
#
_LINUX_DISTROS?=	suse suse91 #slackware

# LINUX_DISTRO is a read-only variable exported by this file that names
#	the chosen Linux distribution.  It is set to "none" if no
#	acceptable distribution can be found.
#
_LINUX_DISTRO_ACCEPTED=	native ${LINUX_DISTRO_ACCEPTED}
.if !empty(_LINUX_DISTRO_ACCEPTED:M${LINUX_DISTRO_DEFAULT})
LINUX_DISTRO=		${LINUX_DISTRO_DEFAULT}
.else
LINUX_DISTRO=		none
.endif

.if ${LINUX_DISTRO} == "none"
PKG_FAIL_REASON=	\
	"${LINUX_DISTRO_DEFAULT} is not an acceptable Linux distribution for ${PKGNAME}."
.else
#
# Include the distribution-specific file that describes which packages
# supply what functionality in various _LINUX_DEPENDS.<mod> variables.
# For example, a the ../../emul/linux/suse91.mk file would contain
# settings like the following:
#
#    _LINUX_DEPENDS.base=  suse_base>=9.1:../../emulators/suse91_base
#    _LINUX_DEPENDS.jpeg=  suse_libjpeg>=9.1:../../emulators/suse91_libjpeg
#    _LINUX_DEPENDS.glx=   suse_glx>=9.1:../../emulators/suse91_glx
#    _LINUX_DEPENDS.x11=   suse_x11>=9.1:../../emulators/suse91_x11
#    # ... etc.
#
.  sinclude "../../emulators/linux/${LINUX_DISTRO}.mk"
.  for _mod_ in ${USE_LINUX_MODULES}
.    if ${LINUX_DISTRO} == "native"
_LINUX_DEPENDS.${_mod_}?=	# "native" Linux supplies everything
.    endif
DEPENDS+=	${_LINUX_DEPENDS.${_mod_}}
.  endfor
.endif