#!/bin/sh -e

patch -p1 < 0001-make-iproute2-fhs-compliant.patch

# Fix hardcoded `gcc` ( there is HOST_CC := $(CC) on line after this,
# but upstream seems to use it inconsistently ). Otherwise build fails on
# `clang` based systems with no `gcc` installed.
sed -i 's/CC := gcc/CC ?= gcc/' Makefile

./configure \
    --prefix=/usr

make
make DESTDIR="$1" SBINDIR="/usr/bin" install

install -Dm0644 include/libnetlink.h "$1/usr/include/libnetlink.h"
install -Dm0644 lib/libnetlink.a "$1/usr/lib/libnetlink.a"
