From freebsd@grem.de  Sat Jul 21 02:25:41 2012
Return-Path: <freebsd@grem.de>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 416BC1065673
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 21 Jul 2012 02:25:41 +0000 (UTC)
	(envelope-from freebsd@grem.de)
Received: from mail.grem.de (outcast.grem.de [213.239.217.27])
	by mx1.freebsd.org (Postfix) with SMTP id 64A1A8FC0C
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 21 Jul 2012 02:25:39 +0000 (UTC)
Received: (qmail 16561 invoked by uid 0); 21 Jul 2012 02:18:57 -0000
Message-Id: <20120721021857.16560.qmail@mail.grem.de>
Date: 21 Jul 2012 02:18:57 -0000
From: Michael Gmelin <freebsd@grem.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc: delphij@FreeBSD.org
Subject: [PATCH] security/cryptopp: Optional build of shared library version
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         170045
>Category:       ports
>Synopsis:       [PATCH] security/cryptopp: Optional build of shared library version
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    delphij
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jul 21 02:30:14 UTC 2012
>Closed-Date:    Mon Jul 23 22:46:45 UTC 2012
>Last-Modified:  Mon Jul 23 23:30:15 UTC 2012
>Originator:     Michael Gmelin
>Release:        FreeBSD 8.2-RELEASE-p1 amd64
>Organization:
Grem Equity GmbH
>Environment:
System: FreeBSD srv06 8.2-RELEASE-p1 FreeBSD 8.2-RELEASE-p1 #0 r221593: Sat May  7 15:12:25
>Description:
Crypto++ includes a shared library target, which is helpful for certain use
cases (including dlopen/dlclose and RTLD_GLOBAL). The FreeBSD port should
allow to facilitate this.

See also:
http://www.cryptopp.com/wiki/Linux#Shared_objects

Port maintainer (delphij@FreeBSD.org) is cc'd.

Generated with FreeBSD Port Tools 0.99_6 (mode: change, diff: suffix)
>How-To-Repeat:
>Fix:
This patch adds a STATIC option, which is enabled by default; future
versions of the port might change the default to disabled, for the time
being it seems more reasonable this way, so current users of cryptopp won't
experience unpleasant surprises on update.

In absence of an official dynamic library versioning scheme upstream the
shared library interface version starts at 0 (so the shared libraries are
installed as libcryptopp.so -> libcryptopp.so.0 -> libcryptopp.so.5.6.1).

Building the dynamic library version adds -fPIC to CXXFLAGS.

The port now uses new-style options and a new option THREADS has been added
to allow thread-safe compilation. This is enabled by default, which - in
practice - only affects the dynamic library version. The change to the
patch to GNUMakefile allows passing of linker options to the shared library
target.

--- cryptopp-5.6.1_2.patch begins here ---
diff -ruN --exclude=CVS ../cryptopp.orig/Makefile ./Makefile
--- ../cryptopp.orig/Makefile	2011-11-10 05:38:32.000000000 +0000
+++ ./Makefile	2012-07-21 01:45:34.103056664 +0000
@@ -7,7 +7,7 @@
 
 PORTNAME=		cryptopp
 PORTVERSION=		5.6.1
-PORTREVISION=		1
+PORTREVISION=		2
 CATEGORIES=		security
 MASTER_SITES=		SF \
 			http://www.cryptopp.com/
@@ -16,6 +16,12 @@
 MAINTAINER=		delphij@FreeBSD.org
 COMMENT=		A free C++ class library of Cryptographic Primitives
 
+OPTIONS_DEFINE=		DEBUG DOCS STATIC THREADS
+OPTIONS_DEFAULT=	STATIC THREADS
+STATIC_DESC=		Build static version only (no shared libs)
+
+.include <bsd.port.options.mk>
+
 NO_WRKSUBDIR=		yes
 USE_ZIP=		yes
 EXTRACT_BEFORE_ARGS=	-aq
@@ -23,8 +29,26 @@
 MAKE_JOBS_SAFE=		yes
 MAKEFILE=		GNUmakefile
 
