2018-09-13 01:34:31 +00:00
|
|
|
#!/usr/bin/env bash
|
2018-06-28 19:52:43 +00:00
|
|
|
|
|
|
|
set -e # exit if a command fails
|
|
|
|
set -o pipefail # Will return the exit status of make if it fails
|
|
|
|
|
2020-05-25 19:54:51 +00:00
|
|
|
package_windows() {
|
|
|
|
rm -rf dist
|
2018-06-28 19:52:43 +00:00
|
|
|
mkdir -p dist
|
2020-03-12 08:04:33 +00:00
|
|
|
cp i386-softmmu/qemu-system-i386.exe dist/xemu.exe
|
|
|
|
cp i386-softmmu/qemu-system-i386w.exe dist/xemuw.exe
|
2020-03-12 10:37:31 +00:00
|
|
|
cp -r data dist/
|
2020-03-12 08:04:33 +00:00
|
|
|
python3 ./get_deps.py dist/xemu.exe dist
|
|
|
|
strip dist/xemu.exe
|
|
|
|
strip dist/xemuw.exe
|
2018-06-28 19:52:43 +00:00
|
|
|
}
|
|
|
|
|
2020-03-26 08:04:56 +00:00
|
|
|
package_macos() {
|
|
|
|
#
|
|
|
|
# Create bundle
|
|
|
|
#
|
|
|
|
rm -rf dist
|
|
|
|
|
|
|
|
# Copy in executable
|
|
|
|
mkdir -p dist/xemu.app/Contents/MacOS/
|
|
|
|
cp i386-softmmu/qemu-system-i386 dist/xemu.app/Contents/MacOS/xemu
|
|
|
|
|
|
|
|
# Copy in in executable dylib dependencies
|
|
|
|
mkdir -p dist/xemu.app/Contents/Frameworks
|
|
|
|
dylibbundler -cd -of -b -x dist/xemu.app/Contents/MacOS/xemu \
|
|
|
|
-d dist/xemu.app/Contents/Frameworks/ \
|
|
|
|
-p '@executable_path/../Frameworks/'
|
|
|
|
|
|
|
|
# Copy in runtime resources
|
|
|
|
mkdir -p dist/xemu.app/Contents/Resources
|
|
|
|
cp -r data dist/xemu.app/Contents/Resources
|
|
|
|
|
|
|
|
# Generate icon file
|
|
|
|
mkdir -p xemu.iconset
|
|
|
|
for r in 16 32 128 256 512; do cp ui/icons/xemu_${r}x${r}.png xemu.iconset/icon_${r}x${r}.png; done
|
|
|
|
iconutil --convert icns --output dist/xemu.app/Contents/Resources/xemu.icns xemu.iconset
|
|
|
|
|
|
|
|
# Generate Info.plist file
|
|
|
|
cat <<EOF > dist/xemu.app/Contents/Info.plist
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
|
|
<plist version="1.0">
|
|
|
|
<dict>
|
|
|
|
<key>CFBundleDevelopmentRegion</key>
|
|
|
|
<string>en</string>
|
|
|
|
<key>CFBundleExecutable</key>
|
|
|
|
<string>xemu</string>
|
|
|
|
<key>CFBundleIconFile</key>
|
|
|
|
<string>xemu.icns</string>
|
|
|
|
<key>CFBundleIdentifier</key>
|
|
|
|
<string>xemu.app.0</string>
|
|
|
|
<key>CFBundleInfoDictionaryVersion</key>
|
|
|
|
<string>6.0</string>
|
|
|
|
<key>CFBundleName</key>
|
|
|
|
<string>xemu</string>
|
|
|
|
<key>CFBundlePackageType</key>
|
|
|
|
<string>APPL</string>
|
|
|
|
<key>CFBundleShortVersionString</key>
|
|
|
|
<string>1</string>
|
|
|
|
<key>CFBundleSignature</key>
|
|
|
|
<string>xemu</string>
|
|
|
|
<key>CFBundleVersion</key>
|
|
|
|
<string>1</string>
|
|
|
|
<key>LSApplicationCategoryType</key>
|
|
|
|
<string>public.app-category.games</string>
|
|
|
|
<key>LSMinimumSystemVersion</key>
|
|
|
|
<string>10.6</string>
|
|
|
|
<key>NSPrincipalClass</key>
|
|
|
|
<string>NSApplication</string>
|
|
|
|
<key>NSHighResolutionCapable</key>
|
|
|
|
<true/>
|
|
|
|
</dict>
|
|
|
|
</plist>
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2020-05-25 19:54:51 +00:00
|
|
|
package_linux() {
|
|
|
|
rm -rf dist
|
|
|
|
mkdir -p dist
|
|
|
|
cp i386-softmmu/qemu-system-i386 dist/xemu
|
|
|
|
cp -r data dist
|
|
|
|
}
|
|
|
|
|
2018-09-13 01:34:31 +00:00
|
|
|
postbuild=''
|
2020-03-12 08:04:33 +00:00
|
|
|
debug_opts=''
|
|
|
|
build_cflags='-O3'
|
|
|
|
job_count='12'
|
2020-05-31 01:43:20 +00:00
|
|
|
sys_ldflags=''
|
2018-09-13 01:34:31 +00:00
|
|
|
|
2020-05-25 19:54:51 +00:00
|
|
|
while [ ! -z "${1}" ]
|
2018-09-13 01:34:31 +00:00
|
|
|
do
|
|
|
|
case "${1}" in
|
|
|
|
'-j'*)
|
|
|
|
job_count="${1:2}"
|
|
|
|
shift
|
|
|
|
;;
|
2020-03-12 08:04:33 +00:00
|
|
|
'--debug')
|
2020-12-24 22:37:53 +00:00
|
|
|
build_cflags='-O0 -g -DXEMU_DEBUG_BUILD=1'
|
2020-03-12 08:04:33 +00:00
|
|
|
debug_opts='--enable-debug'
|
2018-09-13 01:34:31 +00:00
|
|
|
shift
|
|
|
|
;;
|
|
|
|
*)
|
2020-05-25 19:54:51 +00:00
|
|
|
break
|
2018-09-13 01:34:31 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2019-10-17 03:29:40 +00:00
|
|
|
readlink=$(command -v readlink)
|
2018-09-13 01:34:31 +00:00
|
|
|
|
2020-03-12 08:04:33 +00:00
|
|
|
case "$(uname -s)" in # Adjust compilation options based on platform
|
2018-06-28 19:52:43 +00:00
|
|
|
Linux)
|
2020-03-12 08:04:33 +00:00
|
|
|
echo 'Compiling for Linux...'
|
2020-05-25 19:54:51 +00:00
|
|
|
sys_cflags='-Wno-error=redundant-decls -Wno-error=unused-but-set-variable'
|
2018-09-13 01:34:31 +00:00
|
|
|
sys_opts='--enable-kvm --disable-xen --disable-werror'
|
2020-05-25 19:54:51 +00:00
|
|
|
postbuild='package_linux'
|
2018-06-28 19:52:43 +00:00
|
|
|
;;
|
|
|
|
Darwin)
|
2020-03-12 08:04:33 +00:00
|
|
|
echo 'Compiling for MacOS...'
|
2020-03-26 08:04:56 +00:00
|
|
|
sys_cflags='-march=ivybridge'
|
2020-05-31 01:43:20 +00:00
|
|
|
sys_ldflags='-headerpad_max_install_names'
|
2018-09-13 01:34:31 +00:00
|
|
|
sys_opts='--disable-cocoa'
|
2019-06-28 00:11:18 +00:00
|
|
|
# necessary to find libffi, which is required by gobject
|
|
|
|
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}/usr/local/opt/libffi/lib/pkgconfig"
|
2020-04-27 23:44:53 +00:00
|
|
|
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig:${PKG_CONFIG_PATH}"
|
|
|
|
echo $PKG_CONFIG_PATH
|
2019-10-17 03:29:40 +00:00
|
|
|
# macOS needs greadlink for a GNU compatible version of readlink
|
|
|
|
if readlink=$(command -v greadlink); then
|
|
|
|
echo 'GNU compatible readlink detected'
|
|
|
|
else
|
|
|
|
echo 'Could not find a GNU compatible readlink. Please install coreutils with homebrew'
|
|
|
|
exit -1
|
|
|
|
fi
|
2020-03-26 08:04:56 +00:00
|
|
|
postbuild='package_macos'
|
2018-06-28 19:52:43 +00:00
|
|
|
;;
|
|
|
|
CYGWIN*|MINGW*|MSYS*)
|
2020-03-12 08:04:33 +00:00
|
|
|
echo 'Compiling for Windows...'
|
2018-09-13 01:34:31 +00:00
|
|
|
sys_cflags='-Wno-error'
|
2019-11-16 00:24:39 +00:00
|
|
|
sys_opts='--python=python3 --disable-cocoa --disable-opengl --disable-fortify-source'
|
2018-09-13 01:34:31 +00:00
|
|
|
postbuild='package_windows' # set the above function to be called after build
|
2018-06-28 19:52:43 +00:00
|
|
|
;;
|
|
|
|
*)
|
2018-09-13 01:34:31 +00:00
|
|
|
echo "could not detect OS $(uname -s), aborting" >&2
|
2018-06-28 19:52:43 +00:00
|
|
|
exit -1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2018-09-13 01:34:31 +00:00
|
|
|
# find absolute path (and resolve symlinks) to build out of tree
|
2019-10-17 03:29:40 +00:00
|
|
|
configure="$(dirname "$($readlink -f "${0}")")/configure"
|
2018-06-28 19:52:43 +00:00
|
|
|
|
2018-09-13 01:34:31 +00:00
|
|
|
set -x # Print commands from now on
|
2018-06-28 19:52:43 +00:00
|
|
|
|
2018-09-13 01:34:31 +00:00
|
|
|
"${configure}" \
|
|
|
|
--extra-cflags="-DXBOX=1 ${build_cflags} ${sys_cflags} ${CFLAGS}" \
|
2020-05-31 01:43:20 +00:00
|
|
|
--extra-ldflags="${sys_ldflags}" \
|
2018-09-13 01:34:31 +00:00
|
|
|
${debug_opts} \
|
|
|
|
${sys_opts} \
|
|
|
|
--target-list=i386-softmmu \
|
2019-05-25 09:33:12 +00:00
|
|
|
--enable-trace-backends="nop" \
|
2018-09-13 01:34:31 +00:00
|
|
|
--enable-sdl \
|
2020-03-12 10:30:29 +00:00
|
|
|
--enable-opengl \
|
2018-09-13 01:34:31 +00:00
|
|
|
--disable-curl \
|
|
|
|
--disable-vnc \
|
2019-05-25 09:33:12 +00:00
|
|
|
--disable-vnc-sasl \
|
2018-09-13 01:34:31 +00:00
|
|
|
--disable-docs \
|
|
|
|
--disable-tools \
|
|
|
|
--disable-guest-agent \
|
|
|
|
--disable-tpm \
|
|
|
|
--disable-live-block-migration \
|
2019-05-25 09:33:12 +00:00
|
|
|
--disable-rdma \
|
2018-09-13 01:34:31 +00:00
|
|
|
--disable-replication \
|
|
|
|
--disable-capstone \
|
|
|
|
--disable-fdt \
|
|
|
|
--disable-libiscsi \
|
|
|
|
--disable-spice \
|
|
|
|
--disable-user \
|
|
|
|
--disable-stack-protector \
|
2019-04-24 22:25:21 +00:00
|
|
|
--disable-glusterfs \
|
2019-05-25 09:33:12 +00:00
|
|
|
--disable-gtk \
|
|
|
|
--disable-curses \
|
|
|
|
--disable-gnutls \
|
|
|
|
--disable-nettle \
|
|
|
|
--disable-gcrypt \
|
|
|
|
--disable-crypto-afalg \
|
|
|
|
--disable-virglrenderer \
|
|
|
|
--disable-vhost-net \
|
|
|
|
--disable-vhost-crypto \
|
|
|
|
--disable-vhost-vsock \
|
|
|
|
--disable-vhost-user \
|
|
|
|
--disable-virtfs \
|
|
|
|
--disable-snappy \
|
|
|
|
--disable-bzip2 \
|
|
|
|
--disable-vde \
|
|
|
|
--disable-libxml2 \
|
|
|
|
--disable-seccomp \
|
|
|
|
--disable-numa \
|
|
|
|
--disable-lzo \
|
|
|
|
--disable-smartcard \
|
|
|
|
--disable-usb-redir \
|
2019-11-24 01:33:36 +00:00
|
|
|
--disable-bochs \
|
|
|
|
--disable-cloop \
|
|
|
|
--disable-dmg \
|
|
|
|
--disable-vdi \
|
|
|
|
--disable-vvfat \
|
|
|
|
--disable-qcow1 \
|
|
|
|
--disable-qed \
|
|
|
|
--disable-parallels \
|
|
|
|
--disable-sheepdog \
|
|
|
|
--without-default-devices \
|
|
|
|
--disable-blobs \
|
2020-05-25 19:54:51 +00:00
|
|
|
"$@"
|
2018-06-28 19:52:43 +00:00
|
|
|
|
2020-02-18 06:45:58 +00:00
|
|
|
time make -j"${job_count}" 2>&1 | tee build.log
|
2018-06-28 19:52:43 +00:00
|
|
|
|
2018-09-13 01:34:31 +00:00
|
|
|
${postbuild} # call post build functions
|