Download:
 - https://ftp.gnu.org/gnu/gawk/gawk-5.1.1.tar.gz 
 - https://gmplib.org/download/gmp/gmp-6.2.1.tar.xz
 - https://www.mpfr.org/mpfr-current/mpfr-4.1.0.tar.gz
 - https://ftp.gnu.org/gnu/readline/readline-8.1.2.tar.gz

0. Prerequisites:
 - cygwin requires optional cygwin packages "gcc-core", "make" and "bison"
 - on solaris, compilation works with: gcc 3.4.6 and make 3.82
 - on linux: compile on ottlsvr18 server  (has libc 2.11.3 , using default gcc/make, not module add gcc/10.2.0 && module add make/4.3)
1.  Copy the file gawk-5.1.1.tar.gz to /tmp
2.  cd /tmp && rm -rf gawk-5.1.1 && tar xf gawk-5.1.1.tar.gz 
3a. If solaris/sparc, 
          - cp ~/moshell/commonjars/src/gawkextension/filefuncs.solaris.c /tmp/gawk-5.1.1/extension/filefuncs.c
          - include the file libgcc_s.so.1 from /app/gcc/3.4.6/lib and store it in moshell/commonjars/lib/solaris
          - cd /tmp/gawk-5.1.1
          - ./configure && make
3b. If solaris/x86, run the command:
          - cp ~/moshell/commonjars/src/gawkextension/filefuncs.sol86.c /tmp/gawk-5.1.1/extension/filefuncs.c
          - setenv CFLAGS "-O2 -fno-schedule-insns2"
          - cd /tmp/gawk-5.1.1
          - ./configure && make
3c. If Linux: (32bit/64bit) 
    Copy the files readline-8.1.2.tar.gz gmp-6.2.1.tar.xz mpfr-4.1.0.tar.gz to /tmp. Then run the following commands:
	cp ~/moshell/commonjars/src/gawkextension/filefuncs.c /tmp/gawk-5.1.1/extension
	cd /tmp && rm -rf readline-8.1.2 && tar xf readline-8.1.2.tar.gz && cd readline-8.1.2
	./configure --enable-static --prefix=/tmp/readline-8.1.2 && make && make install
	cd /tmp && rm -rf /tmp/gmpfr && mkdir /tmp/gmpfr && rm -rf /tmp/gmp-6.2.1 && tar xJf gmp-6.2.1.tar.xz && cd /tmp/gmp-6.2.1
	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.1.0 && tar xf /tmp/mpfr-4.1.0.tar.gz && cd /tmp/mpfr-4.1.0
	./configure --with-pic --enable-static --disable-shared --with-gmp=/tmp/gmpfr --prefix=/tmp/gmpfr && make && make install
	cd /tmp/gawk-5.1.1
	./configure --with-readline=/tmp/readline-8.1.2 --with-mpfr=/tmp/gmpfr && make
3d. If Cygwin64:
    Copy the files readline-8.1.2.tar.gz gmp-6.2.1.tar.xz mpfr-4.1.0.tar.gz to /tmp. Then run the following commands:
	cp ~/moshell/commonjars/src/gawkextension/filefuncs.c /tmp/gawk-5.1.1/extension
	cd /tmp && rm -rf readline-8.1.2 && tar xf readline-8.1.2.tar.gz && cd readline-8.1.2
	./configure --enable-static --prefix=/tmp/readline-8.1.2 && make && make install
	cd /tmp && rm -rf /tmp/gmpfr && mkdir /tmp/gmpfr && rm -rf /tmp/gmp-6.2.1 && tar xJf gmp-6.2.1.tar.xz && cd /tmp/gmp-6.2.1
	./configure --enable-shared --disable-static --prefix=/tmp/gmpfr && make && make install
	cd /tmp && rm -rf /tmp/mpfr-4.1.0 && tar xf /tmp/mpfr-4.1.0.tar.gz && cd /tmp/mpfr-4.1.0
	./configure --prefix=/tmp/gmpfr --with-gmp-include=/tmp/gmpfr/include --with-gmp-lib=/tmp/gmpfr/lib && make && make install
	cd /tmp/gawk-5.1.1
	./configure --enable-static --with-readline=/tmp/readline-8.1.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()}'

