Skip to content

Commit

Permalink
fix(main/nasm): fix building with ./build-all.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
twaik authored Oct 28, 2024
1 parent ad5a441 commit 9606b74
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/nasm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,31 @@ TERMUX_PKG_DESCRIPTION="A cross-platform x86 assembler with an Intel-like syntax
TERMUX_PKG_LICENSE="BSD 2-Clause"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="2.16.03"
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL=https://www.nasm.us/pub/nasm/releasebuilds/${TERMUX_PKG_VERSION}/nasm-${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=5bc940dd8a4245686976a8f7e96ba9340a0915f2d5b88356874890e207bdb581
TERMUX_PKG_AUTO_UPDATE=true
TERMUX_PKG_BUILD_IN_SRC=true

termux_step_pre_configure1() {
# Autotools generate clang commandline like `$CC -c -I$TERMUX_PREFIX/include -std=c17 ...`
# so $TERMUX_PREFIX/include takes precedense in header search paths.
# It becomes a problem in the case if we build `nasm` in the same env where `libmd` was built
# because `libmd` installs it's own `md5.h` to `$TERMUX_PREFIX/include`, clang picks it and fails with the following error:
# nasmlib/md5c.c:46:10: error: no member named 'buf' in 'struct MD5Context'
# 46 | ctx->buf[0] = 0x67452301;
# | ~~~ ^

# We should move `-I$TERMUX_PREFIX/include` argument to the end of argument list to make sure it will not take precedense
# and make sure it will pick `md5.h` from `./include` folder.
mkdir -p "$TERMUX_PKG_SRCDIR/bin"
cat <<-EOF > "$TERMUX_PKG_SRCDIR/bin/$CC"
#!$(readlink /proc/$$/exe)
# Move -I$TERMUX_PREFIX/include to the end of argument list.
set -- \$(printf "%s\n" "\$@" | grep -v "\-I$TERMUX_PREFIX/include")
exec "$(command -v $CC)" "\$@" "-I$TERMUX_PREFIX/include"
EOF
chmod +x "$TERMUX_PKG_SRCDIR/bin/$CC"
export PATH="$TERMUX_PKG_SRCDIR/bin:$PATH"
}

0 comments on commit 9606b74

Please sign in to comment.