Skip to content

Commit 1be1120

Browse files
authored
BUILD: set install_name for libgap on macOS (#5769)
... but only for the installed version of the library
1 parent b2506e1 commit 1be1120

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Makefile.rules

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,7 @@ else ifneq (,$(findstring darwin,$(host_os)))
447447
LINK_SHLIB_FLAGS += -compatibility_version $(LIBGAP_COMPAT_VER)
448448
LINK_SHLIB_FLAGS += -current_version $(LIBGAP_CURRENT_VER)
449449
LINK_SHLIB_FLAGS += -Wl,-single_module
450-
451-
# TODO: set install_name, at least for installed version of the lib?
452-
#LINK_SHLIB_FLAGS += -install_name $(libdir)/$(LIBGAP_FULL)
450+
LINK_SHLIB_FLAGS += -headerpad_max_install_names
453451

454452
GAP_CPPFLAGS += -DPIC
455453
GAP_CFLAGS += -fno-common
@@ -467,6 +465,12 @@ else
467465
GAP_LDFLAGS += -Wl,--export-dynamic
468466
endif
469467

468+
ifneq (,$(findstring darwin,$(host_os)))
469+
INSTALL_NAME_TOOL = @install_name_tool
470+
else
471+
INSTALL_NAME_TOOL = @echo > /dev/null
472+
endif
473+
470474
libgap: libgap$(SHLIB_EXT) $(LIBGAP_FULL)
471475
.PHONY: libgap
472476

@@ -516,6 +520,7 @@ build/main.c: src/main.c
516520
# build rule for the gap executable used by the `install-bin` target
517521
build/gap-install: libgap$(SHLIB_EXT) cnf/GAP-LDFLAGS cnf/GAP-LIBS cnf/GAP-OBJS build/obj/build/main.c.o
518522
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) build/obj/build/main.c.o $(GAP_LIBS) -L${abs_builddir} -lgap -o $@
523+
$(INSTALL_NAME_TOOL) -change $(LIBGAP_FULL) $(libdir)/$(LIBGAP_FULL) $@
519524

520525
endif
521526

@@ -687,6 +692,7 @@ install-libgap: $(LIBGAP_FULL) libgap.pc
687692
$(INSTALL) -d -m 0755 $(DESTDIR)$(libdir)
688693
$(INSTALL) -m 0644 $(LIBGAP_FULL) $(DESTDIR)$(libdir)
689694
ln -sf $(LIBGAP_FULL) $(DESTDIR)$(libdir)/libgap$(SHLIB_EXT)
695+
$(INSTALL_NAME_TOOL) -id $(libdir)/$(LIBGAP_FULL) $(DESTDIR)$(libdir)/$(LIBGAP_FULL)
690696
$(INSTALL) -d -m 0755 $(DESTDIR)$(libdir)/pkgconfig
691697
$(INSTALL) -m 0644 libgap.pc $(DESTDIR)$(libdir)/pkgconfig
692698

0 commit comments

Comments
 (0)