#!/bin/sh -e

# Build sometimes forces -Werror.
export CFLAGS="$CFLAGS -Wno-error"

# Disable configure error for missing argp, fts, and obstack.
clsed 's/as_fn_error.*argp/: "/g'    configure
clsed 's/as_fn_error.*fts/: "/g'     configure
clsed 's/as_fn_error.*obstack/: "/g' configure

# Don't compile two unrelated C files which require argp.
clsed 's/color.*printversion../#/g' lib/Makefile.in

./configure \
    --prefix=/usr \
    --disable-symbol-versioning \
    --disable-debuginfod \
    --disable-nls

# Skip the default make target and build only what we need.
make -C lib
make -C libelf
make -C libelf DESTDIR="$1" install