summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/make.sh56
1 files changed, 31 insertions, 25 deletions
diff --git a/examples/make.sh b/examples/make.sh
index c60ac3d4..28d95abe 100755
--- a/examples/make.sh
+++ b/examples/make.sh
@@ -1,43 +1,49 @@
-#!/bin/bash
-cc='gcc -s -O2 -Wall -std=c99 -pedantic -Wfatal-errors -fsanitize=address'
-#cc='tcc -s -O2 -Wall -std=c99 -pedantic -Wfatal-errors'
-#cc='clang -s -O2 -Wall -std=c99 -pedantic -Wfatal-errors'
-#cc='clang -s -O2 -Wall -std=c99 -pedantic -Wfatal-errors -DSTC_CSTR_V1 -DSTC_CSMAP_V1'
-#cc='gcc -x c++ -s -O2 -Wall -std=c++20'
-#cc='g++ -x c++ -s -O2 -Wall'
-#cc='clang'
-#cc='clang -c -DSTC_HEADER'
-#cc='cl -O2 -nologo -W2 -MD'
-#cc='cl -nologo -TP'
-#cc='cl -nologo -std:c11'
-libs=''
-#oflag='/Fe:'
-oflag='-o '
-run=0
-if [ -z "$OS" ]; then
- libs='-lm -pthread'
+#!/bin/sh
+
+if [ "$(uname)" = 'Linux' ]; then
+ sanitize='-fsanitize=address'
+ clibs='-lm' # -pthread
+ oflag='-o '
+fi
+
+cc=gcc; cflags="-s -O2 -Wall -std=c99 -pedantic -Wfatal-errors $sanitize"
+#cc=tcc; cflags="-Wall -std=c99"
+#cc=clang; cflags="-s -O2 -Wall -std=c99 -pedantic -Wfatal-errors"
+#cc=clang; cflags="-s -O2 -Wall -std=c99 -pedantic -Wfatal-errors -DSTC_CSTR_V1 -DSTC_CSMAP_V1"
+#cc=gcc; cflags="-x c++ -s -O2 -Wall -std=c++20"
+#cc=g++; cflags="-x c++ -s -O2 -Wall"
+#cc=cl; cflags="-O2 -nologo -W2 -MD"
+#cc=cl; cflags="-nologo -TP"
+#cc=cl; cflags="-nologo -std:c11"
+
+if [ "$cc" = "cl" ]; then
+ oflag='/Fe:'
+else
+ oflag='-o '
fi
-if [ "$1" == '-h' -o "$1" == '--help' ]; then
+
+run=0
+if [ "$1" = '-h' -o "$1" = '--help' ]; then
echo usage: runall.sh [-run] [compiler + options]
exit
fi
-if [ "$1" == '-run' ]; then
+if [ "$1" = '-run' ]; then
run=1
shift
fi
if [ ! -z "$1" ] ; then
- cc=$@
+ comp=$@
fi
if [ $run = 0 ] ; then
for i in *.c ; do
- echo $cc -I../include $i $libs $oflag$(basename $i .c).exe
- $cc -I../include $i $libs $oflag$(basename $i .c).exe
+ echo $cc $cflags -I../include $i $clibs $oflag$(basename $i .c).exe
+ $cc $cflags -I../include $i $clibs $oflag$(basename $i .c).exe
done
else
for i in *.c ; do
- echo $cc -I../include $i $libs
- $cc -I../include $i $libs
+ echo $cc $cflags -I../include $i $clibs
+ $cc $cflags -I../include $i $clibs
if [ -f $(basename -s .c $i).exe ]; then ./$(basename -s .c $i).exe; fi
if [ -f ./a.exe ]; then ./a.exe; fi
if [ -f ./a.out ]; then ./a.out; fi