From: Dima Pasechnik Subject: Re: lang/sbcl - building and installing libsbcl.so ? To: Theo Buehler , George Koehler , ports@openbsd.org, Sebastien Marie Date: Thu, 25 Apr 2024 22:28:27 +0100 On Thu, Apr 25, 2024 at 12:49:07PM +0100, Stuart Henderson wrote: > On 2024/04/25 10:24, Dima Pasechnik wrote: > > > > 1) Is there a standard way to set up .so's major.minor version > > in the port, and propagate it to the build? > > (hardcoding major.minor in several patched places is a pain, obviously) > > > > In port's makefile I now have a line > > > > SHARED_LIBS += sbcl 0.0 > > > > - is this "0.0" being stored somewhere usable? > > You can use LIBsbcl_VERSION in the port Makefile. This can either > be passed to the build via a make variable (usually preferable) > or by patching (one option is to patch to ${LIBsbcl_VERSION}, > SUBST_VARS+=LIBsbcl_VERSION, and use ${SUBST_CMD} to replace it, perhaps > in a pre-configure target). in the sbcl case, installing libsbcl.so to the right location is done in in a script called install.sh, which is invoked by do-install. So I patch it as in the attached diff (all the updates are there). And I "add" LIBsbcl_VERSION to MAKE_ENV. I get libsbcl.so.0.0 installed, as it should be, as LIBsbcl_VERSION is 0.0. "passing" LIBsbcl_VERSION to install.sh happens via MAKE_ENV. (So it seems I have invented a third way to do this patching :-)) > > 2) What is the easiest way to create acceptable to the build system patches > > in patches/ ? > > I just do "git diff > patchifile" and manually edit patchfile, but > > that's clearly suboptimal. > > Copy the clean original file to have the suffix .orig.port, edit, > then run "make update-patches" from the port dir. If you're using > SUBST_CMD then "update-patches" needs to be run at the right time. > Thanks, that helps. I still don't know how to get PLIST automatically updated with the correct version. Is it done by "make update-plist" whenever the @so version is bumped? Please have a look at the complete update. Thanks, Dima diff --git a/lang/sbcl/Makefile b/lang/sbcl/Makefile index 9c849a70c4e..1cd2a1830e0 100644 --- a/lang/sbcl/Makefile +++ b/lang/sbcl/Makefile @@ -10,6 +10,8 @@ PKGNAME = sbcl-${V} CATEGORIES = lang +SHARED_LIBS += sbcl 0.0 + HOMEPAGE = https://www.sbcl.org/ MAINTAINER = Sebastien Marie @@ -90,7 +92,8 @@ MAKE_ENV += CFLAGS="${CFLAGS} -I${LOCALBASE}/include" \ MAKEINFO=${PREFIX}/bin/gmakeinfo \ MAN_DIR="${PREFIX}/man/" \ INFO_DIR="${PREFIX}/info/" \ - SBCL_MAKE_JOBS="-j${MAKE_JOBS}" + SBCL_MAKE_JOBS="-j${MAKE_JOBS}" \ + LIBsbcl_VERSION="${LIBsbcl_VERSION}" USE_GMAKE = Yes @@ -116,6 +119,8 @@ do-build: --with-sb-core-compression \ --with-sb-xref-for-internals \ ${EXTRA_PARAMS} + umask 022 && cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} \ + /bin/sh ./make-shared-library.sh umask 022 && cd ${WRKSRC}/doc/manual/ && ${SETENV} ${MAKE_ENV} \ ${GMAKE} info diff --git a/lang/sbcl/patches/patch-install_sh b/lang/sbcl/patches/patch-install_sh new file mode 100644 index 00000000000..928e96c12d9 --- /dev/null +++ b/lang/sbcl/patches/patch-install_sh @@ -0,0 +1,14 @@ +- install .so with correct version suffix + +Index: install.sh +--- install.sh.orig ++++ install.sh +@@ -114,7 +114,7 @@ + cp src/runtime/$RUNTIME "$BUILD_ROOT$INSTALL_ROOT"/bin/ + cp output/sbcl.core "$BUILD_ROOT$SBCL_HOME"/sbcl.core + test -f src/runtime/libsbcl.so && \ +- cp src/runtime/libsbcl.so "$BUILD_ROOT$INSTALL_ROOT"/lib/ ++ cp src/runtime/libsbcl.so "$BUILD_ROOT$INSTALL_ROOT"/lib/libsbcl.so.${LIBsbcl_VERSION} + + cp src/runtime/sbcl.mk "$BUILD_ROOT$SBCL_HOME"/sbcl.mk + for i in $(grep '^LIBSBCL=' src/runtime/sbcl.mk | cut -d= -f2-) ; do diff --git a/lang/sbcl/patches/patch-src_runtime_GNUmakefile b/lang/sbcl/patches/patch-src_runtime_GNUmakefile index 887d4d2ff6d..57606994ac3 100644 --- a/lang/sbcl/patches/patch-src_runtime_GNUmakefile +++ b/lang/sbcl/patches/patch-src_runtime_GNUmakefile @@ -4,7 +4,7 @@ Index: src/runtime/GNUmakefile --- src/runtime/GNUmakefile.orig +++ src/runtime/GNUmakefile -@@ -33,7 +33,7 @@ __LDFLAGS__ = +@@ -33,7 +33,7 @@ include ../../output/prefix.def @@ -13,3 +13,14 @@ Index: src/runtime/GNUmakefile ASFLAGS += $(CFLAGS) CPPFLAGS += -I. +@@ -132,8 +132,8 @@ + rm -f $@ ; ar rcs $@ $^ + + PIC_OBJS = $(subst .o,.pic.o,$(OBJS)) +-libsbcl.so: $(PIC_OBJS) +- $(CC) -shared -o $@ $^ $(LIBS) $(SOFLAGS) ++libsbcl.so: $(PIC_OBJS) ++ $(CC) -shared -fPIC -o $@ $^ $(LDFLAGS) $(LIBS) $(SOFLAGS) + # for this to work, you must have with-gcc-tls in your build features already. + # can't define it here because then it conflicts if you have it in both places. + %.pic.o: %.c diff --git a/lang/sbcl/pkg/PLIST b/lang/sbcl/pkg/PLIST index 8eece6b846e..e40b96766f7 100644 --- a/lang/sbcl/pkg/PLIST +++ b/lang/sbcl/pkg/PLIST @@ -2,6 +2,7 @@ @bin bin/sbcl @info info/asdf.info @info info/sbcl.info +@so lib/libsbcl.so.0.0 lib/sbcl/ lib/sbcl/contrib/ lib/sbcl/contrib/asdf.fasl