Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Dec 1999 19:07:51 -0800
From:      Jeremy Lea <reg@shale.csir.co.za>
To:        freebsd-ports@freebsd.org
Subject:   RFC: Optional dependencies.
Message-ID:  <19991206190751.E82697@shale.csir.co.za>

next in thread | raw e-mail | index | archive | help
Hi all,

I've been working on a patch to add optional dependencies for GTK+ and
GNOME to ports.  Below is a first cut of bsd.optional.mk.  The way that
this is used is e.g.:

.include <bsd.optional.mk>

pre-configure: msg-option-gtk

.if defined(HAVE_GTK) && ${HAVE_GTK} != "no"
USE_GTK=	yes
.endif

This could be in bsd.port.pre.mk, but it might need to be before an
optional setting of USE_X_PREFIX, which must be set before then.  Other
alternatives are to have an "option.mk" in /usr/ports/x11/gnome (for
example) and include that, although ${PORTSDIR} is not defined until
bsd.port{.pre|.post|}.mk is included.

Notice the fairly strict definintions of WITH_*, HAVE_* and USE_*, which
I would like to apply to all ports with optional depends.

Regards,
 -Jeremy

/usr/ports/Mk/bsd.optional.mk:
#-*- mode: Fundamental; tab-width: 4; -*-
# ex:ts=4
#
# $FreeBSD: $
#	$NetBSD: $
#
# Please view me with 4 column tabs!

# This file keeps tests for optional software.  To use these, include this
# file where you would normally include <bsd.port.pre.mk>, and after that
# file if you need to use it. This works with three sets of variables,
# WITH_, HAVE_ and USE_.  WITH_ variables are used to determine if a package
# is wanted, HAVE_ variables determine what is or will be installed.
# A port should never set any WITH_ variables in it's Makefile. This file
# does not set any USE_ variables, these must be set explictly
# based on the results of this file.  Other than the setting of HAVE_
# variables the only side effect of this file is to define a some message
# targets which inform the user that the port has optional dependancies. 
# These targets must also be called explictly from the port's Makefile.

# The following defines are for the various levels of libraries in the
# GLib/GTK+/GNOME group of software. There are the following options:
#
# WITH_GLIB, WITH_GTK, WITH_IMLIB, WITH_GNOME:
#	yes		- Only set by the user, indicates that they always want
#			  this setting.
#	no		- Only set by the user, indicates that they never want
#			  this setting.
#
# The following variables might be set:
#
# HAVE_GLIB, HAVE_GTK:
#	no		- WITH_GLIB/WITH_GTK set to no.
#	10		- found GTK+ 1.0.x.
#	12		- found GLib/GTK+ 1.2.x or WITH_GLIB/WITH_GTK set to yes.
# HAVE_IMLIB:
#	no		- WITH_IMLIB set to no.
#	yes		- either found imlib or WITH_IMLIB set to yes.
# HAVE_GNOME:
#	no		- WITH_GNOME set to no.
#	libs	- found gnome-libs.
#	core	- found gnome-core or WITH_GNOME set to yes.
#	control - found gnome-controlcenter.

.if defined(WITH_GLIB)
.if ${WITH_GLIB} == "yes"
HAVE_GLIB=		12
.else
HAVE_GLIB=		no
.endif
.else
TEST_LIB:=	`${LDCONFIG} -r | ${GREP} -qF -e "-lglib12"`
.if !empty(TEST_LIB)
HAVE_GLIB=		12
.endif
.endif
.if !target(msg-option-glib)
msg-option-glib:
.if !defined(HAVE_GLIB) && !defined(QUIET_OPTIONS)
	@${ECHO_MSG} ""
	@${ECHO_MSG} "If you want to compile with GLib support,"
	@${ECHO_MSG} "hit Ctrl-C right now and use \"make WITH_GLIB=yes\""
	@${ECHO_MSG} ""
.endif
.endif

.if defined(WITH_GTK)
.if ${WITH_GTK} == "yes"
HAVE_GTK=		12
.else
HAVE_GTK=		no
.endif
.else
TEST_LIB12:=	`${LDCONFIG} -r | ${GREP} -qF -e "-lgtk12"`
TEST_LIB10:=	`${LDCONFIG} -r | ${GREP} -qF -e "-lgtk10"`
.if   !empty(TEST_LIB12)
HAVE_GTK=		12
.elif !empty(TEST_LIB10)
HAVE_GTK=		10
.endif
.endif
.if !target(msg-option-gtk)
msg-option-gtk: msg-option-glib
.if !defined(HAVE_GTK) && !defined(QUIET_OPTIONS)
	@${ECHO_MSG} ""
	@${ECHO_MSG} "If you want to compile with GTK+ support,"
	@${ECHO_MSG} "hit Ctrl-C right now and use \"make WITH_GTK=yes\""
	@${ECHO_MSG} ""
.endif
.endif

.if defined(WITH_IMLIB)
.if ${WITH_IMLIB} == "yes"
HAVE_IMLIB=		yes
.else
HAVE_IMLIB=		no
.endif
.else
TEST_LIB:=	`${LDCONFIG} -r | ${GREP} -qF -e "-lImlib"`
.if !empty(TEST_LIB)
HAVE_IMLIB=		yes
.endif
.endif
.if !target(msg-option-imlib)
msg-option-imlib: msg-option-gtk
.if !defined(HAVE_IMLIB) && !defined(QUIET_OPTIONS)
	@${ECHO_MSG} ""
	@${ECHO_MSG} "If you want to compile with Imlib support,"
	@${ECHO_MSG} "hit Ctrl-C right now and use \"make WITH_IMLIB=yes\""
	@${ECHO_MSG} ""
.endif
.endif

.if defined(WITH_GNOME)
.if ${WITH_GNOME} == "yes"
HAVE_GNOME=		core
.else
HAVE_GNOME=		no
.endif
.else
TEST_CONTROL:=	`${LDCONFIG} -r | ${GREP} -qF -e "-lcapplet"`
TEST_CORE:=		`${LDCONFIG} -r | ${GREP} -qF -e "-lpanel_applet"`
TEST_LIBS:=		`${LDCONFIG} -r | ${GREP} -qF -e "-lgnome"`
.if   !empty(TEST_CONTROL)
HAVE_GNOME=		control
.elif !empty(TEST_CORE)
HAVE_GNOME=		core
.elif !empty(TEST_LIBS)
HAVE_GNOME=		libs
.endif
.endif
.if !target(msg-option-gnome)
msg-option-gnome: msg-option-imlib
.if !defined(HAVE_GNOME) && !defined(QUIET_OPTIONS)
	@${ECHO_MSG} ""
	@${ECHO_MSG} "If you want to compile with GNOME support,"
	@${ECHO_MSG} "hit Ctrl-C right now and use \"make WITH_GNOME=yes\""
	@${ECHO_MSG} ""
.endif
.endif

-- 
  |    What will people think when they hear that I'm a Jesus freak?
--+--  What will people do when they find that it's true?
  |    I don't really care if they label me a Jesus Freak,
  |    There ain't no disguising the truth.  - d c Talk


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19991206190751.E82697>