diff options
| author | Tyge Lovset <[email protected]> | 2022-12-20 23:31:51 +0100 |
|---|---|---|
| committer | Tyge Lovset <[email protected]> | 2022-12-20 23:31:51 +0100 |
| commit | 5f57d597cd27aef55adbcb3b452973b0c6e33667 (patch) | |
| tree | dfd59c2fd0e36a6ef37912a9d0cc5a65970f1524 /misc/examples/make.sh | |
| parent | 1763be8c8cbbc0896477fcf924edd4180d1345a9 (diff) | |
| download | STC-modified-5f57d597cd27aef55adbcb3b452973b0c6e33667.tar.gz STC-modified-5f57d597cd27aef55adbcb3b452973b0c6e33667.zip | |
Restructured folders: examples, benchmarks, tests into misc folder.
Diffstat (limited to 'misc/examples/make.sh')
| -rwxr-xr-x | misc/examples/make.sh | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/misc/examples/make.sh b/misc/examples/make.sh new file mode 100755 index 00000000..bd1392fc --- /dev/null +++ b/misc/examples/make.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +if [ "$(uname)" = 'Linux' ]; then + sanitize='-fsanitize=address' + clibs='-lm' # -pthread + oflag='-o ' +fi + +#cc=gcc; cflags="-s -O2 -std=c99 -Werror -Wfatal-errors -Wpedantic -Wall $sanitize" +cc=gcc; cflags="-s -O2 -std=c99 -Werror -Wfatal-errors -Wpedantic -Wall -Wsign-compare -Wwrite-strings" # -Wconversion +#cc=tcc; cflags="-Wall -std=c99" +#cc=clang; cflags="-s -O2 -std=c99 -Werror -Wfatal-errors -Wpedantic -Wall -Wsign-compare -Wwrite-strings" +#cc=clang; cflags="-s -O2 -std=c99 -Werror -Wfatal-errors -Wpedantic -Wall -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 + +run=0 +if [ "$1" = '-h' -o "$1" = '--help' ]; then + echo usage: runall.sh [-run] [compiler + options] + exit +fi +if [ "$1" = '-run' ]; then + run=1 + shift +fi +if [ ! -z "$1" ] ; then + comp="$@" +else + comp="$cc $cflags" +fi + +if [ $run = 0 ] ; then + for i in *.c ; do + echo $comp -I../include $i $clibs $oflag$(basename $i .c).exe + $comp -I../include $i $clibs $oflag$(basename $i .c).exe + done +else + for i in *.c ; do + echo $comp -I../include $i $clibs + $comp -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 + done +fi + +rm -f a.out *.o *.obj # *.exe |
