RFC: Mk/bsd.jpeg.mk to automagically handle jpeg dependency

Mario Sergio Fujikawa Ferreira lioux at FreeBSD.org
Wed Jun 16 01:10:10 UTC 2010


	Ever since the addition of graphics/libjpeg-turbo, I had
been wondering how one could possibly build the whole ports tree
with it instead of graphics/jpeg. I wanted the choice.

	Therefore, I wrote the attached bsd.jpeg.mk as a suggestion.

	With it, we just add


to any port that requires a jpeg library (either a build or a link

	It will automagically detected the already installed jpeg
port variant (libjpeg-turbo or jpeg) and depend on it. If the user prefers to set the variant, he can do so using



WITH_JPEG=	libjpeg-turbo

	bsd.jpeg.mk will verify if the selected jpeg port WITH_JPEG
conflicts with an already installed version. If it doesn't, it will
be upheld. Otherwise, it will stop the build and tell the user that
his setting might be incorrect.

	If a jpeg port has been neither installed nor selected
WITH_JPEG, bsd.jpeg.mk will default to the reliable graphics/jpeg

	Therefore, unless instructed otherwise everything will
depend upon graphics/jpeg. Only those systems that explicitly either
install graphics/libjpeg-turbo instead of jpeg OR select
WITH_JPEG=libjpeg-turbo will work differently.

	Let me know what you think.


ps: bsd.jpeg.mk structure is heavily based on bsd.database.mk so
thanks to everyone who contributed to it.

Mario S F Ferreira - DF - Brazil - "I guess this is a signature."
feature, n: a documented bug | bug, n: an undocumented feature
-------------- next part --------------
.if defined(USE_JPEG)

# List of available jpeg ports
_JPEG_PORTS=	jpeg libjpeg-turbo

# Dependence lines for different jpeg versions	
jpeg_DEPENDS=		jpeg.11:${PORTSDIR}/graphics/jpeg
libjpeg-turbo_DEPENDS=	jpeg.62:${PORTSDIR}/graphics/libjpeg-turbo
# Detect jpeg versions by finding some files
jpeg_FIND=		${LOCALBASE}/include/jpegint.h
libjpeg-turbo_FIND=	${LOCALBASE}/include/turbojpeg.h

# Assume the default jpeg version as jpeg

# Try to uphold global WITH_JPEG
. if defined(WITH_JPEG)
. endif

# Detect jpeg port

# Detect installed version
. for jpegx in ${_JPEG_PORTS}
.  if exists(${${jpegx}_FIND}) && ${_JPEG_PORT} == "no"
_JPEG_PORT=	${jpegx}
.  endif
. endfor

# If a library has been neither installed nor selected, defer to
# the default one.
. if !defined(_WITH_JPEG) &&  ${_JPEG_PORT} == "no"
. endif

# If one has been selected, verify it that the selection both is
# correct and does not conflict with the installed one.
. if defined(_WITH_JPEG)

.  if ${_JPEG_PORT} == "no"
# Use selected version if none has already been installed
.   for jpeg in ${_JPEG_PORTS}
.    if ${_WITH_JPEG} == "${jpeg}" && ${_JPEG_PORT} == "no"
_JPEG_PORT=	${jpeg}
.    endif
.   endfor
.  else
# Verify if installed version and selected version conflict
.   if ${_WITH_JPEG} != ${_JPEG_PORT}
IGNORE=		cannot install: selected library ${_WITH_JPEG} conflict with installed ${_JPEG_PORT} one
.   endif
.  endif

. endif

# WITH_JPEG is specified incorrectly, so mark this as IGNORE
. if ${_JPEG_PORT} == "no"
IGNORE=		cannot install: unknown jpeg library selected: ${_WITH_JPEG}
. else
# Now add the dependency on JPEG port ${_JPEG_PORT)
.  if defined(JPEG_BUILD_DEPENDS)
.  else
.  endif

. endif


More information about the freebsd-ports mailing list