--- makelinux.sh.orig	2005-08-23 19:27:34.000000000 +0200
+++ makelinux.sh	2006-06-30 01:50:03.000000000 +0200
@@ -1,10 +1,14 @@
-#!/bin/sh
+#! /bin/sh

 ###########################################################################
 #
-# SCRIPT to convert and generate the TIGCC Tools Suite on Linux Systems
-#
-# v 0.3 (tested on Suse 6.x, Suse 7.x, Cygwin, SimplyMepis 3.3.1)
+# SCRIPT to convert and generate the TIGCC Tools Suite on UN*X Systems
+#	modified by John David Ratliff 2002-07-21
+#	modified by Kevin Kofler 2002-11-15
+#
+# v 0.2 (tested on Suse 6.x and Suse 7.x)
+# v 0.2.1 (fixed sh compatibility, removed GNU extentions)
+# v 0.2.2 (now honors CC and CFLAGS environment variables)
 #
 ###########################################################################
 #
@@ -18,7 +22,7 @@
 # your PATH.
 #
 # Due to the fact that the commandline parameter style of command
-# recode is incompatible between Linux 6.x and 7.x installations
+# recode is incompatible between Linux 6.x and 7.x installations
 # recode cannot be used to convert DOS files to UNIX files.
 # Instead of recode a dirty "cat -vte" in combination with
 # 2 sed filters is used which IS compatible between Linux 6.x and
@@ -29,10 +33,26 @@
 # This way the tool disqualify itself for compatible scripts.
 #
 ###########################################################################
+
+# check if CC is set, otherwise default to gcc
+if [ -z "$CC" ]
+ then CC=gcc
+fi
+echo ====== makelinux.sh: using compiler: $CC ========
+
+# check if CFLAGS is set, otherwise default to '-Os -s'
+if [ -z "$CFLAGS" ]
+ then CFLAGS='-Os -s'
+fi
+# The line is one off by intention, to be aligned for the default CFLAGS
+echo ====== using compiler flags: $CFLAGS =============
+
+
 directories=`ls src`

 echo ====== generating linuxbin directory ============
-if test -e linuxbin ; then
+
+if [ -d linuxbin ]; then
    echo directory linuxbin does already exists
 else
    echo generating directory linuxbin
@@ -40,7 +60,7 @@
 fi

 echo ====== generating linuxsrc directory tree =======
-if test -e linuxsrc ; then
+if [ -d linuxsrc ]; then
    echo directory linuxsrc does already exists
 else
    echo generating directory linuxsrc
@@ -49,12 +69,12 @@

 for i in $directories
 do
-   if test -d src/$i ; then
-      if test -e linuxsrc/$i ; then
+   if [ -d src/$i ]; then
+      if [ -d linuxsrc/$i ]; then
           echo directory linuxsrc/$i does already exists
       else
           echo generating directory linuxsrc/$i
-          mkdir linuxsrc/$i
+          mkdir linuxsrc/$i
       fi
    fi
 done
@@ -63,13 +83,13 @@

 for i in $directories
 do
-    if test -d src/$i ; then
+    if [ -d src/$i ]; then
         echo ------ processing directory src/$i -------
         cd src/$i
         allfiles=`ls *.c *.h 2>/dev/null`

-        for j in $allfiles
-        do
+        for j in $allfiles
+        do
             echo converting src/$i/$j ...
             #cat $j | recode ibmpc..lat1 > ../../linuxsrc/$i/$j
             cat -vte $j | sed 's/\^M\$//g' | sed 's/\^I/	/g' > ../../linuxsrc/$i/$j
@@ -83,11 +103,11 @@
 echo ====== generating linux binaries ==================
 cd linuxsrc/pctools
 allfiles=`ls tt*.c`
-for j in $allfiles
-do
+for j in $allfiles
+do
     echo building $j ...
     outname=`echo $j | cut -f1 -d.`
-    gcc -Os -fomit-frame-pointer -o ../../linuxbin/$outname $j
+    $CC $CFLAGS -o ../../linuxbin/$outname $j
 done
 cd ../..
