Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 25 additions & 16 deletions Makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,20 @@ GAP_LIBS += $(LIBS)
ifneq (,$(findstring cygwin,$(host_os)))
GAC_CFLAGS =
GAC_LDFLAGS = -shared -Wl,$(abs_builddir)/bin/$(GAPARCH)/gap.dll -Wl,--enable-auto-image-base
GAC_LDFLAGS_FOR_INSTALL = $(GAC_LDFLAGS)
# Note: the above won't be correct after "make install"; but then I am not
# sure we care about "make install" on Cygwin, so I am not going to work on
# this until someone specifically asks for it (and even then I'll require
# that person to help test it)
else
ifneq (,$(findstring darwin,$(host_os)))
GAC_CFLAGS = -fno-common
GAC_LDFLAGS = -bundle -undefined dynamic_lookup -Wl,-no_fixup_chains
GAC_LDFLAGS = -bundle $(LIBGAP_BUILD_LDFLAGS)
GAC_LDFLAGS_FOR_INSTALL = -bundle $(LIBGAP_INSTALL_LDFLAGS)
else
GAC_CFLAGS = -fPIC
GAC_LDFLAGS = -shared -fPIC
GAC_LDFLAGS = -shared -fPIC $(LIBGAP_BUILD_LDFLAGS)
GAC_LDFLAGS_FOR_INSTALL = -shared -fPIC $(LIBGAP_INSTALL_LDFLAGS)
endif
endif

Expand Down Expand Up @@ -439,7 +442,6 @@ build/obj/%.c.o: %.c cnf/GAP-CFLAGS cnf/GAP-CPPFLAGS $(obj_deps)
########################################################################

LINK=$(CC)
GAP_INSTALL_EXTRAFLAGS =
SHLIB_MAJOR = $(GAP_KERNEL_MAJOR_VERSION)
ifneq (,$(findstring cygwin,$(host_os)))
SHLIB_EXT=.dll
Expand All @@ -455,8 +457,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
LINK_SHLIB_FLAGS += -Wl,-headerpad_max_install_names
GAP_INSTALL_EXTRAFLAGS = -Wl,-headerpad_max_install_names
LINK_SHLIB_FLAGS += -Wl,-install_name,@rpath/$(LIBGAP_FULL)

GAP_CPPFLAGS += -DPIC
GAP_CFLAGS += -fno-common
Expand All @@ -474,10 +475,18 @@ else
GAP_LDFLAGS += -Wl,--export-dynamic
endif

ifneq (,$(findstring darwin,$(host_os)))
INSTALL_NAME_TOOL = @install_name_tool
# Build-tree and installed targets intentionally use different runtime search
# paths, but both link against libgap through these centralized variables.
LIBGAP_BUILD_LDFLAGS = $(abs_builddir)/libgap$(SHLIB_EXT)
LIBGAP_INSTALL_LDFLAGS = -L$(libdir) -lgap
LIBGAP_BUILD_RPATH =
LIBGAP_INSTALL_RPATH =

ifneq (,$(findstring cygwin,$(host_os)))
LIBGAP_BUILD_LDFLAGS = -L$(abs_builddir) -lgap
else
INSTALL_NAME_TOOL = @echo > /dev/null
LIBGAP_BUILD_RPATH = -Wl,-rpath,$(abs_builddir)
LIBGAP_INSTALL_RPATH = -Wl,-rpath,$(libdir)
endif

libgap: libgap$(SHLIB_EXT) $(LIBGAP_FULL)
Expand Down Expand Up @@ -507,7 +516,7 @@ bin/$(GAPARCH)/gap.dll: libgap$(SHLIB_EXT)

# build rule for the main gap executable
gap$(EXEEXT): build/obj/src/main.c.o libgap$(SHLIB_EXT) cnf/GAP-LDFLAGS cnf/GAP-LIBS cnf/GAP-OBJS
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) -Wl,--export-all-symbols $< $(GAP_LIBS) -L${abs_builddir} -lgap -o $@
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) -Wl,--export-all-symbols $< $(GAP_LIBS) $(LIBGAP_BUILD_RPATH) $(LIBGAP_BUILD_LDFLAGS) -o $@
@( if which peflags > /dev/null ; then peflags --cygwin-heap=2048 gap$(EXEEXT) ; fi )

else
Expand All @@ -518,8 +527,8 @@ libgap$(SHLIB_EXT): $(LIBGAP_FULL)
ln -sf $< $@

# build rule for the main gap executable
gap$(EXEEXT): build/obj/src/main.c.o $(OBJS) cnf/GAP-LDFLAGS cnf/GAP-LIBS cnf/GAP-OBJS
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) $< $(OBJS) $(GAP_LIBS) -o $@
gap$(EXEEXT): build/obj/src/main.c.o libgap$(SHLIB_EXT) cnf/GAP-LDFLAGS cnf/GAP-LIBS cnf/GAP-OBJS
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) $< $(GAP_LIBS) $(LIBGAP_BUILD_RPATH) $(LIBGAP_BUILD_LDFLAGS) -o $@

