[CentOS] Compile gnutls yo install samba-4.12.3

Wed Jun 17 16:10:39 UTC 2020
isdtor <isdtor at gmail.com>

Rommel Rodriguez Toirac writes:
> Hello all;
>  Has anyone installed samba4 from sources (samba-4.12.3.tar.gz) on CentOS 7?
>  I explain the problem: to install samba-4.12.3 you need to install a version equal to or greater than 3.4.7 of gnutls; this (gnutls) depends on nettle and gmp. 
>  I am trying to install gnutls-3.6.14; I already have gmp (gmp-6.2.0) and nettle (nettle-3.6) installed (compiled from sources), but gnutls doesn't want to install, it tells me "Libnettle 3.4.1 was not found" when I run the ./configure
> 
>  Nettle is installed in /usr/local/include/nettle (all .h) and in /usr/local/lib64/libnettle.s0.8.0
> 
>  I created a symbolic link for /usr/lib64 from /usr/local/lib64/libnettle.s0.8.0 as libnettle.so and libnettle.so.8; I ran the gnutls ./configure again, but it keeps saying it can't find libnettle 3.4.1
>  
>  How can I do? 
>  Has anyone got CentOS 7 and samba-4.12.3 installed and fixed this situation?

I've just been through a very similar exercise on CentOS 6, not for samba, but involving gnutls. My respect for those who manage to build gnutls at all has grown considerably. The code below works for my purposes.

In the p11-kit section, consider that your system does have systemd. In the libtasn1 section, I'm applying a patch that changes the perlesque C99 for loops into something gcc 4.4.7 can digest. I don't know if gcc 4.8.5 knows C99 (probably not). If you know a little C you can easily figure out what to do if needed. I didn't investigate building gnutls without external libtasn1 etc.

Now, linking your code against this version of gnutls is also a fun exercise. You need to configure against the same --prefix, for starters. You may also require the same PKG_CONFIG_PATH= stanza as below for gnutls. In your Makefiles, you may need to change anything "-lgnutls" to "-lgnutls -lgmp -ltasn1".


# keep it out of system directories!
prefix=/foo/bar

gmp_version=6.2.0
nettle_version=3.6
libtasn1_version=4.16.0
libffi_version=3.3
p11_kit_version=0.23.20
gnutls_version=3.6.14

tar xf gmp-${gmp_version}.tar.xz
pushd gmp-${gmp_version} >/dev/null
./configure --prefix=${prefix}
make install clean
popd >/dev/null
rm -rf gmp-${gmp_version}

tar xf nettle-${nettle_version}.tar.gz
pushd nettle-${nettle_version} >/dev/null
./configure --prefix=${prefix}   --with-include-path=${prefix}/include --with-lib-path=${prefix}/lib
make install clean
popd >/dev/null
rm -rf nettle-${nettle_version}

tar xf libtasn1-${libtasn1_version}.tar.gz
pushd libtasn1-${libtasn1_version} >/dev/null
#optional?# patch -p1 < ../libtasn1-4.16.0-c99-for-loop.patch
./configure --prefix=${prefix}
make install clean
popd >/dev/null
rm -rf libtasn1-${libtasn1_version}

tar xf libffi-${libffi_version}.tar.gz
pushd libffi-${libffi_version} >/dev/null
LIBFFI_CFLAGS="-I${prefix}/include" LIBFFI_LIBS="-L${prefix}/lib64" \
  ./configure --prefix=${prefix}
make install clean
popd >/dev/null
rm -rf libffi-${libffi_version}

tar xf p11-kit-${p11_kit_version}.tar.xz
pushd p11-kit-${p11_kit_version} >/dev/null
PKG_CONFIG_PATH=${prefix}/lib/pkgconfig \
  ./configure --prefix=${prefix} --without-systemd --disable-nls
make install clean
popd >/dev/null
rm -rf p11-kit-${p11_kit_version}

tar xf gnutls-${gnutls_version}.tar.xz
pushd gnutls-${gnutls_version} >/dev/null
PKG_CONFIG_PATH=${prefix}/lib64/pkgconfig:${prefix}/lib/pkgconfig: \
  GMP_CFLAGS="-I ${prefix}/include" \
  GMP_LIBS="-L${prefix}/lib -lm" \
  LIBTASN1_CFLAGS="-I${prefix}/include" LIBTASN1_LIBS="-L${prefix}/lib" \
  ./configure --prefix=${prefix} --with-included-unistring --disable-hardware-acceleration --disable-doc --disable-gtk-doc --disable-gtk-doc-html --disable-nls
sed -i 's%^#am__append_13.*%am__append_13 = -I${prefix}/include%' src/Makefile
for d in doc/examples src tests ; do
  sed -i 's%^LIBS = .*%LIBS = -L${prefix}/lib -lgmp -ltasn1%' ${d}/Makefile
done
make install clean
popd >/dev/null
rm -rf gnutls-${gnutls_version}