i was build a simple script to download,compile (release/debug) version to simplify a env to study! ( a minimal sandbox )
#!/bin/bash
#
# a minimal (quick and dirty) env to develop, study ring lang.
# fell to free to fix any issue
#
# ***************************************************
# NOTE: works, but, need review AFTER study ring lang
# ***************************************************
#
set -ex
VERSION=1.27
# env
rm -fr /tmp/ring /tmp/ring_tmp /tmp/ring_build
mkdir -p /tmp/ring_tmp /tmp/ring_build
# download
cd /tmp
wget -c
https://github.com/ring-lang/ring/releases/download/v1.27/Ring_1.27_LightRelease_SourceCode.zip -O /tmp/ring.zip
# unzip & fix permissions
unzip ring.zip
find /tmp/ring -type d -exec chmod 755 {} +
find /tmp/ring -type f -exec chmod 644 {} +
# copy
cp /tmp/ring/language/src/* /tmp/ring_tmp
cp /tmp/ring/language/include/* /tmp/ring_tmp
# compile static&shared library
# TODO: check macros #ifdef #if....
cd /tmp/ring_tmp
## debug
gcc -I. -fPIC -fstack-protector-strong -O0 -g3 -ggdb -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -c $(printf '%s\n' *.c | grep -vE '^(ring|ringw)\.c$')
ar rcs ringd.a $(printf '%s\n' *.o | grep -vE '^(ring|ringw)\.o$')
ranlib ringd.a
gcc -shared -o libringd.so $(printf '%s\n' *.o | grep -vE '^(ring|ringw)\.o$')
## release
gcc -I. -fPIC -fstack-protector-strong -O2 -g0 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DNDEBUG -c $(printf '%s\n' *.c | grep -vE '^(ring|ringw)\.c$')
ar rcs ring.a $(printf '%s\n' *.o | grep -vE '^(ring|ringw)\.o$')
ranlib ring.a
gcc -shared -o libring.so $(printf '%s\n' *.o | grep -vE '^(ring|ringw)\.o$')
# compile ring
# static: ring library static
## NOTE 1: elf dynamic, ring lib static
## NOTE 2: elf static, ring lib static -> issue below (need check UB)
## FLAG: -static (issue: -ldl related library)
## warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
gcc -I. -fstack-protector-strong -O0 -g3 -ggdb -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DNDEBUG ring.c -o ringd_static ringd.a -lm -lrt -ldl
gcc -I. -fstack-protector-strong -O2 -g0 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 ring.c -o ring_static ring.a -lm -lrt -ldl
strip -s ring_static
## share (-Wl,-rpath,'$ORIGIN')
gcc -I. -fPIE -fstack-protector-strong -O2 -g0 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DNDEBUG ring.c -o ring -L. -lring -lm -ldl -lrt -ldl
gcc -I. -fPIE -fstack-protector-strong -O0 -g3 -ggdb -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 ring.c -o ringd -L. -lring -lm -ldl -lrt
strip -s ring
# copy executables & libraries & headers to target -> ring_build
cp ring ringd ringd.a libringd.so ring.a libring.so ring_static ringd_static /tmp/ring_build
cp *.h /tmp/ring_build
cd /tmp/ring_build
# TODO: download gist ring samples
# NOTES:
# scripts, modules/libraries, c extensions, valgrind, android?, ...
#
echo 'see "Hello, World!" + nl + nl' > hello.ring
du -h
file ./ring_static
file ./ringd_static
file ./ring
file ./ringd
set +x
LD_LIBRARY_PATH=. ldd ./ringd
LD_LIBRARY_PATH=. ldd ./ring
LD_LIBRARY_PATH=. ./ring hello.ring
LD_LIBRARY_PATH=. ./ringd hello.ring
./ring_static hello.ring
./ringd_static hello.ring
#
# next steps:
# TODO: make a tarball or copy to target =)
# TODO: enjoy with ring lang!
# TODO: amalgamation version
#
# REFERENCES:
#
https://ring-lang.github.io/#
https://github.com/ring-lang/ring#
https://groups.google.com/g/ring-lang#