fix shared library numbers for OpenBSD. Patch may still change, but it

appears to work fine w/ kde4.

cmake will still generate a libfoo.so (which is useful as a placeholder to
know the lib has been built, since other directories don't have access to
the version number), but it obeys OpenBSD conventions for the actual library
now.

ld does the right thing, namely it ignores the libfoo.so and links against
libfoo.so.5.0 properly.

Also take environment into account to allow the ports tree to override
version numbers.

Todo: logfile of built libraries.
This commit is contained in:
espie 2007-03-26 21:27:44 +00:00
parent 30059c7ebb
commit eab92da0b6
4 changed files with 107 additions and 3 deletions

View File

@ -1,10 +1,10 @@
# $OpenBSD: Makefile,v 1.5 2007/03/23 16:30:35 espie Exp $
# $OpenBSD: Makefile,v 1.6 2007/03/26 21:27:44 espie Exp $
HOMEPAGE= http://www.cmake.org/
CATEGORIES= devel
COMMENT= portable build system
DISTNAME= cmake-2.4.6
PKGNAME= ${DISTNAME}p0
PKGNAME= ${DISTNAME}p1
MASTER_SITES= ${HOMEPAGE}files/v2.4/
MAINTAINER= Marc Espie <espie@openbsd.org>

View File

@ -1,7 +1,12 @@
# $OpenBSD: cmake.port.mk,v 1.1.1.1 2006/07/20 09:23:13 espie Exp $
# $OpenBSD: cmake.port.mk,v 1.2 2007/03/26 21:27:44 espie Exp $
BUILD_DEPENDS+= ::devel/cmake
.for _n _v in ${SHARED_LIBS}
CONFIGURE_ENV+=LIB${_n}_VERSION=${_v}
MAKE_ENV+=LIB${_n}_VERSION=${_v}
.endfor
.if empty(CONFIGURE_STYLE)
CONFIGURE_STYLE= cmake
.endif
@ -11,3 +16,4 @@ MODCMAKE_configure= cd ${WRKBUILD} && ${_SYSTRACE_CMD} ${SETENV} \
${CONFIGURE_ENV} ${LOCALBASE}/bin/cmake ${CONFIGURE_ARGS} ${WRKSRC}
REGRESS_TARGET?= test

View File

@ -0,0 +1,48 @@
$OpenBSD: patch-Source_cmFileCommand_cxx,v 1.1 2007/03/26 21:27:44 espie Exp $
--- Source/cmFileCommand.cxx.orig Mon Mar 26 00:39:17 2007
+++ Source/cmFileCommand.cxx Mon Mar 26 02:13:02 2007
@@ -1207,10 +1207,44 @@ bool cmFileCommand::HandleInstallCommand(
std::string libname = toFile;
std::string soname = toFile;
std::string soname_nopath = fromName;
+#if defined(__OpenBSD__)
+ // need to tweak version for our shared libraries
+ std::string myversion = lib_version;
+ if (itype == cmTarget::SHARED_LIBRARY) {
+ // namely, transform version from 5.0.0 -> 5.0
+
+ int j = 0;
+
+ for (int i = 0; i < myversion.size(); i++) {
+ if (myversion[i] == '.') {
+ j++;
+ if (j == 2) {
+ myversion.erase(i);
+ break;
+ }
+ }
+ }
+ int n = fromName.length();
+ if (fromName.compare(0, 3, "lib") == 0 &&
+ fromName.compare(n-3, n, ".so") == 0) {
+ std::string base = fromName.substr(3, n-6);
+ // if the env says so, produce a tweaked version number instead
+ std::string v = "LIB" +base + "_VERSION";
+ char *tweaked = ::getenv(v.c_str());
+ if (tweaked)
+ myversion = tweaked;
+ }
+ }
+ this->ComputeVersionedName(soname, myversion.c_str());
+ this->ComputeVersionedName(soname_nopath, myversion.c_str());
+ this->ComputeVersionedName(fromName, myversion.c_str());
+ this->ComputeVersionedName(toFile, myversion.c_str());
+#else
this->ComputeVersionedName(soname, lib_soversion);
this->ComputeVersionedName(soname_nopath, lib_soversion);
this->ComputeVersionedName(fromName, lib_version);
this->ComputeVersionedName(toFile, lib_version);
+#endif
cmSystemTools::RemoveFile(soname.c_str());
cmSystemTools::RemoveFile(libname.c_str());

View File

@ -0,0 +1,50 @@
$OpenBSD: patch-Source_cmTarget_cxx,v 1.1 2007/03/26 21:27:44 espie Exp $
--- Source/cmTarget.cxx.orig Wed Jan 10 18:59:13 2007
+++ Source/cmTarget.cxx Sun Mar 25 18:01:32 2007
@@ -1459,6 +1459,46 @@ void cmTarget::GetLibraryNamesInternal(std::string& na
realName += suffix;
#endif
+#if defined(__OpenBSD__)
+ // need to tweak version for our shared libraries
+ if (type == cmTarget::SHARED_LIBRARY) {
+ if (version) {
+ // namely, transform version from 5.0.0 -> 5.0
+ std::string myversion = version;
+
+ int j = 0;
+
+ for (int i = 0; i < myversion.size(); i++) {
+ if (myversion[i] == '.') {
+ j++;
+ if (j == 2) {
+ myversion.erase(i);
+ break;
+ }
+ }
+ }
+ // if the env says so, produce a tweaked version number instead
+ std::string v = "LIB" +base + "_VERSION";
+ char *tweaked = ::getenv(v.c_str());
+#if 0
+ char *logname = ::getenv("SHARED_LIBS_LOG");
+ if (logname) {
+ std::ofstream logfile(logname, std::ios_base::out | std::ios_base::app);
+ if (logfile)
+ logfile << "SHARED_LIBS += " << base << " "
+ << tweaked << " # " << myversion << "\n";
+ }
+#endif
+ if (tweaked)
+ myversion = tweaked;
+ else
+ tweaked = "";
+ // all our shared libs have major.number, no links
+ realName = prefix+base+".so."+myversion;
+ soName = realName;
+ }
+ }
+#endif
// The import library name.
if(type == cmTarget::SHARED_LIBRARY)
{