Skip to content

Commit

Permalink
Add additional dynamic library that includes the legacy symbols but i…
Browse files Browse the repository at this point in the history
…n addition re-exports libSystem.B
  • Loading branch information
cjones051073 committed Apr 25, 2021
1 parent 7883156 commit b964c09
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
40 changes: 34 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,33 @@ LIBDIR = $(PREFIX)/lib
AREXT = .a
SOEXT = .dylib
LIBNAME = MacportsLegacySupport
SYSLIBNAME = MacportsLegacySystem.B
DLIBFILE = lib$(LIBNAME)$(SOEXT)
SLIBFILE = lib$(LIBNAME)$(AREXT)
SYSLIBFILE = lib$(SYSLIBNAME)$(SOEXT)
DLIBPATH = $(LIBDIR)/$(DLIBFILE)
SLIBPATH = $(LIBDIR)/$(SLIBFILE)
SYSLIBPATH = $(LIBDIR)/$(SYSLIBFILE)
BUILDDLIBDIR = lib
BUILDSLIBDIR = lib
BUILDDLIBPATH = $(BUILDDLIBDIR)/$(DLIBFILE)
BUILDSLIBPATH = $(BUILDSLIBDIR)/$(SLIBFILE)
BUILDSYSLIBPATH = $(BUILDDLIBDIR)/$(SYSLIBFILE)
SOCURVERSION ?= 1.0
SOCOMPATVERSION ?= 1.0
BUILDDLIBFLAGS = -dynamiclib -headerpad_max_install_names \
-install_name @executable_path/../$(BUILDDLIBPATH) \
-current_version 1.0 -compatibility_version 1.0
-current_version $(SOCURVERSION) \
-compatibility_version $(SOCOMPATVERSION)
BUILDSYSLIBFLAGS = -dynamiclib -headerpad_max_install_names \
-install_name @executable_path/../$(BUILDSYSLIBPATH) \
-current_version $(SOCURVERSION) \
-compatibility_version $(SOCOMPATVERSION)
SYSREEXPORTFLAG = -Wl,-reexport_library /usr/lib/libSystem.B.dylib
BUILDSLIBFLAGS = -qs
POSTINSTALL = install_name_tool
POSTINSTALLFLAGS = -id $(DLIBPATH)

MAX_DARWIN_REEXPORT ?= 19

FORCE_ARCH ?=
ARCHFLAGS ?=
Expand Down Expand Up @@ -193,9 +206,10 @@ define splitandfilterandmergemultiarch
fi
endef

all: dlib slib
all: dlib slib syslib
dlib: $(BUILDDLIBPATH)
slib: $(BUILDSLIBPATH)
syslib: $(BUILDSYSLIBPATH)

# Special rules for special implementations.
# For instance, functions using struct stat need to be implemented multiple
Expand Down Expand Up @@ -236,6 +250,13 @@ $(BUILDDLIBPATH): $(DLIBOBJS) $(MULTIDLIBOBJS)
$(MKINSTALLDIRS) $(BUILDDLIBDIR)
$(CC) $(BUILDDLIBFLAGS) $(LDFLAGS) $^ -o $@

# Wrapped libSystem relies on reexport which does not work on Darwin20+
$(BUILDSYSLIBPATH): $(DLIBOBJS) $(MULTIDLIBOBJS)
ifeq ($(shell test $(PLATFORM) -le $(MAX_DARWIN_REEXPORT); echo $$?),0)
$(MKINSTALLDIRS) $(BUILDDLIBDIR)
$(CC) $(BUILDSYSLIBFLAGS) $(LDFLAGS) $(SYSREEXPORTFLAG) $^ -o $@
endif

$(BUILDSLIBPATH): $(SLIBOBJS) $(MULTISLIBOBJS)
$(MKINSTALLDIRS) $(BUILDSLIBDIR)
$(RM) $@
Expand Down Expand Up @@ -281,12 +302,19 @@ install-headers:
$(INSTALL_DATA) $(SRCINCDIR)/"$$h" $(DESTDIR)$(PKGINCDIR)/"$$h"; \
done

install-lib: install-dlib install-slib
install-lib: install-dlib install-slib install-syslib

install-dlib: $(BUILDDLIBPATH)
$(MKINSTALLDIRS) $(DESTDIR)$(LIBDIR)
$(INSTALL_PROGRAM) $(BUILDDLIBPATH) $(DESTDIR)$(LIBDIR)
$(POSTINSTALL) $(POSTINSTALLFLAGS) $(DESTDIR)$(DLIBPATH)
$(POSTINSTALL) -id $(DLIBPATH) $(DESTDIR)$(DLIBPATH)

install-syslib: $(BUILDSYSLIBPATH)
ifeq ($(shell test $(PLATFORM) -le $(MAX_DARWIN_REEXPORT); echo $$?),0)
$(MKINSTALLDIRS) $(DESTDIR)$(LIBDIR)
$(INSTALL_PROGRAM) $(BUILDSYSLIBPATH) $(DESTDIR)$(LIBDIR)
$(POSTINSTALL) -id $(SYSLIBPATH) $(DESTDIR)$(SYSLIBPATH)
endif

install-slib: $(BUILDSLIBPATH)
$(MKINSTALLDIRS) $(DESTDIR)$(LIBDIR)
Expand All @@ -296,7 +324,7 @@ test check: $(TESTRUNS) test_cmath

clean:
$(RM) $(foreach D,$(SRCDIR) $(TESTDIR),$D/*.o $D/*.o.* $D/*.d)
$(RM) $(BUILDDLIBPATH) $(BUILDSLIBPATH) $(TESTPRGS) test/test_cmath_*
$(RM) $(BUILDDLIBPATH) $(BUILDSLIBPATH) $(BUILDSYSLIBPATH) $(TESTPRGS) test/test_cmath_*
@$(RMDIR) $(BUILDDLIBDIR) $(BUILDSLIBDIR)

.PHONY: all dlib slib clean check test $(TESTRUNS) test_cmath
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# MacPorts Support for Legacy OSX Versions

Installs wrapper headers and a library of functions that add common
Installs wrapper headers and library functions that add common
functions missing in various older OSX releases to bring them
approximately up to current expected standards.

Three different libraries are provided

- libMacportsLegacySupport.a - A static library with the missing functions for the given OS.
- libMacportsLegacySupport.dylib - A dynamic library with the missing functions for the given OS.
- libMacportsLegacySystem.B.dylib - Similar to libMacportsLegacySupport.dylib but in addition re-exports the symbols from libSystem.B.dylib.

To use this library within [MacPorts](https://github.com/macports)
add the `legacysupport` PortGroup to the Portfile. This will add the
required include paths and libraries to allow the library to do it's
Expand Down

0 comments on commit b964c09

Please sign in to comment.