2
0
mirror of https://codeberg.org/kiss-community/repo synced 2024-12-21 23:00:06 -07:00

libelf: portability fixes from E5ten

This commit is contained in:
Dylan Araps 2020-05-26 18:01:54 +03:00
parent aba069a964
commit 58ff323f1f
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E

View File

@ -1,6 +1,6 @@
#!/bin/sh -e
#
# Word splitting (for CFLAGS, CC, etc) is sadly required.
# Word splitting (for CPPFLAGS, CC, etc) is sadly required.
# shellcheck disable=2086
#
# This package used to provide the old 'libelf' library. This had a sane
@ -15,7 +15,8 @@
# elftoolchain requires BSD make to build. Rather than package BSD make,
# let's just do the equivalent ourselves in shell. This is fairly simple
# as all we're building is 'libelf' and not the entire toolchain.
export CFLAGS="-shared -fPIC -O2 $CFLAGS"
export CPPFLAGS="-fPIC -O2 $CPPFLAGS"
export LDFLAGS="-shared $LDFLAGS"
# Patch unneeded in next release.
patch -p1 < libelf-linux.patch
@ -30,16 +31,18 @@ done
# Create all objects (.o).
for file in libelf/*.c; do
${CC:-cc} -I./libelf -I./common $CFLAGS -c -o "${file%%.c}.o" "$file"
${CC:-cc} -I./libelf -I./common $LDFLAGS $CPPFLAGS -c \
-o "${file%%.c}.o" "$file"
done
mkdir -p "$1/usr/lib"
# Create shared library.
${CC:-cc} $CFLAGS -I./libelf -I./common libelf/*.o -o "$1/usr/lib/libelf.so.1"
${CC:-cc} $LDFLAGS $CPPFLAGS -I./libelf -I./common libelf/*.o \
-o "$1/usr/lib/libelf.so.1"
# Create static library.
${AR:-ar} rc "$1/usr/lib/libelf.a" libelf/*.o
${AR:-ar} -rc "$1/usr/lib/libelf.a" libelf/*.o
# Install remaining headers/files.
ln -sf libelf.so.1 "$1/usr/lib/libelf.so"