Download:
 - https://ftp.gnu.org/gnu/gawk/gawk-5.2.2.tar.gz 
 - https://gmplib.org/download/gmp/gmp-6.3.0.tar.gz
 - https://www.mpfr.org/mpfr-current/mpfr-4.2.0.tar.gz
 - https://ftp.gnu.org/gnu/readline/readline-8.2.tar.gz

0. Prerequisites:
 - cygwin requires optional cygwin packages "gcc-core", "make" and "bison"
 - on linux: (from citrix) seliiuts02919.seli.gic.ericsson.se or seliiuts03047 or seliiuts02893 to seliiuts02913 or ottlsvr18 (libc 2.11.3) (or seliiuts02929 or sekilx484.wrbs.rnd.ki.sw.ericsson.se or sekilx1260.wrbs.rnd.ki.sw.ericsson.se): 
export CC=gcc
module add perl/5.10.1
module add gcc/10.2.0
module add make/4.3
 
1.  Copy the file gawk-5.2.2.tar.gz readline-8.2.tar.gz gmp-6.3.0.tar.gz mpfr-4.2.0.tar.gz to /tmp. 
2.  cd /tmp && rm -rf gawk-5.2.2 && tar xf gawk-5.2.2.tar.gz 
2a. Comment out the line below in gawk-5.2.2/io.c , it causes a crash when moshell uses the close() function on a process that does not have a pid anymore
		/* flush before closing to leverage special error handling */
		efflush(rp->output.fp, "flush", rp);
3a. Linux: (64bit) 
	cp ~/moshell/commonjars/src/gawkextension/filefuncs.c /tmp/gawk-5.2.2/extension
	cd /tmp && rm -rf readline-8.2 && tar xf readline-8.2.tar.gz && cd readline-8.2
	./configure --enable-static --prefix=/tmp/readline-8.2 && make && make install
	cd /tmp && rm -rf /tmp/gmpfr && mkdir /tmp/gmpfr && rm -rf /tmp/gmp-6.3.0 && tar xf gmp-6.3.0.tar.gz && cd /tmp/gmp-6.3.0
	cp -v configfsf.guess config.guess
	cp -v configfsf.sub config.sub
	./configure --with-pic --enable-static --disable-shared --prefix=/tmp/gmpfr && make && make install
	cd /tmp && rm -rf /tmp/mpfr-4.2.0 && tar xf /tmp/mpfr-4.2.0.tar.gz && cd /tmp/mpfr-4.2.0
	./configure --with-pic --enable-static --disable-shared --with-gmp=/tmp/gmpfr --prefix=/tmp/gmpfr && make && make install
	cd /tmp/gawk-5.2.2
	./configure --with-readline=/tmp/readline-8.2 --with-mpfr=/tmp/gmpfr && make
3b. Cygwin64:
	cp ~/moshell/commonjars/src/gawkextension/filefuncs.c /tmp/gawk-5.2.2/extension
	cd /tmp && rm -rf readline-8.2 && tar xf readline-8.2.tar.gz && cd readline-8.2
	./configure --enable-static --prefix=/tmp/readline-8.2 && make && make install
	cd /tmp && rm -rf /tmp/gmpfr && mkdir /tmp/gmpfr && rm -rf /tmp/gmp-6.3.0 && tar xf gmp-6.3.0.tar.gz && cd /tmp/gmp-6.3.0
	./configure --enable-shared --disable-static --prefix=/tmp/gmpfr && make && make install
	cd /tmp && rm -rf /tmp/mpfr-4.2.0 && tar xf /tmp/mpfr-4.2.0.tar.gz && cd /tmp/mpfr-4.2.0
	./configure --prefix=/tmp/gmpfr --with-gmp-include=/tmp/gmpfr/include --with-gmp-lib=/tmp/gmpfr/lib && make && make install
	cd /tmp/gawk-5.2.2
	./configure --enable-static --with-readline=/tmp/readline-8.2 --with-mpfr=/tmp/gmpfr && make
3c. Mac:
        cp ~/moshell/commonjars/src/gawkextension/filefuncs.c /tmp/gawk-5.2.2/extension
        cd /tmp && rm -rf readline-8.2 && tar xf readline-8.2.tar.gz && cd readline-8.2
        ./configure --enable-static --prefix=/tmp/readline-8.2 && make && make install
        cd /tmp && rm -rf /tmp/gmpfr && mkdir /tmp/gmpfr && rm -rf /tmp/gmp-6.3.0 && tar xf gmp-6.3.0.tar.gz && cd /tmp/gmp-6.3.0
        cp -v configfsf.guess config.guess
        cp -v configfsf.sub config.sub
        ./configure --with-pic --enable-static --disable-shared --prefix=/tmp/gmpfr && make && make install
        cd /tmp && rm -rf /tmp/mpfr-4.2.0 && tar xf /tmp/mpfr-4.2.0.tar.gz && cd /tmp/mpfr-4.2.0
        ./configure --with-pic --enable-static --disable-shared --with-gmp=/tmp/gmpfr --prefix=/tmp/gmpfr && make && make install
        cd /tmp/gawk-5.2.2
	you need to add if condition in the file extension/filefuncs.c before #include <sys/sysmacros.h> at 2 places:
	#if defined(__linux__)
	#include <sys/sysmacros.h>
	#endif
        ./configure --with-readline=/tmp/readline-8.2 --with-mpfr=/tmp/gmpfr && make

Important: check with ldd that the gawk does not have dependency to shared readline !!!
4. strip gawk
5a. If Cygwin64: strip extension/.libs/filefuncs.dll
5b. Else: strip extension/.libs/filefuncs.so
6. update mos2emInfo["gawk_version"] in moshell/prog.awk

#testing of the lib:
./gawk -l extension/.libs/filefuncs 'BEGIN{usleep(100000);system("ls -l extension/time.c");chmod(00666,"extension/time.c");system("ls -l extension/time.c");chmod(00644,"extension/time.c");print mkdir("/tmp/test",0777);system("ls -ld /tmp/test");system("rmdir /tmp/test");system("ls -ld /tmp/test");print "touch testfile: "touch("testfile");system("ls -l testfile");print "rm testfile: "unlink("testfile");system("ls -l testfile");ctrl_c_disable();ctrl_c_enable();delete table;print scandir("/home/eanzmagn/moshell",table);for(i in table) print i,table[i];print ncfunc("128.1.0.1",443,1)}'

./gawk.solaris -l commonjars/lib/solaris/filefuncs 'BEGIN{usleep(5000000);system("ls -l commonjars/pm/PARAM_RNC_V_8_0.txt");chmod(00666,"commonjars/pm/PARAM_RNC_V_8_0.txt");system("ls -l commonjars/pm/PARAM_RNC_V_8_0.txt");chmod(00644,"commonjars/pm/PARAM_RNC_V_8_0.txt");print mkdir("/tmp/test",0777);system("ls -ld /tmp/test");system("rmdir /tmp/test");system("ls -ld /tmp/test");print "touch testfile: "touch("testfile");system("ls -l testfile");print "rm testfile: "unlink("testfile");system("ls -l testfile");delete table;print scandir("/home/eanzmagn/moshell",table);for(i in table) print i,table[i];ctrl_c_disable();ctrl_c_enable()}'

