pkgname="binutils" pkgver="2.38" pkgurl="https://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz" pkgmode="web" pkgdeps=('gmp' 'mpfr' 'mpc') setupdir="$workdir" builddir="$workdir/build" installdir="$workdir/build" srcdir="$workdir/binutils-$pkgver" port_unpack() { tar xvf binutils-$pkgver.tar.xz } port_patch() { patch -u -i $portdir/binutils.patch -p 1 -d $workdir } port_configure() { CFLAGS="-ffunction-sections -fdata-sections" LDFLAGS="-Wl,--gc-sections" $srcdir/configure --target=x86_64-luna --prefix="" --disable-werror --disable-nls --disable-dependency-tracking --with-build-sysroot=$LUNA_ROOT/base --host=x86_64-luna } port_build() { make -j$(nproc) } port_install() { make install-strip-binutils rm -rf $DESTDIR/include/ rm -rf $DESTDIR/lib/ rm -rf $DESTDIR/share/ rm -rf $DESTDIR/x86_64-luna/ # keep only a few binaries since we only use an initial ramdisk for now, which doesn't like having many of these large binaries rm -f $DESTDIR/bin/{ar,as,elfedit,gprof,ld,ld.bfd,objcopy,ranlib,strip} } port_uninstall() { rm -f $DESTDIR/bin/{addr2line,c++filt,nm,objdump,readelf,size,strings} }