-.if !defined(WITH_DEBUG)
-CXXFLAGS+=	-DNDEBUG
+LIBVERSION=		0
+PLIST_SUB+=		LIBVERSION=${LIBVERSION}
+PLIST_SUB+=		PORTVERSION=${PORTVERSION}
+
+.if ${PORT_OPTIONS:MDEBUG}
+CXXFLAGS+=		-DNDEBUG
+.endif
+
+.if ${PORT_OPTIONS:MSTATIC}
+PLIST_SUB+=		DYNAMIC_ENABLED="@comment "
+.else
+PLIST_SUB+=		DYNAMIC_ENABLED=""
+MAKE_ARGS=		all libcryptopp.so
+CXXFLAGS+=		-fPIC
+USE_LDCONFIG=		yes
+.endif
+
+.if ${PORT_OPTIONS:MTHREADS}
+CXXFLAGS+=		${PTHREAD_CFLAGS}
+LDFLAGS+=		${PTHREAD_LIBS}
 .endif
 
 do-install:
@@ -36,7 +60,12 @@
 			-and -not -name 'resource.h'`; do \
 		${INSTALL_DATA} $$i ${PREFIX}/include/cryptopp; \
 	done)
-.if !defined(NOPORTDOCS)
+.if !${PORT_OPTIONS:MSTATIC}
+	${INSTALL_LIB} ${WRKSRC}/libcryptopp.so ${PREFIX}/lib/libcryptopp.so.${PORTVERSION}
+	${LN} -fs libcryptopp.so.${PORTVERSION} ${PREFIX}/lib/libcryptopp.so.${LIBVERSION}
+	${LN} -fs libcryptopp.so.${LIBVERSION} ${PREFIX}/lib/libcryptopp.so
+.endif
+.if ${PORT_OPTIONS:MDOCS}
 	${MKDIR} ${PREFIX}/share/doc/cryptopp
 	${CP} ${WRKSRC}/Readme.txt ${PREFIX}/share/doc/cryptopp/README
 	${CP} ${WRKSRC}/License.txt ${PREFIX}/share/doc/cryptopp/License
diff -ruN --exclude=CVS ../cryptopp.orig/files/patch-GNUmakefile ./files/patch-GNUmakefile
--- ../cryptopp.orig/files/patch-GNUmakefile	2011-01-27 20:47:30.000000000 +0000
+++ ./files/patch-GNUmakefile	2012-07-21 01:35:28.726776901 +0000
@@ -1,5 +1,5 @@
 --- ./GNUmakefile.orig	2010-08-09 14:22:42.000000000 -0700
-+++ ./GNUmakefile	2011-01-27 12:43:08.905856979 -0800
++++ ./GNUmakefile	2012-07-21 03:14:01.000000000 +0200
 @@ -1,4 +1,4 @@
 -CXXFLAGS = -DNDEBUG -g -O2
 +#CXXFLAGS = -DNDEBUG -g -O2
@@ -19,3 +19,12 @@
  ISMINGW = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "mingw")
  
  ifneq ($(GCC42_OR_LATER),0)
+@@ -151,7 +151,7 @@
+	$(RANLIB) $@
+ 
+ libcryptopp.so: $(LIBOBJS)
+-	$(CXX) -shared -o $@ $(LIBOBJS)
++	$(CXX) -shared -o $@ $(CXXFLAGS) $(LDFLAGS) $(LIBOBJS)
+ 
+ cryptest.exe: libcryptopp.a $(TESTOBJS)
+	$(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) -L. -lcryptopp $(LDFLAGS) $(LDLIBS)
diff -ruN --exclude=CVS ../cryptopp.orig/pkg-plist ./pkg-plist
--- ../cryptopp.orig/pkg-plist	2009-03-27 00:02:32.000000000 +0000
+++ ./pkg-plist	2012-07-21 01:45:34.102055960 +0000
@@ -132,6 +132,9 @@
 include/cryptopp/zinflate.h
 include/cryptopp/zlib.h
 lib/libcryptopp.a
+%%DYNAMIC_ENABLED%%lib/libcryptopp.so
+%%DYNAMIC_ENABLED%%lib/libcryptopp.so.%%LIBVERSION%%
+%%DYNAMIC_ENABLED%%lib/libcryptopp.so.%%PORTVERSION%%
 @dirrm include/cryptopp
 %%PORTDOCS%%%%DOCSDIR%%/README
 %%PORTDOCS%%%%DOCSDIR%%/License
--- cryptopp-5.6.1_2.patch ends here ---

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->delphij 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Sat Jul 21 02:30:46 UTC 2012 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=170045 
State-Changed-From-To: open->closed 
State-Changed-By: delphij 
State-Changed-When: Mon Jul 23 22:45:22 UTC 2012 
State-Changed-Why:  
Committed, thanks! 

(Note that the original submission gets DEBUG handling the 
different way, making it -DNDEBUG when DEBUG is desired, 
fixed in the commit). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=170045 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/170045: commit references a PR
Date: Mon, 23 Jul 2012 22:44:48 +0000 (UTC)

 Author: delphij
 Date: Mon Jul 23 22:44:33 2012
 New Revision: 301416
 URL: http://svn.freebsd.org/changeset/ports/301416
 
 Log:
   Make it possible to build and install shared library of crypto++, and
   convert to use OPTIONSng [1].
   
   While I'm there, also add an option to build with GCC 4.6.x and newer
   binutils, which enables use of AES-NI.
   
   PR:		ports/170045
   Submitted by:	Michael Gmelin <freebsd grem.de>
 
 Modified:
   head/security/cryptopp/Makefile
   head/security/cryptopp/files/patch-GNUmakefile
   head/security/cryptopp/pkg-plist
 
 Modified: head/security/cryptopp/Makefile
 ==============================================================================
 --- head/security/cryptopp/Makefile	Mon Jul 23 21:19:52 2012	(r301415)
 +++ head/security/cryptopp/Makefile	Mon Jul 23 22:44:33 2012	(r301416)
 @@ -7,7 +7,7 @@
  
  PORTNAME=		cryptopp
  PORTVERSION=		5.6.1
 -PORTREVISION=		1
 +PORTREVISION=		2
  CATEGORIES=		security
  MASTER_SITES=		SF \
  			http://www.cryptopp.com/
 @@ -16,6 +16,13 @@ DISTNAME=		cryptopp${PORTVERSION:S/.//g}
  MAINTAINER=		delphij@FreeBSD.org
  COMMENT=		A free C++ class library of Cryptographic Primitives
  
 +OPTIONS_DEFINE=		DEBUG DOCS GCC46 STATIC THREADS
 +OPTIONS_DEFAULT=	STATIC THREADS
 +STATIC_DESC=		Build static version only (no shared libs)
 +GCC46_DESC=		Build with GCC 4.6+
 +
 +.include <bsd.port.options.mk>
 +
  NO_WRKSUBDIR=		yes
  USE_ZIP=		yes
  EXTRACT_BEFORE_ARGS=	-aq
 @@ -23,8 +30,30 @@ USE_GMAKE=		yes
  MAKE_JOBS_SAFE=		yes
  MAKEFILE=		GNUmakefile
  
 -.if !defined(WITH_DEBUG)
 -CXXFLAGS+=	-DNDEBUG
 +LIBVERSION=		0
 +PLIST_SUB+=		LIBVERSION=${LIBVERSION}
 +PLIST_SUB+=		PORTVERSION=${PORTVERSION}
 +
 +.if !${PORT_OPTIONS:MDEBUG}
 +CXXFLAGS+=		-DNDEBUG
 +.endif
 +
 +.if ${PORT_OPTIONS:MGCC46}
 +USE_GCC=		4.6+
 +.endif
 +
 +.if ${PORT_OPTIONS:MSTATIC}
 +PLIST_SUB+=		DYNAMIC_ENABLED="@comment "
 +.else
 +PLIST_SUB+=		DYNAMIC_ENABLED=""
 +MAKE_ARGS=		all libcryptopp.so
 +CXXFLAGS+=		-fPIC
 +USE_LDCONFIG=		yes
 +.endif
 +
 +.if ${PORT_OPTIONS:MTHREADS}
 +CXXFLAGS+=		${PTHREAD_CFLAGS}
 +LDFLAGS+=		${PTHREAD_LIBS}
  .endif
  
  do-install:
 @@ -36,7 +65,12 @@ do-install:
  			-and -not -name 'resource.h'`; do \
  		${INSTALL_DATA} $$i ${PREFIX}/include/cryptopp; \
  	done)
 -.if !defined(NOPORTDOCS)
 +.if !${PORT_OPTIONS:MSTATIC}
 +	${INSTALL_LIB} ${WRKSRC}/libcryptopp.so ${PREFIX}/lib/libcryptopp.so.${PORTVERSION}
 +	${LN} -fs libcryptopp.so.${PORTVERSION} ${PREFIX}/lib/libcryptopp.so.${LIBVERSION}
 +	${LN} -fs libcryptopp.so.${LIBVERSION} ${PREFIX}/lib/libcryptopp.so
 +.endif
 +.if ${PORT_OPTIONS:MDOCS}
  	${MKDIR} ${PREFIX}/share/doc/cryptopp
  	${CP} ${WRKSRC}/Readme.txt ${PREFIX}/share/doc/cryptopp/README
  	${CP} ${WRKSRC}/License.txt ${PREFIX}/share/doc/cryptopp/License
 
 Modified: head/security/cryptopp/files/patch-GNUmakefile
 ==============================================================================
 --- head/security/cryptopp/files/patch-GNUmakefile	Mon Jul 23 21:19:52 2012	(r301415)
 +++ head/security/cryptopp/files/patch-GNUmakefile	Mon Jul 23 22:44:33 2012	(r301416)
 @@ -1,5 +1,5 @@
  --- ./GNUmakefile.orig	2010-08-09 14:22:42.000000000 -0700
 -+++ ./GNUmakefile	2011-01-27 12:43:08.905856979 -0800
 ++++ ./GNUmakefile	2012-07-21 03:14:01.000000000 +0200
  @@ -1,4 +1,4 @@
  -CXXFLAGS = -DNDEBUG -g -O2
  +#CXXFLAGS = -DNDEBUG -g -O2
 @@ -19,3 +19,12 @@
   ISMINGW = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "mingw")
   
   ifneq ($(GCC42_OR_LATER),0)
 +@@ -151,7 +151,7 @@
 +	$(RANLIB) $@
 + 
 + libcryptopp.so: $(LIBOBJS)
 +-	$(CXX) -shared -o $@ $(LIBOBJS)
 ++	$(CXX) -shared -o $@ $(CXXFLAGS) $(LDFLAGS) $(LIBOBJS)
 + 
 + cryptest.exe: libcryptopp.a $(TESTOBJS)
 +	$(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) -L. -lcryptopp $(LDFLAGS) $(LDLIBS)
 
 Modified: head/security/cryptopp/pkg-plist
 ==============================================================================
 --- head/security/cryptopp/pkg-plist	Mon Jul 23 21:19:52 2012	(r301415)
 +++ head/security/cryptopp/pkg-plist	Mon Jul 23 22:44:33 2012	(r301416)
 @@ -132,6 +132,9 @@ include/cryptopp/zdeflate.h
  include/cryptopp/zinflate.h
  include/cryptopp/zlib.h
  lib/libcryptopp.a
 +%%DYNAMIC_ENABLED%%lib/libcryptopp.so
 +%%DYNAMIC_ENABLED%%lib/libcryptopp.so.%%LIBVERSION%%
 +%%DYNAMIC_ENABLED%%lib/libcryptopp.so.%%PORTVERSION%%
  @dirrm include/cryptopp
  %%PORTDOCS%%%%DOCSDIR%%/README
  %%PORTDOCS%%%%DOCSDIR%%/License
 _______________________________________________
 svn-ports-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-ports-all
 To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
 

From: Michael Gmelin <freebsd@grem.de>
To: "bug-followup@FreeBSD.org" <bug-followup@FreeBSD.org>
Cc: "delphij@FreeBSD.org" <delphij@FreeBSD.org>
Subject: Re: ports/170045: [PATCH] security/cryptopp: Optional build of shared library version
Date: Tue, 24 Jul 2012 01:24:11 +0200

 Thanks  for correcting the flaw.
>Unformatted:
