2023-07-22 14:30:04 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
[ ! -d "lib" ] && mkdir "lib"
|
|
|
|
[ ! -d "bin" ] && mkdir "bin"
|
|
|
|
|
|
|
|
nasm -f elf64 "src/linux/crt_entry.asm" -o "bin/crt_entry.o"
|
|
|
|
clang -fPIC -nostdlib -I "include" -g "src/linux/crt_ctors.c" -c -o "bin/crt_ctors.o"
|
|
|
|
clang -fPIC -nostdlib -I "include" -g "src/ciabatta.c" -c -o "bin/ciabatta.o"
|
|
|
|
|
|
|
|
rm "$LIB_FILE" 2> /dev/null
|
|
|
|
|
|
|
|
if [ "$1" != "-shared" ]; then
|
2023-07-22 15:23:39 +00:00
|
|
|
[ -f "lib/ciabatta.a" ] && rm "lib/ciabatta.a"
|
2023-07-22 14:30:04 +00:00
|
|
|
llvm-ar -q "lib/ciabatta.a" "bin/crt_ctors.o" "bin/crt_entry.o" "bin/ciabatta.o"
|
|
|
|
else
|
|
|
|
clang -fPIC -nostdlib -shared -o "lib/ciabatta.so" "bin/ciabatta.o"
|
|
|
|
cp "bin/crt_ctors.o" "lib/ctors.o"
|
|
|
|
cp "bin/crt_entry.o" "lib/entry.o"
|
|
|
|
fi
|