2018-11-09

Getting GNU Make 3.81 compiling again on Ubuntu 18.04

I have to use GNU Make 3.81 with a lot of my software because they use my Binodeps and Jardeps libraries, and they manifest a bug introduced in Make 3.82 (#48643). [Update 2021-11-15 Looks like it's not really a bug, as the behaviour has been in 3.75, 3.79.1, 3.80 and 3.82+. I still think it is something of design error, but it is evidently established behaviour in both implementation and documentation (under ought-to-exist). Someone has proposed a patch which allows old and new behaviour; maybe it will be accepted. My own patch would be too disruptive.] On a fresh system, I usually fetch make-3.81.tar.bz2, unpack it, build it, and install it in /usr/local:

cd /tmp
wget 'https://ftp.gnu.org/gnu/make/make-3.81.tar.bz2'
tar xjf make-3.81.tar.bz2
cd make-3.81
./configure
make
sudo make install

This stopped working recently, as the make command completes:

gcc  -g -O2   -o make  ar.o arscan.o commands.o default.o dir.o expand.o file.o function.o getopt.o getopt1.o implicit.o job.o main.o misc.o read.o remake.o remote-stub.o rule.o signame.o strcache.o variable.o version.o vpath.o hash.o glob/libglob.a  
glob/libglob.a(glob.o): In function `glob_in_dir':
/tmp/make-3.81/glob/glob.c:1361: undefined reference to `__alloca'
/tmp/make-3.81/glob/glob.c:1336: undefined reference to `__alloca'
/tmp/make-3.81/glob/glob.c:1277: undefined reference to `__alloca'
/tmp/make-3.81/glob/glob.c:1250: undefined reference to `__alloca'
glob/libglob.a(glob.o): In function `glob':
/tmp/make-3.81/glob/glob.c:575: undefined reference to `__alloca'
glob/libglob.a(glob.o):/tmp/make-3.81/glob/glob.c:726: more undefined references to `__alloca' follow
collect2: error: ld returned 1 exit status

This is likely a result of moving from Ubuntu 16.04 to 18.04. The issue is discussed in the GNU Make thread undefined reference to `__alloca', where a line in configure.ac is highlighted [my emphasis]:

#define GLOB_INTERFACE_VERSION 1
#if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
# include <gnu-versions.h>
# if _GNU_GLOB_INTERFACE_VERSION == GLOB_INTERFACE_VERSION

The recommended fix is to change the comparison from == to >=. However, there is no configure.ac in the tar file, but there are similar lines in configure and configure.in (which, I presume, are generated from configure.ac, which itself probably only exists in the source repository, and is not routinely packaged up with the tarballs). Changing the one in configure.in seems to do the trick.