oksh-noxz

[fork] Portable OpenBSD ksh, based on the Public Domain Korn Shell (pdksh).
git clone https://noxz.tech/git/oksh-noxz.git
oksh-noxz

commit: 70e44f72f1d452b90fa5a8104004b8577458fa8b
parent: d479454c901181b1f4114b9876dd38c523cdd7d9
author: Brian Callahan <bcallah@openbsd.org>
date:   Mon, 15 Feb 2021 00:36:16 -0500
Add support for Nils Weller's C compiler (nwcc)
On OpenBSD, nwcc needs special LDFLAGS. Detect and add.
MREADME.md1+
Mconfigure46++++++++++----------
2 files changed, 25 insertions(+), 22 deletions(-)
diff --git a/README.md b/README.md
@@ -54,6 +54,7 @@ Supported compilers
 * Optimizing C Compilation System  (CCS) 4.2  03/27/14 (uw714mp5.bl4s)
 * Tiny C Compiler (https://bellard.org/tcc/)
 * CompCert (https://compcert.org/)
+* Nils Weller's C compiler (http://nwcc.sourceforge.net/)
 
 Building with a compiler not listed here? Add it and send a pull request!
 
diff --git a/configure b/configure
@@ -95,7 +95,7 @@ clean:
 	rm -f \${PROG} \${OBJS}
 
 distclean: clean
-	rm -f Makefile pconfig.h
+	rm -f Makefile pconfig.h *.core
 EOF
 }
 
@@ -121,7 +121,6 @@ c99check() {
 int main(void){long long l;for (int i=0;i<1;i++)printf("%s",__func__);return 0;}
 EOF
   $cc $cflags -std=c99 -o conftest.o -c conftest.c > /dev/null 2>&1
-  $cc $ldflags -o conftest conftest.o > /dev/null 2>&1
   if [ $? -eq 0 ] ; then
     rm -f conftest conftest.o conftest.c
     return 0
@@ -315,7 +314,6 @@ gnu99check() {
 int main(void){long long l;for (int i=0;i<1;i++)printf("%s",__func__);return 0;}
 EOF
   $cc $cflags -std=gnu99 -o conftest.o -c conftest.c > /dev/null 2>&1
-  $cc $ldflags -o conftest conftest.o > /dev/null 2>&1
   if [ $? -eq 0 ] ; then
     rm -f conftest conftest.o conftest.c
     return 0
@@ -396,7 +394,6 @@ noc99check() {
 int main(void){long long l;for (int i=0;i<1;i++)printf("%s",__func__);return 0;}
 EOF
   $cc $cflags -o conftest.o -c conftest.c > /dev/null 2>&1
-  $cc $ldflags -o conftest conftest.o > /dev/null 2>&1
   if [ $? -eq 0 ] ; then
     rm -f conftest conftest.o conftest.c
     return 0
@@ -911,16 +908,27 @@ else
   echo "$cc"
 fi
 
-printf "checking if C compiler can compile C99 without -std=c99... "
+if [ "x$cflags" = "x-DEMACS -DVI" ] ; then
+  printf "checking if the compiler accepts -g -O2... "
+  defaultcflagscheck
+  if [ $? -eq 0 ] ; then
+    echo "no"
+  else
+    cflags="-g -O2 $cflags"
+    echo "yes"
+  fi
+fi
+
+printf "checking if the compiler can compile C99 without -std=c99... "
 noc99check
 if [ $? -ne 0 ] ; then
   echo "no"
-  printf "checking if C compiler can compile C99 with -std=c99... "
+  printf "checking if the compiler can compile C99 with -std=c99... "
   cflags="$cflags"
   c99check
   if [ $? -ne 0 ] ; then
     echo "no"
-    printf "checking if C compiler can compile C99 with -std=gnu99... "
+    printf "checking if the compiler can compile C99 with -std=gnu99... "
     gnu99check
     if [ $? -ne 0 ] ; then
       echo "no"
@@ -938,17 +946,6 @@ else
   echo "yes"
 fi
 
-if [ "x$cflags" = "x-DEMACS -DVI" ] ; then
-  printf "checking if the compiler accepts -g -O2... "
-  defaultcflagscheck
-  if [ $? -eq 0 ] ; then
-    echo "no"
-  else
-    cflags="-g -O2 $cflags"
-    echo "yes"
-  fi
-fi
-
 printf "checking for -w compiler flag... "
 wflagcheck
 if [ $? -eq 0 ] ; then
@@ -970,10 +967,15 @@ case "x$os" in
     cflags="$cflags -D_OPENBSD_SOURCE"
     ;;
   "xOpenBSD")
-    if [ "x$cc" = "xccomp" ] ; then
-      cflags="$cflags -D_ANSI_LIBRARY"
-      ldflags="$ldflags -Wl,-nopie"
-    fi
+    case "x$cc" in
+      "xccomp")
+	cflags="$cflags -D_ANSI_LIBRARY"
+	ldflags="$ldflags -Wl,-nopie"
+	;;
+      "xnwcc")
+	ldflags="$ldflags -Wl,-nopie"
+	;;
+    esac
     ;;
   "xAIX"|"xOS400")
     cflags="$cflags -D_ALL_SOURCE"