|
| 1 | +#!/bin/bash |
| 2 | +MXE=${1:-.} |
| 3 | +TARGET=${2:-x86_64-w64-mingw32.shared} |
| 4 | +CC=$MXE/usr/bin/$TARGET-gcc |
| 5 | +NM=$MXE/usr/bin/$TARGET-nm |
| 6 | +OBJCOPY=$MXE/usr/bin/$TARGET-objcopy |
| 7 | +DLLTOOL=$MXE/usr/bin/$TARGET-dlltool |
| 8 | +PKGCONFIG=$MXE/usr/bin/$TARGET-pkg-config |
| 9 | + |
| 10 | +get_dll() |
| 11 | +{ |
| 12 | + symbol="$1" |
| 13 | + shift |
| 14 | + for lib ; do |
| 15 | + for implib in $lib.dll.a $lib.a ; do |
| 16 | + for dir in $MXE/usr/lib/gcc/$TARGET/*/ $MXE/usr/$TARGET/lib/ ; do |
| 17 | + if [ -e $dir/$implib ] ; then |
| 18 | + if $NM -C -g --defined-only $dir/$implib | grep -q " $symbol$" ; then |
| 19 | + if $DLLTOOL --identify-strict -I $dir/$implib ; then |
| 20 | + return |
| 21 | + fi |
| 22 | + fi |
| 23 | + fi |
| 24 | + done |
| 25 | + done |
| 26 | + done |
| 27 | +} |
| 28 | + |
| 29 | +pkg_libs() |
| 30 | +{ |
| 31 | + set -- `$PKGCONFIG --libs "$@"` |
| 32 | + for arg ; do |
| 33 | + case "$arg" in |
| 34 | + -l*) echo lib${arg#-l} |
| 35 | + esac |
| 36 | + done |
| 37 | +} |
| 38 | + |
| 39 | +pkg_version() |
| 40 | +{ |
| 41 | + ver=`$PKGCONFIG --modversion $1` |
| 42 | + eval "$2=$ver" |
| 43 | + ver=$ver.0.0 |
| 44 | + i=0 |
| 45 | + for part in MAJOR MINOR RELEASE ; do |
| 46 | + v=${ver%%.*} |
| 47 | + ver=${ver#*.} |
| 48 | + i=$((i*1000+v)) |
| 49 | + eval "${2}_$part=$v" |
| 50 | + done |
| 51 | + eval "${2}_INT=$i" |
| 52 | +} |
| 53 | + |
| 54 | +get_c_bool() |
| 55 | +{ |
| 56 | + exp="$1" |
| 57 | + shift |
| 58 | + file=/tmp/conftest-$$.c |
| 59 | + while [ $# -gt 0 ] ; do |
| 60 | + if [ "$1" == -- ] ; then |
| 61 | + shift |
| 62 | + break; |
| 63 | + fi |
| 64 | + echo "$1" |
| 65 | + shift |
| 66 | + done > $file |
| 67 | + echo "struct x {unsigned a:($exp)?1:-1;};" >> $file |
| 68 | + $CC "$@" -S -o - $file >/dev/null 2>/dev/null |
| 69 | + ret=$? |
| 70 | + rm -f $file |
| 71 | + return $ret |
| 72 | +} |
| 73 | + |
| 74 | +get_c_uinteger() |
| 75 | +{ |
| 76 | + num="$1" |
| 77 | + shift |
| 78 | + cur=0 |
| 79 | + bit=1 |
| 80 | + while get_c_bool "($num) > ${cur}UL" "$@"; do |
| 81 | + while ! get_c_bool "($num) & ${bit}UL" "$@"; do |
| 82 | + bit=$((bit*2)) |
| 83 | + done |
| 84 | + cur=$((cur+bit)) |
| 85 | + bit=$((bit*2)) |
| 86 | + done |
| 87 | + echo $cur |
| 88 | +} |
| 89 | + |
| 90 | +LUA_LIB_NAME=$(get_dll luaL_newstate $(pkg_libs lua)) |
| 91 | +pkg_version lua LUA_VERSION |
| 92 | + |
| 93 | +av__codec=$(get_dll avcodec_version $(pkg_libs libavcodec)) |
| 94 | +pkg_version libavcodec LIBAVCODEC_VERSION |
| 95 | + |
| 96 | +av__format=$(get_dll avformat_version $(pkg_libs libavformat)) |
| 97 | +pkg_version libavformat LIBAVFORMAT_VERSION |
| 98 | + |
| 99 | +av__util=$(get_dll avutil_version $(pkg_libs libavutil)) |
| 100 | +pkg_version libavutil LIBAVUTIL_VERSION |
| 101 | + |
| 102 | +sw__resample=$(get_dll swr_convert $(pkg_libs libswresample)) |
| 103 | +pkg_version libswresample LIBSWRESAMPLE_VERSION |
| 104 | + |
| 105 | +sw__scale=$(get_dll sws_scale $(pkg_libs libswscale)) |
| 106 | +pkg_version libswscale LIBSWSCALE_VERSION |
| 107 | + |
| 108 | +pkg_version libprojectM PROJECTM_VERSION |
| 109 | +pkg_version portaudio-2.0 PORTAUDIO_VERSION |
| 110 | + |
| 111 | +# Works for all FFmpeg version supported by current USDX |
| 112 | +FFMPEG_DIR="ffmpeg-$(($LIBAVUTIL_VERSION_MAJOR-52)).0" |
| 113 | + |
| 114 | +LUA_INTEGER_BYTES=$(get_c_uinteger "sizeof(lua_Integer)" "#include <lua.h>" -- $($PKGCONFIG --cflags lua)) |
| 115 | +LUA_INTEGER_BITS=$(($LUA_INTEGER_BYTES*8)) |
| 116 | + |
| 117 | +cat <<EOF |
| 118 | +{***************************************************************** |
| 119 | + * Configuration file for UltraStar Deluxe |
| 120 | + *****************************************************************} |
| 121 | +
|
| 122 | +{* Libraries *} |
| 123 | +
|
| 124 | +{\$IF Defined(IncludeConstants)} |
| 125 | + LUA_LIB_NAME = '${LUA_LIB_NAME}'; |
| 126 | + LUA_VERSION_INT = ${LUA_VERSION_INT}; |
| 127 | + LUA_VERSION_RELEASE = '${LUA_VERSION_RELEASE}'; |
| 128 | + LUA_VERSION_MINOR = '${LUA_VERSION_MINOR}'; |
| 129 | + LUA_VERSION_MAJOR = '${LUA_VERSION_MAJOR}'; |
| 130 | + LUA_VERSION = '${LUA_VERSION}'; |
| 131 | + LUA_INTEGER_BITS = ${LUA_INTEGER_BITS}; |
| 132 | +{\$IFEND} |
| 133 | +
|
| 134 | +{\$DEFINE HaveFFmpeg} |
| 135 | +//the required DLLs can be built with MXE |
| 136 | +{\$IF Defined(HaveFFmpeg)} |
| 137 | + {\$MACRO ON} |
| 138 | + {\$IFNDEF FFMPEG_DIR} |
| 139 | + {\$DEFINE FFMPEG_DIR := '${FFMPEG_DIR}'} |
| 140 | + {\$ENDIF} |
| 141 | + {\$IF Defined(IncludeConstants)} |
| 142 | + av__codec = '${av__codec}'; |
| 143 | + LIBAVCODEC_VERSION_MAJOR = ${LIBAVCODEC_VERSION_MAJOR}; |
| 144 | + LIBAVCODEC_VERSION_MINOR = ${LIBAVCODEC_VERSION_MINOR}; |
| 145 | + LIBAVCODEC_VERSION_RELEASE = ${LIBAVCODEC_VERSION_RELEASE}; |
| 146 | +
|
| 147 | + av__format = '${av__format}'; |
| 148 | + LIBAVFORMAT_VERSION_MAJOR = ${LIBAVFORMAT_VERSION_MAJOR}; |
| 149 | + LIBAVFORMAT_VERSION_MINOR = ${LIBAVFORMAT_VERSION_MINOR}; |
| 150 | + LIBAVFORMAT_VERSION_RELEASE = ${LIBAVFORMAT_VERSION_RELEASE}; |
| 151 | +
|
| 152 | + av__util = '${av__util}'; |
| 153 | + LIBAVUTIL_VERSION_MAJOR = ${LIBAVUTIL_VERSION_MAJOR}; |
| 154 | + LIBAVUTIL_VERSION_MINOR = ${LIBAVUTIL_VERSION_MINOR}; |
| 155 | + LIBAVUTIL_VERSION_RELEASE = ${LIBAVUTIL_VERSION_RELEASE}; |
| 156 | + {\$IFEND} |
| 157 | +{\$IFEND} |
| 158 | +
|
| 159 | +{\$DEFINE HaveSWResample} |
| 160 | +{\$IF Defined(HaveSWScale) and Defined(IncludeConstants)} |
| 161 | + sw__resample = '${sw__resample}'; |
| 162 | + LIBSWRESAMPLE_VERSION_MAJOR = ${LIBSWRESAMPLE_VERSION_MAJOR}; |
| 163 | + LIBSWRESAMPLE_VERSION_MINOR = ${LIBSWRESAMPLE_VERSION_MINOR}; |
| 164 | + LIBSWRESAMPLE_VERSION_RELEASE = ${LIBSWRESAMPLE_VERSION_RELEASE}; |
| 165 | +{\$IFEND} |
| 166 | +
|
| 167 | +{\$DEFINE HaveSWScale} |
| 168 | +{\$IF Defined(HaveSWScale) and Defined(IncludeConstants)} |
| 169 | + sw__scale = '${sw__scale}'; |
| 170 | + LIBSWSCALE_VERSION_MAJOR = ${LIBSWSCALE_VERSION_MAJOR}; |
| 171 | + LIBSWSCALE_VERSION_MINOR = ${LIBSWSCALE_VERSION_MINOR}; |
| 172 | + LIBSWSCALE_VERSION_RELEASE = ${LIBSWSCALE_VERSION_RELEASE}; |
| 173 | +{\$IFEND} |
| 174 | +
|
| 175 | +{\$DEFINE HaveProjectM} |
| 176 | +{\$IF Defined(HaveProjectM) and Defined(IncludeConstants)} |
| 177 | + ProjectM_DataDir = 'visuals\projectM'; |
| 178 | + PROJECTM_VERSION_MAJOR = ${PROJECTM_VERSION_MAJOR}; |
| 179 | + PROJECTM_VERSION_MINOR = ${PROJECTM_VERSION_MINOR}; |
| 180 | + PROJECTM_VERSION_RELEASE = ${PROJECTM_VERSION_RELEASE}; |
| 181 | +{\$IFEND} |
| 182 | +
|
| 183 | +{\$UNDEF HavePortaudio} |
| 184 | +{\$IF Defined(HavePortaudio) and Defined(IncludeConstants)} |
| 185 | + PORTAUDIO_VERSION_MAJOR = ${PORTAUDIO_VERSION_MAJOR}; |
| 186 | + PORTAUDIO_VERSION_MINOR = ${PORTAUDIO_VERSION_MINOR}; |
| 187 | + PORTAUDIO_VERSION_RELEASE = ${PORTAUDIO_VERSION_RELEASE}; |
| 188 | +{\$IFEND} |
| 189 | +
|
| 190 | +{\$UNDEF HavePortmixer} |
| 191 | +
|
| 192 | +{\$DEFINE UsePortMidi} |
| 193 | +{\$IF Defined(UsePortMidi)} |
| 194 | + {\$DEFINE UseMIDIPort} |
| 195 | +{\$IFEND} |
| 196 | +{\$IF Defined(UseMidiEmu)} |
| 197 | + {\$DEFINE UseMidiEmu} |
| 198 | + {\$DEFINE UseMIDIPort} |
| 199 | + // Avoid platform MIDI backends with system synths if built-in MIDI emulation is enabled |
| 200 | + {\$UNDEF UsePortMidi} |
| 201 | + {\$UNDEF UsePortTime} |
| 202 | +{\$IFEND} |
| 203 | +
|
| 204 | +{\$DEFINE UseOpenCVWrapper} |
| 205 | +EOF |
0 commit comments