diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 019f36fc16..87afdca745 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -162,7 +162,7 @@ jobs: - uses: gap-actions/setup-cygwin@v1 if: ${{ runner.os == 'Windows' }} with: - PKGS_TO_INSTALL: 'wget,git,gcc-g++,gcc-core,m4,libgmp-devel,make,automake,libtool,autoconf,autoconf2.5,zlib-devel,libreadline-devel,libmpc-devel,libmpfr-devel,xdg-utils' + PKGS_TO_INSTALL: 'wget,git,gcc-g++,gcc-core,m4,libgmp-devel,make,automake,libtool,autoconf,autoconf2.5,zlib-devel,libreadline-devel,libmpc-devel,libmpfr-devel,xdg-utils,pkg-config' # There are two cygwin installs on github actions (ours, # and a preinstalled one which we can't use as not enough packages are installed. @@ -228,8 +228,9 @@ jobs: fi sudo apt-get update sudo apt-get install --no-install-recommends "${packages[@]}" + sudo apt-get install pkg-config elif [ "$RUNNER_OS" == "macOS" ]; then - brew install gmp zlib + brew install gmp zlib pkg-config fi python -m pip install gcovr diff --git a/.gitignore b/.gitignore index 18242da9f9..221570f6e9 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ /confdefs.h /conftest* /libtool +/libgap.pc /src/config.h.in /src/config.h.in~ diff --git a/Makefile.rules b/Makefile.rules index 8a855a6c89..1b10dfa1c8 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -532,6 +532,7 @@ clean: rm -f bin/gap.sh sysinfo.gap* rm -f gap$(EXEEXT) gac ffgen rm -f libgap.la + rm -f libgap.pc rm -rf .libs rm -f doc/wsp.g rm -f cnf/GAP-* @@ -656,10 +657,12 @@ install-headers: $(FFDATA_H) build/version.h # Create a symlink to support packages using `#include "src/compiled.h"` ln -sfn . $(DESTDIR)$(includedir)/gap/src -install-libgap: libgap.la +install-libgap: libgap.la libgap.pc @echo "Warning, 'make install-libgap' is incomplete" $(INSTALL) -d -m 0755 $(DESTDIR)$(libdir) $(LTINSTALL) -s libgap.la $(DESTDIR)$(libdir) + $(INSTALL) -d -m 0755 $(DESTDIR)$(libdir)/pkgconfig + $(INSTALL) -m 0644 libgap.pc $(DESTDIR)$(libdir)/pkgconfig .PHONY: install install-bin install-doc install-gaproot install-headers install-libgap @@ -1258,6 +1261,28 @@ testlibgap: ${LIBGAPTESTS} $(v) -A -l $(top_srcdir) -q -T --nointeract >$(v).out && \ diff $(top_srcdir)/$(v).expect $(v).out && ) : +# test libgap's pkg-config's libgap version reporting +testpkgconfigversion: install-libgap +ifeq ($(shell PKG_CONFIG_PATH=$(DESTDIR)$(libdir)/pkgconfig pkg-config --modversion libgap), $(PACKAGE_VERSION)) + @echo "pkg-config reports correct version of libgap: "$(PACKAGE_VERSION) +else + @echo "pkg-config does not report version of libgap, or is not installed" + exit 1 +endif + +# test libgap's pkg-config's libgap flags fetching +testpkgconfigbuild: install-libgap install-headers + $(eval PKG_REPORTED_CFLAGS := $(shell PKG_CONFIG_PATH=$(DESTDIR)$(libdir)/pkgconfig pkg-config --cflags libgap | cut -d' ' -f 1)/gap) + $(eval PKG_REPORTED_LDFLAGS := $(shell PKG_CONFIG_PATH=$(DESTDIR)$(libdir)/pkgconfig pkg-config --libs libgap)) + $(eval v := "tst/testlibgap/basic") + $(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) + $(v) -A -l $(top_srcdir) -q -T --nointeract >$(v).out && \ + diff $(top_srcdir)/$(v).expect $(v).out + + KERNELTESTS := $(addprefix tst/testkernel/,dstruct) # run a test in tst/testkernel @@ -1279,6 +1304,7 @@ testkernel: ${KERNELTESTS} .PHONY: testinstall testmanuals testobsoletes teststandard testbugfix .PHONY: testpackage testpackages testpackagesload testpackagesvars +.PHONY: testpkgconfigbuild testpkgconfigversion .PHONY: check ######################################################################## @@ -1469,6 +1495,9 @@ build/stamp-h: $(srcdir)/src/config.h.in config.status $(SHELL) ./config.status build/config.h echo > $@ +libgap.pc: $(srcdir)/libgap.pc.in config.status + @$(SHELL) ./config.status $@ + ifneq ($(MAINTAINER_MODE),no) $(srcdir)/src/config.h.in: $(configure_deps) @if command -v autoheader >/dev/null 2>&1 ; then \ diff --git a/configure.ac b/configure.ac index 9b3b254211..11fb93ee65 100644 --- a/configure.ac +++ b/configure.ac @@ -1027,6 +1027,7 @@ AC_SUBST([GAP_DEFINES], [$GAP_DEFINES]) AC_CONFIG_FILES([GNUmakefile]) AC_CONFIG_FILES([CITATION]) +AC_CONFIG_FILES([libgap.pc]) AC_CONFIG_FILES([doc/make_doc], [chmod +x doc/make_doc]) AC_CONFIG_FILES([doc/versiondata]) AC_OUTPUT diff --git a/dev/ci.sh b/dev/ci.sh index 4691246199..53653a2784 100755 --- a/dev/ci.sh +++ b/dev/ci.sh @@ -236,6 +236,7 @@ GAPInput test -f $GAPPREFIX/include/gap/version.h test -f $GAPPREFIX/include/gap/src/compiled.h # for backwards compatibility test -f $GAPPREFIX/lib/gap/sysinfo.gap + test -f $GAPPREFIX/lib/pkgconfig/libgap.pc test -f $GAPPREFIX/share/gap/doc/ref/chap0_mj.html test -f $GAPPREFIX/share/gap/grp/basic.gd test -f $GAPPREFIX/share/gap/hpcgap/lib/hpc/tasks.g @@ -257,6 +258,12 @@ GAPInput # TODO: should we install the GAP test suite??? cp -R $SRCDIR/tst $GAPPREFIX/share/gap/ $GAPPREFIX/bin/gap $GAPPREFIX/share/gap/tst/testinstall.g + + # test integration with pkg-config + cd "$SRCDIR" + # make install # might be actually needed for testpkgconfigbuild + make testpkgconfigversion + make testpkgconfigbuild ;; testmanuals) diff --git a/libgap.pc.in b/libgap.pc.in new file mode 100644 index 0000000000..fcb41135ee --- /dev/null +++ b/libgap.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@prefix@/include + +Name: GAP +Description: Library containing the kernel of GAP, a computer algebra system +URL: https://www.gap-system.org +Version: @GAP_VERSION@ +Libs: -L${libdir} -lgap +Cflags: -I${includedir}