diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2025-05-26 19:13:41 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska@appnovation.com> | 2025-05-26 19:13:41 +0000 |
| commit | 40ecb28c204049cbb4d0ae8491f62398861fe453 (patch) | |
| tree | ec5c787e4819db703d18e750d32a02b7842d0689 | |
| parent | a7832523b7e309b5e160e1aff0db98d9ad23004b (diff) | |
| download | tipidee-40ecb28c204049cbb4d0ae8491f62398861fe453.tar.gz | |
Support shlibs on MacOS
Signed-off-by: Laurent Bercot <ska@appnovation.com>
| -rw-r--r-- | Makefile | 44 | ||||
| -rw-r--r-- | README.macos | 3 | ||||
| -rwxr-xr-x | configure | 21 | ||||
| -rwxr-xr-x | tools/configure.template | 21 |
4 files changed, 64 insertions, 25 deletions
@@ -25,10 +25,13 @@ LIB_DEFS := BIN_SYMLINKS := TEST_BINS := +-include config.mak +include package/targets.mak + define library_definition -LIB$(1) := lib$(2).$(if $(DO_ALLSTATIC),a,so).xyzzy +LIB$(1) := lib$(2).$(if $(DO_ALLSTATIC),a,$(SHLIB_EXT)).xyzzy ifdef DO_SHARED -SHARED_LIBS += lib$(2).so.xyzzy +SHARED_LIBS += lib$(2).$(SHLIB_EXT).xyzzy endif ifdef DO_STATIC STATIC_LIBS += lib$(2).a.xyzzy @@ -67,9 +70,6 @@ $(DESTDIR)$(1)/$(2): $(DESTDIR)$(1)/$(SYMLINK_TARGET_$(2)) exec $(INSTALL) -l $$(<F) $$@ endef --include config.mak -include package/targets.mak - $(foreach var,$(LIB_DEFS),$(eval $(call library_definition,$(firstword $(subst =, ,$(var))),$(lastword $(subst =, ,$(var)))))) include package/deps.mak @@ -124,7 +124,7 @@ ifneq ($(strip $(ALL_BINS)$(SHARED_LIBS)),) endif install: install-dynlib install-libexec install-bin install-symlinks install-lib install-include install-pkgconfig -install-dynlib: $(SHARED_LIBS:lib%.so.xyzzy=$(DESTDIR)$(dynlibdir)/lib%.so) +install-dynlib: $(SHARED_LIBS:lib%.$(SHLIB_EXT).xyzzy=$(DESTDIR)$(dynlibdir)/lib%.$(SHLIB_EXT)) install-libexec: $(LIBEXEC_TARGETS:%=$(DESTDIR)$(libexecdir)/%) install-bin: $(BIN_TARGETS:%=$(DESTDIR)$(bindir)/%) install-symlinks: $(BIN_SYMLINKS:%=$(DESTDIR)$(bindir)/%) @@ -156,10 +156,10 @@ $(DESTDIR)$(sproot)/library.so/lib%.so.$(version_M): $(DESTDIR)$(dynlibdir)/lib% endif -$(DESTDIR)$(dynlibdir)/lib%.so $(DESTDIR)$(dynlibdir)/lib%.so.$(version_M): lib%.so.xyzzy - $(INSTALL) -D -m 755 $< $@.$(version) && \ - $(INSTALL) -l $(@F).$(version) $@.$(version_M) && \ - exec $(INSTALL) -l $(@F).$(version_M) $@ +$(DESTDIR)$(dynlibdir)/lib%.so $(DESTDIR)$(dynlibdir)/lib%.so.$(version_M) $(DESTDIR)$(dynlibdir)/lib%.so.$(version): lib%.so.xyzzy + $(INSTALL) -D -m 755 $< $(@D)/lib$(*F).so.$(version) && \ + $(INSTALL) -l lib$(*F).so.$(version) $(@D)/lib$(*F).so.$(version_M) && \ + exec $(INSTALL) -l lib$(*F).so.$(version_M) $(@D)/lib$(*F).so $(DESTDIR)$(libdir)/lib%.a: lib%.a.xyzzy exec $(INSTALL) -D -m 644 $< $@ @@ -192,3 +192,27 @@ lib%.so.xyzzy: .PHONY: it all clean distclean tests check tgz strip install install-dynlib install-bin install-lib install-include install-pkgconfig .DELETE_ON_ERROR: + +ifeq ($(SHLIB_EXT),dylib) + +version_X := $(shell exec expr 256 '*' $(version_l) + $(subst .,,$(suffix $(version_M)))) +version_XY := $(version_X)$(suffix $(version_m)) +version_XYZ := $(version_XY)$(suffix $(version)) + +ifneq ($(exthome),) +global-links: $(SHARED_LIBS:lib%.dylib.xyzzy=$(DESTDIR)$(sproot)/library.so/lib%.$(version_X).dylib) + +$(DESTDIR)$(sproot)/library.so/lib%.$(version_X).dylib: $(DESTDIR)$(sproot)/library.so/lib%.$(version_M).dylib + exec $(INSTALL) -l $(<F) $@ +endif + +$(DESTDIR)$(dynlibdir)/lib%.dylib $(DESTDIR)$(dynlibdir)/lib%.$(version_X).dylib $(DESTDIR)$(dynlibdir)/lib%.$(version_M).dylib $(DESTDIR)$(dynlibdir)/lib%.$(version).dylib: lib%.dylib.xyzzy + $(INSTALL) -D -m 755 $< $(@D)/lib$(*F).$(version).dylib && \ + $(INSTALL) -l lib$(*F).$(version).dylib $(@D)/lib$(*F).$(version_M).dylib && \ + $(INSTALL) -l lib$(*F).$(version_M).dylib $(@D)/lib$(*F).$(version_X).dylib && \ + exec $(INSTALL) -l lib$(*F).$(version_X).dylib $(@D)/lib$(*F).dylib + +lib%.dylib.xyzzy: $(ALL_DOBJS) + exec $(CC) -o $@ $(CFLAGS_ALL) $(CFLAGS_SHARED) $(LDFLAGS_ALL) $(LDFLAGS_SHARED) -Wl,-dylib_install_name,$(dynlibdir)/lib$(*F).$(version_M).dylib -Wl,-dylib_compatibility_version,$(version_XY) -Wl,-dylib_current_version,$(version_XYZ) -undefined dynamic_lookup $^ $(EXTRA_LIBS) $(SOCKET_LIB) $(SPAWN_LIB) $(SYSCLOCK_LIB) $(TAINNOW_LIB) $(TIMER_LIB) $(UTIL_LIB) $(LDLIBS) +endif + diff --git a/README.macos b/README.macos deleted file mode 100644 index 9bdfadc..0000000 --- a/README.macos +++ /dev/null @@ -1,3 +0,0 @@ - This package will compile and run on Darwin (MacOS), but the building of -shared libraries is not supported. - Make sure you use the --disable-shared option to configure. @@ -147,6 +147,7 @@ pkgconfdir='$prefix/lib/pkgconfig' shebangdir='$bindir' sysdeps='$prefix/lib/skalibs/sysdeps' manualsysdeps=false +shlibext=so shared=false static=true allpic=true @@ -192,9 +193,9 @@ for arg ; do --disable-shared|--enable-shared=no) shared=false ;; --enable-static|--enable-static=yes) static=true ;; --disable-static|--enable-static=no) static=false ;; - --enable-allstatic|--enable-allstatic=yes) allstatic=true ;; - --disable-allstatic|--enable-allstatic=no) allstatic=false ; evenmorestatic=false ;; - --enable-static-libc|--enable-static-libc=yes) allstatic=true ; evenmorestatic=true ;; + --enable-allstatic|--enable-allstatic=yes) static=true ; allstatic=true ;; + --disable-allstatic|--enable-allstatic=no) allstatic=false ; evenmorestatic=false ; shared=true ;; + --enable-static-libc|--enable-static-libc=yes) static=true ; allstatic=true ; evenmorestatic=true ;; --disable-static-libc|--enable-static-libc=no) evenmorestatic=false ;; --enable-all-pic|--enable-all-pic=yes) allpic=true ;; --disable-all-pic|--enable-all-pic=no) allpic=false ;; @@ -373,11 +374,18 @@ if test ! -d $sysdeps || test ! -f $sysdeps/target ; then echo "$0: error: $sysdeps is not a valid sysdeps directory" exit 1 fi -if [ "x$target" != "x$(cat $sysdeps/target)" ] ; then +if test "$target" != "$(cat $sysdeps/target)" ; then echo "$0: error: target $target does not match the contents of $sysdeps/target" exit 1 fi +echo "Shared libraries will be named ..." +libc="${target##*-}" +if test "${libc##darwin}" != "$libc" ; then + shlibext=dylib +fi +echo " ... *.$shlibext" + if $allpic ; then tryflag CPPFLAGS_AUTO -fPIC fi @@ -467,16 +475,17 @@ LDFLAGS := ${LDFLAGS}${LDFLAGS_POST:+ }$LDFLAGS_POST LDFLAGS_SHARED := $LDFLAGS_SHARED LDFLAGS_NOSHARED :=$LDFLAGS_NOSHARED CROSS_COMPILE := $cross +SHLIB_EXT := ${shlibext} vpath lib%.a$vpaths -vpath lib%.so$vpathd +vpath lib%.${shlibext}$vpathd EOF if $allstatic ; then echo ".LIBPATTERNS := lib%.a" echo "DO_ALLSTATIC := 1" else - echo ".LIBPATTERNS := lib%.so" + echo ".LIBPATTERNS := lib%.${shlibext}" echo "DO_ALLSTATIC :=" fi if $static ; then diff --git a/tools/configure.template b/tools/configure.template index c0e2945..db8f59a 100755 --- a/tools/configure.template +++ b/tools/configure.template @@ -147,6 +147,7 @@ pkgconfdir='$prefix/lib/pkgconfig' shebangdir='$bindir' sysdeps='$prefix/lib/skalibs/sysdeps' manualsysdeps=false +shlibext=so shared=false static=true allpic=true @@ -192,9 +193,9 @@ for arg ; do --disable-shared|--enable-shared=no) shared=false ;; --enable-static|--enable-static=yes) static=true ;; --disable-static|--enable-static=no) static=false ;; - --enable-allstatic|--enable-allstatic=yes) allstatic=true ;; - --disable-allstatic|--enable-allstatic=no) allstatic=false ; evenmorestatic=false ;; - --enable-static-libc|--enable-static-libc=yes) allstatic=true ; evenmorestatic=true ;; + --enable-allstatic|--enable-allstatic=yes) static=true ; allstatic=true ;; + --disable-allstatic|--enable-allstatic=no) allstatic=false ; evenmorestatic=false ; shared=true ;; + --enable-static-libc|--enable-static-libc=yes) static=true ; allstatic=true ; evenmorestatic=true ;; --disable-static-libc|--enable-static-libc=no) evenmorestatic=false ;; --enable-all-pic|--enable-all-pic=yes) allpic=true ;; --disable-all-pic|--enable-all-pic=no) allpic=false ;; @@ -373,11 +374,18 @@ if test ! -d $sysdeps || test ! -f $sysdeps/target ; then echo "$0: error: $sysdeps is not a valid sysdeps directory" exit 1 fi -if [ "x$target" != "x$(cat $sysdeps/target)" ] ; then +if test "$target" != "$(cat $sysdeps/target)" ; then echo "$0: error: target $target does not match the contents of $sysdeps/target" exit 1 fi +echo "Shared libraries will be named ..." +libc="${target##*-}" +if test "${libc##darwin}" != "$libc" ; then + shlibext=dylib +fi +echo " ... *.$shlibext" + if $allpic ; then tryflag CPPFLAGS_AUTO -fPIC fi @@ -467,16 +475,17 @@ LDFLAGS := ${LDFLAGS}${LDFLAGS_POST:+ }$LDFLAGS_POST LDFLAGS_SHARED := $LDFLAGS_SHARED LDFLAGS_NOSHARED :=$LDFLAGS_NOSHARED CROSS_COMPILE := $cross +SHLIB_EXT := ${shlibext} vpath lib%.a$vpaths -vpath lib%.so$vpathd +vpath lib%.${shlibext}$vpathd EOF if $allstatic ; then echo ".LIBPATTERNS := lib%.a" echo "DO_ALLSTATIC := 1" else - echo ".LIBPATTERNS := lib%.so" + echo ".LIBPATTERNS := lib%.${shlibext}" echo "DO_ALLSTATIC :=" fi if $static ; then |
