Skip site navigation (1)Skip section navigation (2)
Date:      26 Mar 2003 21:30:03 -0000
From:      Sergei Kolobov <sergei@kolobov.com>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/50323: [PATCH] bsd.port.mk: add USE_GNUGETOPT option
Message-ID:  <20030326213003.4606.qmail@kolobov.com>

next in thread | raw e-mail | index | archive | help

>Number:         50323
>Category:       ports
>Synopsis:       [PATCH] bsd.port.mk: add USE_GNUGETOPT option
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 26 13:30:13 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Sergei Kolobov
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD elf.chetwood.ru 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Sun Mar 16 04:38:45 MSK 2003 root@elf.chetwood.ru:/usr/obj/usr/src/sys/GENERIC i386
>Description:
135 ports depend on getopt_long(3) provided by devel/libgnugetopt port.
Recently, getopt_long(3) has been added to libc in -CURRENT 
(OSVERSION == 500041).

Some 27 of the ports depending on getopt_long(3) try to take advantage of that
and conditionalize their dependency on devel/libgnugetopt port by simply 
checking for presence of /usr/include/getopt.h file:

	.if !exists(/usr/include/getopt.h)
	CONFIGURE_ENV=	CFLAGS="${CFLAGS} -I${LOCALBASE}/include" \
			LDFLAGS="${LDFLAGS} -L${LOCALBASE}/lib -lgnugetopt"
	LIB_DEPENDS=	gnugetopt.1:${PORTSDIR}/devel/libgnugetopt
	.endif

Unfortunately, this is not a correct way of checking for getopt_long(3) 
presence and may cause INDEX build (which is done separately from package
building). Instead, the check should be done against OSVERSION.

To simplify Makefiles of these ports and to avoid code duplication, the 
following patch adds USE_GNUGETOPT option to bsd.port.mk. So, instead of
the Makefile fragment above, the following will be sufficient:

	USE_GNUGETOPT=	yes

The patch was tested under 5.0-CURRENT and 4.8-RC.
>How-To-Repeat:
>Fix:
--- bsd.port.mk-gnugetopt.patch begins here ---
Index: bsd.port.mk
===================================================================
RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.444
diff -u -r1.444 bsd.port.mk
--- bsd.port.mk	22 Mar 2003 04:45:24 -0000	1.444
+++ bsd.port.mk	26 Mar 2003 21:03:07 -0000
@@ -275,6 +275,12 @@
 # LIBTOOLFLAGS	- Additional flags to pass to ltconfig
 #				  (default: --disable-ltlibs)
 ##
+# USE_GNUGETOPT	- Says that the port uses getopt_long. If OSVERSION
+#				  less than 500041, automatically adds devel/libgnugeopt
+#				  to LIB_DEPENDS, and pass adjusted values of 
+#				  CPPFLAGS and LDFLAGS in CONFIGURE_ENV.
+#				  Default: not set.
+##
 # USE_PERL5		- Says that the port uses perl5 for building and running.
 # USE_PERL5_BUILD	- Says that the port uses perl5 for building.
 # USE_PERL5_RUN		- Says that the port uses perl5 for running.
@@ -1252,6 +1258,15 @@
 CC=				gcc32
 CXX=			g++32
 BUILD_DEPENDS+=	gcc32:${PORTSDIR}/lang/gcc32
+.endif
+
+.if defined(USE_GNUGETOPT)
+.if ${OSVERSION} < 500041
+LIB_DEPENDS=	gnugetopt.1:${PORTSDIR}/devel/libgnugetopt
+CPPFLAGS+=		-I${LOCALBASE}/include
+LDFLAGS+=		-L${LOCALBASE}/lib -lgnugetopt
+CONFIGURE_ENV+=	CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}"
+.endif
 .endif
 
 .if defined(USE_LINUX)
--- bsd.port.mk-gnugetopt.patch ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:

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




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