#!/bin/sh -e

export DESTDIR="$1"

# Set the CFLAGS so that gcc > 14 doesn't complain.
export CFLAGS="$CFLAGS -D_GNU_SOURCE -Wno-incompatible-pointer-types"

# musl doesn't have the fpu_control header files, so
# instead we just copy in glibc's header file directly
# into the source directory
kiss list musl && {
    cp files/fpu_control.h src/os/linux/x86_64/
    sed "s/<fpu_control.h>/\"fpu_control.h\"/" src/os/linux/x86_64/init.c > _
    mv _ src/os/linux/x86_64/init.c
}

# Remove precompiled classes
rm lib/classes.zip

./configure \
    --prefix=/usr \
    --disable-int-caching \
    --enable-runtime-reloc-checks \
    --with-classpath-install-dir=/usr \
    --enable-ffi

make
make install
