devel/elftoolchain/ndmake.sh
$ cat ndmake.sh
#!/bin/sh -ue
NAME=elftoolchain
VERSION=git
RELEASE=1
SOURCE="https://github.com/xplshn/elftoolchain.git
remove-lsbr.patch
busybox.patch"
PROJECTS="libelf libelftc libdwarf libpe"
build() {
msg "generating common headers..."
cd common || die "common directory missing"
make || die "common make failed"
cd sys || die "common/sys directory missing"
make || die "common/sys make failed"
cd ../.. || die "failed to cd back"
msg "building elftoolchain libraries..."
export CC="${CC:-clang}"
WRAP_DIR="$SRC/wrappers"
mkdir -p "$WRAP_DIR"
cat >"$WRAP_DIR/install" <<'EOF'
#!/bin/sh
ARGS=""
for arg in "$@"; do
[ "$arg" = "-C" ] || ARGS="$ARGS \"$arg\""
done
eval "exec /usr/bin/install $ARGS"
EOF
chmod +x "$WRAP_DIR/install"
export PATH="$WRAP_DIR:$PATH"
# Build the libraries
for lib in $PROJECTS; do
msg "building $lib..."
cd "$SRC/$lib" || die "failed to enter $lib directory"
# Patch queue.h references
find . -type f \( -name '*.h' -o -name '*.c' \) -exec sed -i 's|<sys/queue.h>|<bsd/sys/queue.h>|g' {} \;
make -j"$NPROC" \
CC="$CC" \
CFLAGS="-O2 -D_GNU_SOURCE -I$SRC/common -I$SRC/libelf -I$SRC/libdwarf -I$SRC/libelftc -static" \
LDFLAGS="-static" \
WITH_SHARED=no || die "make failed for $lib"
# Install to pkg
make DESTDIR="$PKG" PREFIX="$PREFIX" install || die "install failed for $lib"
cd - >/dev/null || die "failed to cd back"
done
mkdir -p "$PKG$PREFIX/include/sys"
if [ -f "$SRC/common/elfdefinitions.h" ]; then
install -m 444 "$SRC/common/elfdefinitions.h" \
"$PKG$PREFIX/include/elfdefinitions.h"
fi
if [ -f "$SRC/common/sys/elfdefinitions.h" ]; then
install -m 444 "$SRC/common/sys/elfdefinitions.h" \
"$PKG$PREFIX/include/sys/elfdefinitions.h"
fi
}
. ${0%/*}/../../libsh/libdmake.sh
