2009-04-08 13:11:27 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# This script reads filenames from STDIN and outputs any relevant provides
|
|
|
|
# information that needs to be included in the package.
|
2014-10-21 14:21:40 +00:00
|
|
|
target="mingw64"
|
|
|
|
host="x86_64-w64-mingw32"
|
2009-04-08 13:11:27 +00:00
|
|
|
|
2022-05-24 08:26:51 +00:00
|
|
|
scan_implibs=
|
|
|
|
if [ "$1" = "--scan-implibs" ]; then
|
|
|
|
scan_implibs=1
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
2022-07-15 07:07:27 +00:00
|
|
|
libs_to_exclude=
|
|
|
|
if [ "$1" = "--exclude" ]; then
|
|
|
|
shift
|
|
|
|
libs_to_exclude="$1"
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
2014-10-21 14:21:40 +00:00
|
|
|
if [ -n "$1" ]; then
|
2009-04-08 13:11:27 +00:00
|
|
|
package_name="$1"
|
|
|
|
fi
|
|
|
|
|
2014-10-21 14:21:40 +00:00
|
|
|
[ -z "$OBJDUMP" ] && OBJDUMP="$host-objdump"
|
2022-07-28 13:39:51 +00:00
|
|
|
[ -z "$STRINGS" ] && STRINGS="$host-strings"
|
2009-04-08 13:11:27 +00:00
|
|
|
|
|
|
|
# Get the list of files.
|
|
|
|
|
2022-05-24 08:26:51 +00:00
|
|
|
filelist=`sed "s/['\"]/\\\&/g"`
|
2009-04-08 13:11:27 +00:00
|
|
|
|
2022-07-15 07:07:27 +00:00
|
|
|
libs_to_exclude+="
|
2011-12-20 13:35:55 +00:00
|
|
|
advapi32
|
2022-08-06 11:04:47 +00:00
|
|
|
bcrypt
|
2011-12-20 13:35:55 +00:00
|
|
|
cfgmgr32
|
|
|
|
comctl32
|
|
|
|
comdlg32
|
|
|
|
crypt32
|
2022-08-06 11:04:47 +00:00
|
|
|
d2d1
|
|
|
|
d3d11
|
|
|
|
d3d12
|
2015-10-19 19:34:19 +00:00
|
|
|
d3d8
|
|
|
|
d3d9
|
2022-08-06 11:04:47 +00:00
|
|
|
dbghelp
|
|
|
|
dcomp
|
2011-12-20 13:35:55 +00:00
|
|
|
ddraw
|
|
|
|
dnsapi
|
|
|
|
dsound
|
2015-10-19 19:34:19 +00:00
|
|
|
dwmapi
|
2022-08-06 11:04:47 +00:00
|
|
|
dwrite
|
|
|
|
dxgi
|
2017-01-13 12:59:50 +00:00
|
|
|
dxva2
|
|
|
|
evr
|
2011-12-20 13:35:55 +00:00
|
|
|
gdi32
|
|
|
|
gdiplus
|
|
|
|
glu32
|
|
|
|
glut32
|
|
|
|
imm32
|
|
|
|
iphlpapi
|
|
|
|
kernel32
|
2013-06-10 18:59:54 +00:00
|
|
|
ksuser
|
2017-01-13 12:59:50 +00:00
|
|
|
mf
|
|
|
|
mfplat
|
2022-08-06 11:04:47 +00:00
|
|
|
mlang
|
|
|
|
mpr
|
2015-01-24 21:13:43 +00:00
|
|
|
mpr
|
2011-12-20 13:35:55 +00:00
|
|
|
mscms
|
|
|
|
mscoree
|
|
|
|
msimg32
|
|
|
|
msvcr71
|
|
|
|
msvcr80
|
|
|
|
msvcr90
|
|
|
|
msvcrt
|
|
|
|
mswsock
|
2022-08-06 11:04:47 +00:00
|
|
|
ncrypt
|
2012-08-30 09:19:33 +00:00
|
|
|
netapi32
|
2012-01-28 21:02:53 +00:00
|
|
|
odbc32
|
2022-08-06 11:04:47 +00:00
|
|
|
odbccp32
|
2011-12-20 13:35:55 +00:00
|
|
|
ole32
|
2016-03-07 07:38:51 +00:00
|
|
|
oleacc
|
2011-12-20 13:35:55 +00:00
|
|
|
oleaut32
|
|
|
|
opengl32
|
|
|
|
psapi
|
|
|
|
rpcrt4
|
|
|
|
secur32
|
|
|
|
setupapi
|
|
|
|
shell32
|
|
|
|
shlwapi
|
|
|
|
user32
|
2022-08-06 11:04:47 +00:00
|
|
|
userenv
|
2011-12-20 13:35:55 +00:00
|
|
|
usp10
|
2022-08-06 11:04:47 +00:00
|
|
|
uxtheme
|
2011-12-20 13:35:55 +00:00
|
|
|
version
|
2022-08-06 11:04:47 +00:00
|
|
|
winhttp
|
2011-12-20 13:35:55 +00:00
|
|
|
wininet
|
|
|
|
winmm
|
|
|
|
wldap32
|
|
|
|
ws2_32
|
|
|
|
wsock32
|
2022-08-06 11:04:47 +00:00
|
|
|
wtsapi32
|
2009-12-16 10:46:30 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
exclude_pattern=""
|
2011-12-20 13:35:55 +00:00
|
|
|
for i in $libs_to_exclude; do
|
2014-10-21 14:21:40 +00:00
|
|
|
if [ -z "$exclude_pattern" ]; then
|
|
|
|
exclude_pattern="$i"
|
2009-12-16 10:46:30 +00:00
|
|
|
else
|
2014-10-21 14:21:40 +00:00
|
|
|
exclude_pattern="$exclude_pattern|$i"
|
2009-12-16 10:46:30 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2009-04-08 13:11:27 +00:00
|
|
|
|
2022-05-24 08:26:51 +00:00
|
|
|
dlls=$(echo "$filelist" | grep -v 'config$' | xargs file | grep executable | sed 's,:.*$,,g')
|
|
|
|
pcs=$(echo "$filelist" | grep '\.pc$')
|
|
|
|
configs=$(echo "$filelist" | grep 'config$')
|
2009-04-08 13:11:27 +00:00
|
|
|
|
|
|
|
for f in $dlls; do
|
2014-10-30 12:25:44 +00:00
|
|
|
[ ! -f "$f" ] && continue
|
2014-10-21 14:21:40 +00:00
|
|
|
"$OBJDUMP" -p "$f" | grep 'DLL Name' | tr "[:upper:]" "[:lower:]" |
|
2009-11-13 20:32:09 +00:00
|
|
|
grep -Eo '[-._\+[:alnum:]]+\.dll' |
|
2009-12-16 10:46:30 +00:00
|
|
|
grep -Ev "$exclude_pattern" |
|
2014-10-21 14:21:40 +00:00
|
|
|
sed 's/\(.*\)/'"$target"'(\1)/'
|
2009-04-08 13:11:27 +00:00
|
|
|
done | sort -u
|
2011-04-13 08:48:20 +00:00
|
|
|
|
2022-07-23 16:18:26 +00:00
|
|
|
# scan import libraries - all archive files are scanned, not only
|
|
|
|
# '.dll.a' as some packages do not use the standard extension
|
|
|
|
# for import libraries
|
2022-05-24 08:26:51 +00:00
|
|
|
if [ -n "$scan_implibs" ]; then
|
2022-07-23 16:18:26 +00:00
|
|
|
implibs=$(echo "$filelist" | grep '\.a$')
|
2022-05-24 08:26:51 +00:00
|
|
|
for f in $implibs; do
|
|
|
|
[ ! -f "$f" ] && continue
|
2022-07-28 13:39:51 +00:00
|
|
|
"$STRINGS" "$f" | grep '\.dll$' | grep -v '[%$&#]' |
|
2022-05-24 08:26:51 +00:00
|
|
|
tr "[:upper:]" "[:lower:]" |
|
|
|
|
grep -Ev "$exclude_pattern" |
|
|
|
|
sed 's/\(.*\)/'"$target"'(\1)/'
|
|
|
|
done | sort -u
|
|
|
|
fi
|
|
|
|
|
2011-04-25 14:17:14 +00:00
|
|
|
(
|
2011-04-13 08:48:20 +00:00
|
|
|
for g in $pcs; do
|
2014-10-21 14:21:40 +00:00
|
|
|
dirname="${g%/*}"
|
2022-07-28 13:39:51 +00:00
|
|
|
PKG_CONFIG_PATH="$dirname" "$host-pkgconf" --print-errors --print-requires "$g" | awk '{ print "'"$target"'(pkg:"$1")", $2, $3 }'
|
|
|
|
PKG_CONFIG_PATH="$dirname" "$host-pkgconf" --print-errors --print-requires-private "$g" | grep -Ev "$exclude_pattern" | awk '{ print "'"$target"'(pkg:"$1")", $2, $3 }'
|
|
|
|
for h in $(PKG_CONFIG_PATH="$dirname" "$host-pkgconf" --libs-only-l "$g" | sed 's#^\-l##g;s# \-l# #g'); do
|
2014-10-21 14:21:40 +00:00
|
|
|
echo "$target(lib:$h)"
|
2011-04-18 12:05:33 +00:00
|
|
|
done
|
2011-04-25 14:17:14 +00:00
|
|
|
done
|
|
|
|
for k in $configs; do
|
2022-07-28 13:39:51 +00:00
|
|
|
for j in $(PKG_CONFIG="$host-pkgconf" "$k" --libs); do
|
2014-10-21 14:21:40 +00:00
|
|
|
case "$j" in
|
2011-04-25 14:17:14 +00:00
|
|
|
-l*)
|
2014-10-21 14:21:40 +00:00
|
|
|
echo "$j" | sed 's#\-l##g' | grep -Ev "$exclude_pattern" | awk '{ print "'"$target"'(lib:"$1")" }'
|
2011-04-25 14:17:14 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
done
|
|
|
|
) | sort -u
|