|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# I'm sick and tired of all the churn the three versions of autoconf |
| 4 | +# are causing in this repo. Stop committing the configure scripts |
| 5 | +# and just autoregen. |
| 6 | +./autogen.sh || exit 1 |
| 7 | + |
| 8 | +# where are we? |
| 9 | +top=$(pwd) |
| 10 | +if test -z "${top}" ; then exit 1; fi |
| 11 | + |
| 12 | +# fix |
| 13 | +chmod +x vs/sdl/build-scripts/strip_fPIC.sh |
| 14 | + |
| 15 | +orig_CFLAGS="${CFLAGS}" |
| 16 | +orig_LDFLAGS="${LDFLAGS}" |
| 17 | +orig_CPPFLAGS="${CPPFLAGS}" |
| 18 | +orig_CXXFLAGS="${CXXFLAGS}" |
| 19 | + |
| 20 | +# Ensure sdl2 isn't detected as we aren't going to use it, and the presence of |
| 21 | +# this folder will cause the build to fail. |
| 22 | +rm -rf vs/sdl2/linux-host vs/sdl2/linux-build |
| 23 | + |
| 24 | +# Remove our temporary copies of dosbox-x executable before rebuilding |
| 25 | +rm -f src/dosbox-x-arm64 src/dosbox-x-x86_64 |
| 26 | + |
| 27 | +do_cleanup() { |
| 28 | + rm -rf vs/sdl/linux-host vs/sdl/linux-build |
| 29 | + rm -rf vs/sdlnet/linux-host vs/sdlnet/linux-build |
| 30 | + rm -rf vs/zlib/linux-host vs/zlib/linux-build |
| 31 | + rm -rf vs/libpng/linux-host vs/libpng/linux-build |
| 32 | + rm -rf vs/freetype/linux-host vs/freetype/linux-build |
| 33 | + [ -e Makefile ] && make clean |
| 34 | +} |
| 35 | + |
| 36 | +universal=0 |
| 37 | +architectures="$(uname -m)" |
| 38 | +#if [ "${1}" = "universal" ]; then |
| 39 | +# shift |
| 40 | +# if [ "${architectures}" = "arm64" ]; then |
| 41 | +# # We can only build universal binaries on an arm64 host because we |
| 42 | +# # need homebrew functional under both architectures. |
| 43 | +# universal=1 |
| 44 | +# architectures="arm64 x86_64" |
| 45 | +# fi |
| 46 | +#fi |
| 47 | + |
| 48 | +arm64_brew_cmd="" |
| 49 | +x86_64_brew_cmd="" |
| 50 | +# arm64 native Homebrew |
| 51 | +#if [ -x /opt/homebrew/bin/brew ]; then |
| 52 | +# arm64_brew_cmd="/opt/homebrew/bin/brew" |
| 53 | +#fi |
| 54 | + |
| 55 | +# x86_64 Homebrew |
| 56 | +#if [ -x /usr/local/bin/brew ]; then |
| 57 | +# # old homebrew |
| 58 | +# x86_64_brew_cmd="/usr/local/bin/brew" |
| 59 | +#elif [ -x /usr/local/Homebrew/bin/brew ]; then |
| 60 | +# # new homebrew |
| 61 | +# x86_64_brew_cmd="/usr/local/Homebrew/bin/brew" |
| 62 | +#fi |
| 63 | + |
| 64 | +# x86_64 on arm64 for universal builds if x86_64 Homebrew is installed |
| 65 | +#if [ -n "${x86_64_brew_cmd}" ] && [ "${universal}" -eq 1 ]; then |
| 66 | +# x86_64_brew_cmd="/usr/bin/arch -x86_64 ${x86_64_brew_cmd}" |
| 67 | +#fi |
| 68 | + |
| 69 | +for arch in ${architectures}; do |
| 70 | + #declare brew_cmd="${arch}_brew_cmd" |
| 71 | + #if [ -n "${!brew_cmd}" ]; then |
| 72 | + # ${!brew_cmd} list fluid-synth &>/dev/null || ${!brew_cmd} install fluid-synth |
| 73 | + # ${!brew_cmd} list libslirp &>/dev/null || ${!brew_cmd} install libslirp |
| 74 | + # ${!brew_cmd} list pkg-config &>/dev/null || ${!brew_cmd} install pkg-config |
| 75 | + #fi |
| 76 | + |
| 77 | + do_cleanup |
| 78 | + |
| 79 | + #arch_flags="-arch ${arch} -mmacosx-version-min=10.11 " |
| 80 | + arch_flags="-arch ${arch} " |
| 81 | + CFLAGS="${arch_flags}${orig_CFLAGS}" |
| 82 | + LDFLAGS="${arch_flags}${orig_LDFLAGS}" |
| 83 | + CPPFLAGS="${arch_flags}${orig_CPPFLAGS}" |
| 84 | + CXXFLAGS="${arch_flags}${orig_CXXFLAGS}" |
| 85 | + export CFLAGS LDFLAGS CPPFLAGS CXXFLAGS |
| 86 | + |
| 87 | + # prefer to compile against our own copy of SDL 1.x |
| 88 | + echo "Compiling our internal SDL 1.x" |
| 89 | + (cd vs/sdl && ./build-dosbox.sh) || exit 1 |
| 90 | + new="-I${top}/vs/sdl/linux-host/include " |
| 91 | + nld="-L${top}/vs/sdl/linux-host/lib " |
| 92 | + CFLAGS="${CFLAGS}${new}" |
| 93 | + LDFLAGS="${LDFLAGS}${nld}" |
| 94 | + CPPFLAGS="${CPPFLAGS}${new}" |
| 95 | + CXXFLAGS="${CXXFLAGS}${new}" |
| 96 | + export CFLAGS LDFLAGS CPPFLAGS CXXFLAGS |
| 97 | + |
| 98 | + # prefer to compile against our own copy of SDLnet 1.x |
| 99 | + echo "Compiling our internal SDLnet 1.x" |
| 100 | + (cd vs/sdlnet && ./build-dosbox.sh) || exit 1 |
| 101 | + |
| 102 | + CPPFLAGS="${CPPFLAGS} $(pkg-config --cflags zlib) " |
| 103 | + CFLAGS="${CFLAGS} $(pkg-config --cflags zlib) " |
| 104 | + CXXFLAGS="${CXXFLAGS} $(pkg-config --cflags zlib) " |
| 105 | + LDFLAGS="${LDFLAGS} $(pkg-config --libs zlib) " |
| 106 | + |
| 107 | + # prefer to compile against our own zlib |
| 108 | + #echo "Compiling our internal zlib" |
| 109 | + #(cd vs/zlib && ./build-dosbox.sh) || exit 1 |
| 110 | + #new="-I${top}/vs/zlib/linux-host/include " |
| 111 | + #nld="-L${top}/vs/zlib/linux-host/lib " |
| 112 | + #CFLAGS="${CFLAGS}${new}" |
| 113 | + #LDFLAGS="${LDFLAGS}${nld}" |
| 114 | + #CPPFLAGS="${CPPFLAGS}${new}" |
| 115 | + #CXXFLAGS="${CXXFLAGS}${new}" |
| 116 | + export CFLAGS LDFLAGS CPPFLAGS CXXFLAGS |
| 117 | + |
| 118 | + CPPFLAGS="${CPPFLAGS} $(pkg-config --cflags libpng) " |
| 119 | + CFLAGS="${CFLAGS} $(pkg-config --cflags libpng) " |
| 120 | + CXXFLAGS="${CXXFLAGS} $(pkg-config --cflags libpng) " |
| 121 | + LDFLAGS="${LDFLAGS} $(pkg-config --libs libpng) " |
| 122 | + |
| 123 | + # prefer to compile against our own libpng (comment this out to disable) |
| 124 | + #echo "Compiling our internal libpng" |
| 125 | + #(cd vs/libpng && ./build-dosbox.sh) || exit 1 |
| 126 | + #new="-I${top}/vs/libpng/linux-host/include " |
| 127 | + #nld="-L${top}/vs/libpng/linux-host/lib " |
| 128 | + #CFLAGS="${CFLAGS}${new}" |
| 129 | + #LDFLAGS="${LDFLAGS}${nld}" |
| 130 | + #CPPFLAGS="${CPPFLAGS}${new}" |
| 131 | + #CXXFLAGS="${CXXFLAGS}${new}" |
| 132 | + export CFLAGS LDFLAGS CPPFLAGS CXXFLAGS |
| 133 | + |
| 134 | + # prefer to compile against our own freetype |
| 135 | + echo "Compiling our internal freetype" |
| 136 | + (cd vs/freetype && ./build-dosbox.sh) || exit 1 |
| 137 | + new="-I${top}/vs/freetype/linux-host/include/freetype2 " |
| 138 | + nld="-L${top}/vs/freetype/linux-host/lib -lfreetype " |
| 139 | + CFLAGS="${CFLAGS}${new}" |
| 140 | + LDFLAGS="${LDFLAGS}${nld}" |
| 141 | + CPPFLAGS="${CPPFLAGS}${new}" |
| 142 | + CXXFLAGS="${CXXFLAGS}${new}" |
| 143 | + INTERNAL_FREETYPE=1 |
| 144 | + export CFLAGS LDFLAGS CPPFLAGS CXXFLAGS INTERNAL_FREETYPE |
| 145 | + |
| 146 | + opts= |
| 147 | + |
| 148 | + # if Brew has installed packages, try to use those too |
| 149 | + #if [ -n "${!brew_cmd}" ]; then |
| 150 | + # echo "Brew is installed, I'm going to use its libraries too" |
| 151 | + # new="-I$(${!brew_cmd} --prefix)/include " |
| 152 | + # nld="-L$(${!brew_cmd} --prefix)/lib " |
| 153 | + # CFLAGS="${CFLAGS}${new}" |
| 154 | + # LDFLAGS="${LDFLAGS}${nld}" |
| 155 | + # CPPFLAGS="${CPPFLAGS}${new}" |
| 156 | + # CXXFLAGS="${CXXFLAGS}${new}" |
| 157 | + # PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:$(${!brew_cmd} --prefix)/lib/pkgconfig" |
| 158 | + # export CFLAGS LDFLAGS CPPFLAGS CXXFLAGS PKG_CONFIG_PATH |
| 159 | + #fi |
| 160 | + |
| 161 | + #if [ "${universal}" = 1 ]; then |
| 162 | + # opts="${opts} --enable-universal" |
| 163 | + #fi |
| 164 | + |
| 165 | + # now compile ourself |
| 166 | + echo "Compiling DOSBox-X" |
| 167 | + chmod +x configure |
| 168 | + ./configure --enable-debug=heavy --prefix=/usr "${opts}" "${@}" || exit 1 |
| 169 | + make -j3 || exit 1 |
| 170 | + |
| 171 | + cp src/dosbox-x "src/dosbox-x-${arch}" |
| 172 | +done |
0 commit comments