To cleanly port anything with a configure script, you will want to apply
this patch to config.guess and config.sub.
In the directory that contains config.guess and config.sub:
patch -p1 < pathname-of-config.patch
If that fails, you should try the patch for older autoconf scripts and see whether that works.
I have written a tool, patchconf.pl, to
apply the patch recursively within a directory hierarchy. Its syntax is
patchconf.pl patch-file-name [dir ...]
If no directory is given, it works from the current directory downward.
It is quite possible that neither of these patches will work. There are a near-infinite number of configure script variations out there. What you want to do is actually fairly simple.
In general, configure wants to give you CFLAGS of -g -O2. Optimization level 2 is currently broken under Linux/390, so you should specify CFLAGS=-O1 on your make command line.
This can be made trickier if CFLAGS itself is more complex; in general,
replace -Ox, where x > 1, with -O1.
sed -e 's/\-O[2-9]/\-O1/g' run over the Makefile will do the trick.
So far, I have patches for the following packages to build them under
the IBM flavor of Linux/390.