# generate a special main.c which sets SYS_DEFAULT_PATHS and then includes
# regular main.c; this is used to build the `gap-install` binary
Expand All @@ -529,8 +538,7 @@ build/main.c: sysinfo.gap

# build rule for the gap executable used by the `install-bin` target
build/gap-install: build/obj/build/main.c.o libgap$(SHLIB_EXT) cnf/GAP-LDFLAGS cnf/GAP-LIBS cnf/GAP-OBJS
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) $(GAP_INSTALL_EXTRAFLAGS) $< $(GAP_LIBS) -L${abs_builddir} -lgap -o $@
$(INSTALL_NAME_TOOL) -change $(LIBGAP_FULL) $(libdir)/$(LIBGAP_FULL) $@
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) $< $(GAP_LIBS) $(LIBGAP_INSTALL_RPATH) $(LIBGAP_BUILD_LDFLAGS) -o $@

endif

Expand Down Expand Up @@ -686,6 +694,7 @@ install-sysinfo: SYSINFO_CPPFLAGS = -I${includedir}/gap/extra $(GAP_DEFINES)
install-sysinfo: SYSINFO_LDFLAGS = $(ABI_CFLAGS)
install-sysinfo: SYSINFO_GAP = $(bindir)/gap
install-sysinfo: SYSINFO_GAC = $(bindir)/gac
install-sysinfo: GAC_LDFLAGS = $(GAC_LDFLAGS_FOR_INSTALL)
install-sysinfo: GMP_PREFIX =
install-sysinfo: install-dirs
@echo "$$sysinfo_gap" > $(DESTDIR)$(libdir)/gap/sysinfo.gap
Expand Down Expand Up @@ -1015,7 +1024,7 @@ build-testlibgap: ${LIBGAPTESTS}

# run a test in tst/testlibgap
tst/testlibgap/%: build/obj/tst/testlibgap/%.c.o build/obj/tst/testlibgap/common.c.o libgap$(SHLIB_EXT)
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) -Wl,-rpath,$(abs_builddir) $^ $(GAP_LIBS) -o $@
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) $(LIBGAP_BUILD_RPATH) $^ $(GAP_LIBS) -o $@

clean: clean-testlibgap
clean-testlibgap:
Expand Down Expand Up @@ -1046,7 +1055,7 @@ testpkgconfigbuild: install-libgap install-headers
$(eval com := "tst/testlibgap/common")
$(CC) -c $(v).c -o $(v).o $(PKG_REPORTED_CFLAGS)
$(CC) -c $(com).c -o $(com).o $(PKG_REPORTED_CFLAGS)
$(QUIET_LINK)$(LINK) $(v).o -o $(v) $(com).o $(PKG_REPORTED_LDFLAGS) -Wl,-rpath,$(abs_builddir)
$(QUIET_LINK)$(LINK) $(v).o -o $(v) $(com).o $(PKG_REPORTED_LDFLAGS) $(LIBGAP_INSTALL_RPATH)
$(v) -A -l $(top_srcdir) -q -T --nointeract >$(v).out && \
diff $(top_srcdir)/$(v).expect $(v).out

Expand All @@ -1057,7 +1066,7 @@ build-testkernel: ${KERNELTESTS}

# run a test in tst/testkernel
tst/testkernel/%: build/obj/tst/testkernel/%.c.o libgap$(SHLIB_EXT)
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) -Wl,-rpath,$(abs_builddir) $^ $(GAP_LIBS) -o $@
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) $(LIBGAP_BUILD_RPATH) $^ $(GAP_LIBS) -o $@

clean: clean-testkernel
clean-testkernel:
Expand Down
7 changes: 3 additions & 4 deletions dev/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,16 @@ GAPInput
strip $GAPPREFIX/bin/gap > /dev/null
strip $GAPPREFIX/lib/libgap.so > /dev/null 2>&1 || : # for Linux
strip -S $GAPPREFIX/lib/libgap.dylib > /dev/null 2>&1 || : # for macOS
echo "Check if BUILDDIR=$BUILDDIR occurs in $GAPPREFIX"
fgrep -r $BUILDDIR $GAPPREFIX && exit 1
echo "Check if SRCDIR=$SRCDIR occurs in $GAPPREFIX"
fgrep -r $SRCDIR $GAPPREFIX && exit 1
echo "Check if HOME=$HOME occurs in $GAPPREFIX"
fgrep -r $HOME $GAPPREFIX && exit 1

# HACK: symlink packages so we can start GAP
ln -s $SRCDIR/pkg $GAPPREFIX/share/gap/pkg

# ensure the dynamic linker finds the install libgap in our custom prefix
export LD_LIBRARY_PATH="$GAPPREFIX/lib"
export DYLD_LIBRARY_PATH="$GAPPREFIX/lib"

# test building and loading package kernel extension
testmockpkg "$GAPPREFIX/bin/gap" "$GAPPREFIX/lib/gap" "$SRCDIR/tst/mockpkg"

Expand Down
Loading