From patchwork Thu Aug 24 20:32:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3/4] makedef: Extend the script for use with mingw tools as well X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 63782 Message-Id: <1503606746-21606-3-git-send-email-martin@martin.st> To: libav-devel@libav.org Date: Thu, 24 Aug 2017 23:32:25 +0300 From: =?utf-8?q?Martin_Storsj=C3=B6?= List-Id: libav development This is invoked by setting the NM and AR variables to the names of those specific tools. The ARCH variable also needs to be provided, to choose the symbol prefix (nm doesn't provide any option that dumps the architecture easily). --- compat/windows/makedef | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/compat/windows/makedef b/compat/windows/makedef index b3de992..b321d84 100755 --- a/compat/windows/makedef +++ b/compat/windows/makedef @@ -45,7 +45,11 @@ libname=$(mktemp -u "library").lib trap 'rm -f -- $libname' EXIT -lib -out:${libname} $@ >/dev/null +if [ -n "$AR" ]; then + $AR rcs ${libname} $@ >/dev/null +else + lib -out:${libname} $@ >/dev/null +fi if [ $? != 0 ]; then echo "Could not create temporary library." >&2 exit 1 @@ -57,6 +61,15 @@ IFS=' # Determine if we're building for x86 or x86_64 and # set the symbol prefix accordingly. prefix="" +if [ -n "$NM" ]; then + case $ARCH in + *86) + prefix="_" + ;; + *) + ;; + esac +else arch=$(dumpbin -headers ${libname} | tr '\t' ' ' | grep '^ \+.\+machine \+(.\+)' | @@ -71,6 +84,7 @@ else exit 1 fi fi +fi started=0 regex="none" @@ -112,10 +126,19 @@ for line in $(cat ${vscript} | tr '\t' ' '); do ' done +if [ -n "$NM" ]; then +# Use eval, since NM="nm -g" +dump=$(eval "$NM --defined-only -g ${libname}" | + grep -v : | + grep -v ^$ | + cut -d' ' -f3 | + sed -e "s/^${prefix}//") +else dump=$(dumpbin -linkermember:1 ${libname} | sed -e '/public symbols/,$!d' -e '/^ \{1,\}Summary/,$d' -e "s/ \{1,\}${prefix}/ /" -e 's/ \{1,\}/ /g' | tail -n +2 | cut -d' ' -f3) +fi rm ${libname}