File: build-macos

package info (click to toggle)
dosbox-x 2025.12.01%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 53,224 kB
  • sloc: cpp: 339,768; ansic: 165,257; sh: 1,455; makefile: 963; perl: 385; python: 106; asm: 57
file content (161 lines) | stat: -rwxr-xr-x 5,354 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/env bash

# I'm sick and tired of all the churn the three versions of autoconf
# are causing in this repo. Stop committing the configure scripts
# and just autoregen.
./autogen.sh || exit 1

# where are we?
top=$(pwd)
if test -z "${top}" ; then exit 1; fi

# fix
chmod +x vs/sdl/build-scripts/strip_fPIC.sh

orig_CFLAGS="${CFLAGS}"
orig_LDFLAGS="${LDFLAGS}"
orig_CPPFLAGS="${CPPFLAGS}"
orig_CXXFLAGS="${CXXFLAGS}"

# Ensure sdl2 isn't detected as we aren't going to use it, and the presence of
# this folder will cause the build to fail.
rm -rf vs/sdl2/linux-host vs/sdl2/linux-build

# Remove our temporary copies of dosbox-x executable before rebuilding
rm -f src/dosbox-x-arm64 src/dosbox-x-x86_64

do_cleanup() {
    rm -rf vs/sdl/linux-host vs/sdl/linux-build
    rm -rf vs/sdlnet/linux-host vs/sdlnet/linux-build
    rm -rf vs/zlib/linux-host vs/zlib/linux-build
    rm -rf vs/libpng/linux-host vs/libpng/linux-build
    rm -rf vs/freetype/linux-host vs/freetype/linux-build
    [ -e Makefile ] && make clean
}

universal=0
architectures="$(uname -m)"
if [ "${1}" = "universal" ]; then
    shift
    if [ "${architectures}" = "arm64" ]; then
        # We can only build universal binaries on an arm64 host because we
        # need homebrew functional under both architectures.
        universal=1
        architectures="arm64 x86_64"
    fi
fi

arm64_brew_cmd=""
x86_64_brew_cmd=""
# arm64 native Homebrew
if [ -x /opt/homebrew/bin/brew ]; then
    arm64_brew_cmd="/opt/homebrew/bin/brew"
fi

# x86_64 Homebrew
if [ -x /usr/local/bin/brew ]; then
    # old homebrew
    x86_64_brew_cmd="/usr/local/bin/brew"
elif [ -x /usr/local/Homebrew/bin/brew ]; then
    # new homebrew
    x86_64_brew_cmd="/usr/local/Homebrew/bin/brew"
fi

# x86_64 on arm64 for universal builds if x86_64 Homebrew is installed
if [ -n "${x86_64_brew_cmd}" ] && [ "${universal}" -eq 1 ]; then
    x86_64_brew_cmd="/usr/bin/arch -x86_64 ${x86_64_brew_cmd}"
fi

for arch in ${architectures}; do
    declare brew_cmd="${arch}_brew_cmd"
    if [ -n "${!brew_cmd}" ]; then
        ${!brew_cmd} list fluid-synth &>/dev/null || ${!brew_cmd} install fluid-synth
        ${!brew_cmd} list libslirp &>/dev/null || ${!brew_cmd} install libslirp
        ${!brew_cmd} list pkg-config &>/dev/null || ${!brew_cmd} install pkg-config
    fi

    do_cleanup

    arch_flags="-arch ${arch} -mmacosx-version-min=10.13 "
    CFLAGS="${arch_flags}${orig_CFLAGS}"
    LDFLAGS="${arch_flags}${orig_LDFLAGS}"
    CPPFLAGS="${arch_flags}${orig_CPPFLAGS}"
    CXXFLAGS="${arch_flags}${orig_CXXFLAGS}"
    export CFLAGS LDFLAGS CPPFLAGS CXXFLAGS

    # prefer to compile against our own copy of SDL 1.x
    echo "Compiling our internal SDL 1.x"
    (cd vs/sdl && ./build-dosbox.sh) || exit 1
    new="-I${top}/vs/sdl/linux-host/include "
    nld="-L${top}/vs/sdl/linux-host/lib "
    CFLAGS="${CFLAGS}${new}"
    LDFLAGS="${LDFLAGS}${nld}"
    CPPFLAGS="${CPPFLAGS}${new}"
    CXXFLAGS="${CXXFLAGS}${new}"
    export CFLAGS LDFLAGS CPPFLAGS CXXFLAGS

    # prefer to compile against our own copy of SDLnet 1.x
    echo "Compiling our internal SDLnet 1.x"
    (cd vs/sdlnet && ./build-dosbox.sh) || exit 1

    # prefer to compile against our own zlib
    echo "Compiling our internal zlib"
    (cd vs/zlib && ./build-dosbox.sh) || exit 1
    new="-I${top}/vs/zlib/linux-host/include "
    nld="-L${top}/vs/zlib/linux-host/lib "
    CFLAGS="${CFLAGS}${new}"
    LDFLAGS="${LDFLAGS}${nld}"
    CPPFLAGS="${CPPFLAGS}${new}"
    CXXFLAGS="${CXXFLAGS}${new}"
    export CFLAGS LDFLAGS CPPFLAGS CXXFLAGS

    # prefer to compile against our own libpng (comment this out to disable)
    echo "Compiling our internal libpng"
    (cd vs/libpng && ./build-dosbox.sh) || exit 1
    new="-I${top}/vs/libpng/linux-host/include "
    nld="-L${top}/vs/libpng/linux-host/lib "
    CFLAGS="${CFLAGS}${new}"
    LDFLAGS="${LDFLAGS}${nld}"
    CPPFLAGS="${CPPFLAGS}${new}"
    CXXFLAGS="${CXXFLAGS}${new}"
    export CFLAGS LDFLAGS CPPFLAGS CXXFLAGS

    # prefer to compile against our own freetype
    echo "Compiling our internal freetype"
    (cd vs/freetype && ./build-dosbox.sh) || exit 1
    new="-I${top}/vs/freetype/linux-host/include/freetype2 "
    nld="-L${top}/vs/freetype/linux-host/lib -lfreetype "
    CFLAGS="${CFLAGS}${new}"
    LDFLAGS="${LDFLAGS}${nld}"
    CPPFLAGS="${CPPFLAGS}${new}"
    CXXFLAGS="${CXXFLAGS}${new}"
    INTERNAL_FREETYPE=1
    export CFLAGS LDFLAGS CPPFLAGS CXXFLAGS INTERNAL_FREETYPE

    opts=

    # if Brew has installed packages, try to use those too
    if [ -n "${!brew_cmd}" ]; then
        echo "Brew is installed, I'm going to use its libraries too"
        new="-I$(${!brew_cmd} --prefix)/include "
        nld="-L$(${!brew_cmd} --prefix)/lib "
        CFLAGS="${CFLAGS}${new}"
        LDFLAGS="${LDFLAGS}${nld}"
        CPPFLAGS="${CPPFLAGS}${new}"
        CXXFLAGS="${CXXFLAGS}${new}"
        PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:$(${!brew_cmd} --prefix)/lib/pkgconfig"
        export CFLAGS LDFLAGS CPPFLAGS CXXFLAGS PKG_CONFIG_PATH
    fi

    if [ "${universal}" = 1 ]; then
        opts="${opts} --enable-universal"
    fi

    # now compile ourself
    echo "Compiling DOSBox-X"
    chmod +x configure
    ./configure --enable-debug=heavy --prefix=/usr "${opts}" "${@}" || exit 1
    make -j3 || exit 1

    cp src/dosbox-x "src/dosbox-x-${arch}"
done