Skip to content

Instantly share code, notes, and snippets.

@TechnologistAU
Last active January 27, 2018 02:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TechnologistAU/3ea3bdbe9f7095f790074285432565b5 to your computer and use it in GitHub Desktop.
Save TechnologistAU/3ea3bdbe9f7095f790074285432565b5 to your computer and use it in GitHub Desktop.
#!/bin/bash
hardware_extra_dist=()
hardware_sources=()
gui_sources=()
################################################################################
#
# UpdateSources $1 $2 $3 $4 $5
#
# $1: Filename
# $2: Text Line
# $3: Array
# $4: Padding
# $5: Split
#
################################################################################
UpdateSources() {
declare -a array=("${!3}")
c_sources=${#array[*]}
if [[ $c_sources -gt 0 ]]; then
s_sources=$5
lines=""
for (( i=0; i<$c_sources; i++ ))
do
let "mod = $i % $s_sources"
if [[ $mod -eq 0 ]]; then
line=""
while [[ ${#line} -lt $4*2 ]]; do
line="\t"$line
done
fi
[[ $mod -gt 0 ]] && line+=" "
line+="${array[$i]}"
if [[ $mod -eq $s_sources-1 || $i -eq $c_sources-1 ]]; then
[[ $i -lt $c_sources-1 ]] && line+=" \\\\\\n"
lines+=$line
fi
done
sed -i "s/^\s.*$2\s*$/\0 \\\\\\n$lines/" $1
fi
}
################################################################################
# sudo apt-get -y install libsdl1.2-dev libsdl-net1.2-dev libsdl-sound1.2-dev libpcap-dev automake autoconf subversion cmake qt5-default bximage
#[[ ! "$LD_LIBRARY_PATH" =~ "/usr/local/lib:" ]] && export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
#grep -q "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" ~/.bashrc; [ $? -eq 1 ] && echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> ~/.bashrc
#grep -q "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" ~/.bashrc; [ $? -eq 1 ] && echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" | sudo tee -a ~/.bashrc
################################################################################
# MUNT
# https://github.com/munt/
if [ ! -f "/usr/local/include/mt32emu/mt32emu.h" ]; then
cd ~
[ -d "munt" ] && rm -fr munt
git clone https://github.com/munt/munt.git
cd munt
cmake -DCMAKE_BUILD_TYPE:STRING=Release .
make
sudo make install
sudo ldconfig
fi
# FluidSynth
# http://www.fluidsynth.org/
if [ ! -f "/usr/local/include/fluidsynth.h" ]; then
cd ~
[ -d "fluidsynth" ] && rm -fr fluidsynth
git clone https://github.com/FluidSynth/fluidsynth.git
cd fluidsynth
cmake .
make
sudo make install
sudo ldconfig
fi
# DOSBox
# https://www.dosbox.com/
cd ~
[ -d "dosbox" ] && rm -fr dosbox
svn checkout svn://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk dosbox
cd dosbox
./autogen.sh
if [[ "$(uname -m)" =~ ^armv6.* ]]; then
CXXFLAGS="-O2 -mfpu=vfp -march=armv6j -mfloat-abi=hard" ./configure --disable-opengl
sed -i "s/C_TARGETCPU.*/C_TARGETCPU ARMV4LE/g" config.h
else
# CXXFLAGS="-O2 -mfpu=neon-vfpv4 -march=armv7-a -mfloat-abi=hard" ./configure --disable-opengl
CXXFLAGS="-O2 -mfpu=neon-vfpv4 -march=armv7-a -mfloat-abi=hard" ./configure
# sed -i "s/C_TARGETCPU.*/C_TARGETCPU ARMV7LE/g" config.h
# echo "#define C_DYNREC 1" >>config.h
# echo "#define C_UNALIGNED_MEMORY 1" >>config.h
fi
################################################################################
# ARMv7 Processor Optimisations
wget -O armv7.diff http://www.technologist.site/wp-content/uploads/dosbox/armv7_r4068_20180123.diff
patch -p0 < armv7.diff
#
#wget -O voodoo.diff http://www.technologist.site/wp-content/uploads/dosbox/voodoo_20141226.diff
#patch -p0 < voodoo.diff
# Scaler Normalx4/x5/x6
# http://www.vogons.org/viewtopic.php?f=41&t=43899
wget -O scalers.diff http://www.technologist.site/wp-content/uploads/dosbox/scalers_r3850_20131126.diff
sed -i 's/^\s.*\"none\", \"normal2x\", \"normal3x\",*$/\0 "normal4x", "normal5x", "normal6x",/' src/dosbox.cpp
sed -i -e '1,12d' scalers.diff
patch -p1 < scalers.diff
# MUNT Roland MT-32 Synthesizer Emulator
# https://sourceforge.net/projects/munt/
wget -O mt32.diff http://www.technologist.site/wp-content/uploads/dosbox/mt32_r4025_20170706.diff
sed -i -e '33,43d' mt32.diff
gui_sources+=("midi_mt32.h")
gui_sources+=("midi_mt32.cpp")
patch -p1 < mt32.diff
# FluidSynth SoundFont Synthesizer
# http://www.fluidsynth.org/
wget -O fluidsynth.diff http://www.technologist.site/wp-content/uploads/dosbox/fluidsynth_r3955_20160119.diff
sed -i 's/^\(.*\"default\", \"win32\", \"alsa\", \"oss\", \"coreaudio\", \"coremidi\",\)\s*\(.*\)$/\1 \"mt32\", \2/g' fluidsynth.diff
patch -p1 < fluidsynth.diff
# Improved Yamaha YMF262 OPL3 Emulation
# http://www.vogons.org/viewtopic.php?f=41&t=23371
wget -O nukedopl.diff http://www.technologist.site/wp-content/uploads/dosbox/nukedopl_r3990_20160804.diff
sed -i -e '74,94d' nukedopl.diff
hardware_extra_dist+=("nukedopl.h")
hardware_sources+=("nukedopl.cpp")
patch -p0 < nukedopl.diff
# Improved PC Speaker Emulation
# http://www.vogons.org/viewtopic.php?f=41&t=23371
#wget -O pcspeaker.diff http://www.technologist.site/wp-content/uploads/dosbox/pcspeaker_20131005.diff
#patch -p0 < pcspeaker.diff
# NE2000 Network Adapter
# https://sourceforge.net/p/dosbox/patches/238/
wget -O ne2000.diff http://www.technologist.site/wp-content/uploads/dosbox/ne2000_r3661_20170516.diff
sed -i -e '1704,1716d' ne2000.diff
sed -i 's/configure.in/configure.ac/g' ne2000.diff
hardware_sources+=("ne2000.cpp")
patch -p0 < ne2000.diff
# Add sanity check to UMB Linking
# https://sourceforge.net/p/dosbox/patches/254/
wget -O umb_linking.diff http://www.technologist.site/wp-content/uploads/dosbox/umb_linking_r3780_20120529.diff
patch -p0 < umb_linking.diff
# Large Disk Support larger than 2GB
# http://www.vogons.org/viewtopic.php?f=41&t=34642
#wget -O larger_than_2gb.diff http://www.technologist.site/wp-content/uploads/dosbox/larger_than_2gb_20130212.diff
#patch -p0 < larger_than_2gb.diff
# Update IMGMAKE command and autodetect geometry
# http://www.vogons.org/viewtopic.php?f=41&t=34642#p302954
#wget -O imgmake.diff http://www.technologist.site/wp-content/uploads/dosbox/imgmake_20130421.diff
#patch -p1 < imgmake.diff
################################################################################
echo "Updating Sources..."
if [[ ${#hardware_extra_dist[*]} -gt 0 ]]; then
extra_dist=${hardware_extra_dist[@]}
sed -i "s/^EXTRA_DIST\s.*=.*$/\0 $extra_dist/" src/hardware/Makefile.am
fi
UpdateSources "src/hardware/Makefile.am" "cmos.cpp disney.cpp gus.cpp mpu401.cpp ipx.cpp ipxserver.cpp dbopl.cpp" hardware_sources[@] 24 7
UpdateSources "src/gui/Makefile.am" "midi_coremidi.h sdl_gui.cpp dosbox_splash.h" gui_sources[@] 8 3
# Compile DOSBOX
#make
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment