Skip to content

Commit

Permalink
BUILD: set install_name for libgap on macOS (#5769)
Browse files Browse the repository at this point in the history
... but only for the installed version of the library
  • Loading branch information
fingolfin authored Aug 27, 2024
1 parent b2506e1 commit 1be1120
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,7 @@ else ifneq (,$(findstring darwin,$(host_os)))
LINK_SHLIB_FLAGS += -compatibility_version $(LIBGAP_COMPAT_VER)
LINK_SHLIB_FLAGS += -current_version $(LIBGAP_CURRENT_VER)
LINK_SHLIB_FLAGS += -Wl,-single_module

# TODO: set install_name, at least for installed version of the lib?
#LINK_SHLIB_FLAGS += -install_name $(libdir)/$(LIBGAP_FULL)
LINK_SHLIB_FLAGS += -headerpad_max_install_names

GAP_CPPFLAGS += -DPIC
GAP_CFLAGS += -fno-common
Expand All @@ -467,6 +465,12 @@ else
GAP_LDFLAGS += -Wl,--export-dynamic
endif

ifneq (,$(findstring darwin,$(host_os)))
INSTALL_NAME_TOOL = @install_name_tool
else
INSTALL_NAME_TOOL = @echo > /dev/null
endif

libgap: libgap$(SHLIB_EXT) $(LIBGAP_FULL)
.PHONY: libgap

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

endif

Expand Down Expand Up @@ -687,6 +692,7 @@ install-libgap: $(LIBGAP_FULL) libgap.pc
$(INSTALL) -d -m 0755 $(DESTDIR)$(libdir)
$(INSTALL) -m 0644 $(LIBGAP_FULL) $(DESTDIR)$(libdir)
ln -sf $(LIBGAP_FULL) $(DESTDIR)$(libdir)/libgap$(SHLIB_EXT)
$(INSTALL_NAME_TOOL) -id $(libdir)/$(LIBGAP_FULL) $(DESTDIR)$(libdir)/$(LIBGAP_FULL)
$(INSTALL) -d -m 0755 $(DESTDIR)$(libdir)/pkgconfig
$(INSTALL) -m 0644 libgap.pc $(DESTDIR)$(libdir)/pkgconfig

Expand Down

0 comments on commit 1be1120

Please sign in to comment.