Skip to content

Instantly share code, notes, and snippets.

@douglas-vaz
Last active January 23, 2024 09:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save douglas-vaz/7399155 to your computer and use it in GitHub Desktop.
Save douglas-vaz/7399155 to your computer and use it in GitHub Desktop.
Add pkg-config support to the GMP source tree.
#!/bin/sh
#Add pkg-config support to GMP
#http://gmplib.org/list-archives/gmp-discuss/2013-May/005329.html
echo "Creating gmp.pc.in..."
echo """prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: gmp
Description: GNU Multiple Precision Arithmetic Library
URL: http://gmplib.org
Version: @PACKAGE_VERSION@
Libs: -L\${libdir} -lgmp
Cflags: -I\${includedir}""" > gmp.pc.in
echo "Patching Makefile.am..."
sed -i "100ipkgconfigdir = \$(libdir)/pkgconfig\\
pkgconfig_DATA = gmp.pc" Makefile.am
echo "Patching configure.ac..."
sed -i "3648iAC_CONFIG_FILES([gmp.pc])" configure.ac
echo """Running automake...
"""
automake --add-missing
autoreconf
echo """
Completed. Run './configure' followed by 'make' and 'sudo make install'
gmp.pc will be added to /usr/local/lib/pkgconfig
Run 'export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig' to set environment (should be default)
To check version after install: pkg-config --modversion gmp
To include during compilation: gcc program.c \$(pkg-config --cflags --libs gmp)
"""
@rustyx
Copy link

rustyx commented Jan 23, 2024

Need to also add aclocal && libtoolize --force before autoreconf, in order to avoid errors like "You should recreate aclocal.m4 with macros from libtool...", caused by a libtool version mismatch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment