cosmopolitan/tool/scripts/distribute.sh
Justine Tunney e75ffde09e Get codebase completely working with LLVM
You can now build Cosmopolitan with Clang:

    make -j8 MODE=llvm
    o/llvm/examples/hello.com

The assembler and linker code is now friendly to LLVM too.
So it's not needed to configure Clang to use binutils under
the hood. If you love LLVM then you can now use pure LLVM.
2021-02-09 02:57:32 -08:00

43 lines
983 B
Bash
Executable file

#!/bin/sh
set -ex
rm -f o/ansi/.cosmopolitan.h o/ansi/cosmopolitan.h
make -j12 o/ansi/cosmopolitan.h MODE=ansi
make -j12 o//libc/crt/crt.o o//ape/ape.o o//ape/ape.lds
make -j12 o//cosmopolitan.a
rm -rf o/cosmo
mkdir -p o/cosmo
cp o//ape/ape.o \
o//ape/ape.lds \
o//libc/crt/crt.o \
o//cosmopolitan.a \
o/cosmo
{
echo '#ifndef COSMOPOLITAN_H_'
echo '#define COSMOPOLITAN_H_'
echo '#ifdef __cplusplus'
echo 'extern "C" {'
echo '#endif'
cat o/ansi/cosmopolitan.h
echo '#ifdef __cplusplus'
echo '} /* extern C */'
echo '#endif'
echo '#endif /* COSMOPOLITAN_H_ */'
} >o/cosmo/cosmopolitan.h
cd o/cosmo
cat <<EOF >HELLO.C
int main(int argc, char *argv[]) {
printf("hello world\n");
return 0;
}
EOF
gcc -O -s -static -nostdlib -nostdinc \
-Wl,-T,ape.lds -include cosmopolitan.h \
-o HELLO.COM.DBG HELLO.C crt.o ape.o cosmopolitan.a
objcopy -S -O binary HELLO.COM.DBG HELLO.COM
ls -hal ./HELLO.COM
./HELLO.COM