Fixes #2128. Based on @infinity0's commit.

This commit is contained in:
Dominik Picheta
2016-06-05 14:30:47 +01:00
parent 62da869eee
commit 9d001d207e
2 changed files with 22 additions and 22 deletions

View File

@@ -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
;;

View File

@@ -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"')