#!/bin/sh -e

# Modify Makefile to make it POSIX
clsed '/^\.for/,/^\.endfor/d' Makefile

# Modify Makefile to properly use LDFLAGS
# We don't want this expression to expand
# shellcheck disable=2016
clsed '/^kfcgi:/{n; s,$, $(LDFLAGS),}' Makefile

./configure \
    PREFIX=/usr \
    SBINDIR=/usr/bin \
    MANDIR=/usr/share/man \
    LDFLAGS="$LDFLAGS -static"

make
make DESTDIR="$1" install