summary refs log tree commit diff stats
path: root/tools/niminst
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@gmail.com>2016-06-05 14:30:47 +0100
committerDominik Picheta <dominikpicheta@gmail.com>2016-06-05 14:30:47 +0100
commit9d001d207ec35cfd47a0cf2388f0e45cfd80249f (patch)
tree6d7ccdee7af44b3b8c62c54d619afe7edf4205e3 /tools/niminst
parent62da869eee19f4a48dfa775b808b11a0c0ebd5ce (diff)
downloadNim-9d001d207ec35cfd47a0cf2388f0e45cfd80249f.tar.gz
Fixes #2128. Based on @infinity0's commit.
Diffstat (limited to 'tools/niminst')
-rw-r--r--tools/niminst/buildsh.tmpl38
-rw-r--r--tools/niminst/makefile.tmpl6
2 files changed, 22 insertions, 22 deletions
diff --git a/tools/niminst/buildsh.tmpl b/tools/niminst/buildsh.tmpl
index aa3bce3c3..2c66ea493 100644
--- a/tools/niminst/buildsh.tmpl
+++ b/tools/niminst/buildsh.tmpl
@@ -1,5 +1,5 @@
 #? stdtmpl(subsChar='?') | standard
-#proc generateBuildShellScript(c: ConfigData): string = 
+#proc generateBuildShellScript(c: ConfigData): string =
 #  result = "#! /bin/sh\n# Generated from niminst\n" &
 #           "# Template is in tools/niminst/buildsh.tmpl\n" &
 #           "# To regenerate run ``niminst csource`` or ``koch csource``\n"
@@ -29,8 +29,8 @@ done
 
 CC="gcc"
 LINKER="gcc"
-COMP_FLAGS="?{c.ccompiler.flags}$extraBuildArgs"
-LINK_FLAGS="?{c.linker.flags}"
+COMP_FLAGS="${CPPFLAGS:-} ${CFLAGS:-} ?{c.ccompiler.flags}$extraBuildArgs"
+LINK_FLAGS="${LDFLAGS:-} ?{c.linker.flags}"
 PS4=""
 #  add(result, "# platform detection\n")
 ucpu=`uname -m`
@@ -51,8 +51,8 @@ ucpu=`echo $ucpu | tr "[:upper:]" "[:lower:]"`
 uos=`echo $uos | tr "[:upper:]" "[:lower:]"`
 
 case $uos in
-  *linux* ) 
-    myos="linux" 
+  *linux* )
+    myos="linux"
     LINK_FLAGS="$LINK_FLAGS -ldl -lm"
     ;;
   *dragonfly* )
@@ -66,14 +66,14 @@ case $uos in
     LINK_FLAGS="$LINK_FLAGS -lm"
     ;;
   *openbsd* )
-    myos="openbsd" 
+    myos="openbsd"
     LINK_FLAGS="$LINK_FLAGS -lm"
     ;;
   *netbsd* )
     myos="netbsd"
     LINK_FLAGS="$LINK_FLAGS -lm"
     ;;
-  *darwin* ) 
+  *darwin* )
     myos="macosx"
     CC="clang"
     LINKER="clang"
@@ -84,41 +84,41 @@ case $uos in
     ;;
   *aix* )
     myos="aix"
-    LINK_FLAGS="$LINK_FLAGS -ldl -lm"    
+    LINK_FLAGS="$LINK_FLAGS -ldl -lm"
     ;;
-  *solaris* | *sun* ) 
+  *solaris* | *sun* )
     myos="solaris"
     LINK_FLAGS="$LINK_FLAGS -ldl -lm -lsocket -lnsl"
     ;;
   *haiku* )
     myos="haiku"
     ;;
-  *) 
+  *)
     echo 2>&1 "Error: unknown operating system: $uos"
     exit 1
     ;;
 esac
 
 case $ucpu in
-  *i386* | *i486* | *i586* | *i686* | *bepc* | *i86pc* ) 
+  *i386* | *i486* | *i586* | *i686* | *bepc* | *i86pc* )
     mycpu="i386" ;;
-  *amd*64* | *x86-64* | *x86_64* ) 
+  *amd*64* | *x86-64* | *x86_64* )
     mycpu="amd64" ;;
-  *sparc*|*sun* ) 
+  *sparc*|*sun* )
     mycpu="sparc" ;;
-  *ppc64* ) 
+  *ppc64* )
     if [ "$myos" = "linux" ] ; then
       COMP_FLAGS="$COMP_FLAGS -m64"
       LINK_FLAGS="$LINK_FLAGS -m64"
     fi
     mycpu="powerpc64" ;;
-  *power*|*ppc* ) 
+  *power*|*ppc* )
     mycpu="powerpc" ;;
-  *mips* ) 
+  *mips* )
     mycpu="mips" ;;
   *arm*|*armv6l* )
     mycpu="arm" ;;
-  *) 
+  *)
     echo 2>&1 "Error: unknown processor: $ucpu"
     exit 1
     ;;
@@ -128,7 +128,7 @@ esac
 
 case $myos in
 #  for osA in 1..c.oses.len:
-?{c.oses[osA-1]}) 
+?{c.oses[osA-1]})
   case $mycpu in
 #    for cpuA in 1..c.cpus.len:
   ?{c.cpus[cpuA-1]})
@@ -149,7 +149,7 @@ case $myos in
   esac
   ;;
 #  end for
-*) 
+*)
   echo 2>&1 "Error: no C code generated for: [$myos: $mycpu]"
   exit 1
   ;;
diff --git a/tools/niminst/makefile.tmpl b/tools/niminst/makefile.tmpl
index 6615ddc02..5c95ccda9 100644
--- a/tools/niminst/makefile.tmpl
+++ b/tools/niminst/makefile.tmpl
@@ -1,13 +1,13 @@
 #? stdtmpl(subsChar='?') | standard
-#proc generateMakefile(c: ConfigData): string = 
+#proc generateMakefile(c: ConfigData): string =
 #  result = "# Generated from niminst\n" &
 #           "# Template is in tools/niminst/makefile.tmpl\n" &
 #           "# To regenerate run ``niminst csource`` or ``koch csource``\n"
 
 CC = gcc
 LINKER = gcc
-COMP_FLAGS = ?{c.ccompiler.flags}
-LINK_FLAGS = ?{c.linker.flags}
+COMP_FLAGS = $(CPPFLAGS) $(CFLAGS) ?{c.ccompiler.flags}
+LINK_FLAGS = $(LDFLAGS) ?{c.linker.flags}
 binDir = ?{firstBinPath(c).toUnix}
 
 koch := $(shell sh -c 'test -s ../koch.nim && echo "yes"')