2020-12-14 04:14:08 +01:00
|
|
|
project('dosbox-staging', 'c', 'cpp',
|
|
|
|
default_options : ['cpp_std=c++14', 'b_ndebug=if-release'],
|
|
|
|
version : '0.77.0')
|
|
|
|
|
2021-02-06 18:06:49 +01:00
|
|
|
|
|
|
|
# meson version check
|
|
|
|
#
|
|
|
|
# After increasing the minimum-required meson version, make the following
|
|
|
|
# improvements:
|
|
|
|
#
|
|
|
|
# - 0.51.0 - remove warning about assertions in buildtype=plain
|
|
|
|
# - 0.56.0 - use meson.current_source_dir() in unit tests
|
|
|
|
#
|
2021-02-06 18:58:02 +01:00
|
|
|
assert(meson.version().version_compare('>= 0.49.0'),
|
|
|
|
'Expecting meson 0.49.0 or newer.')
|
2020-12-14 04:14:08 +01:00
|
|
|
|
2021-01-26 16:20:40 +01:00
|
|
|
# https://mesonbuild.com/Release-notes-for-0-51-0.html#n_debugifrelease-and-buildtypeplain-means-no-asserts
|
|
|
|
is_plain_build = (get_option('buildtype') == 'plain')
|
|
|
|
if meson.version().version_compare('< 0.51.0') and is_plain_build
|
|
|
|
warning('C assertions might be enabled, use buildtype=release instead')
|
|
|
|
endif
|
|
|
|
|
2021-02-06 18:06:49 +01:00
|
|
|
|
2020-12-14 04:14:08 +01:00
|
|
|
# compiler flags
|
|
|
|
#
|
2020-12-16 20:26:16 +01:00
|
|
|
# Warnings enabled below are our baseline; use '-Dwarning_level=3' to
|
|
|
|
# turn on more. The default level is 1 (meson turns on -Wall).
|
|
|
|
#
|
2020-12-14 04:14:08 +01:00
|
|
|
cc = meson.get_compiler('c')
|
|
|
|
cxx = meson.get_compiler('cpp')
|
|
|
|
|
|
|
|
add_global_arguments('-Weffc++', language : 'cpp')
|
|
|
|
if cxx.has_argument('-Wextra-semi')
|
|
|
|
add_global_arguments('-Wextra-semi', language : 'cpp')
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2020-12-20 11:38:00 +01:00
|
|
|
# gather data for config file
|
2020-12-14 04:14:08 +01:00
|
|
|
#
|
2021-01-12 20:45:49 +01:00
|
|
|
# Actual config.h file will be generated after all interpreting build files
|
|
|
|
# for all subdirs.
|
|
|
|
#
|
2020-12-14 04:14:08 +01:00
|
|
|
conf_data = configuration_data()
|
|
|
|
conf_data.set('version', meson.project_version())
|
2021-01-04 23:54:37 +01:00
|
|
|
|
2021-02-07 22:17:05 +01:00
|
|
|
os_family_name = {
|
|
|
|
'linux' : 'LINUX',
|
|
|
|
'windows' : 'WIN32',
|
|
|
|
'cygwin' : 'WIN32',
|
|
|
|
'darwin' : 'MACOSX',
|
|
|
|
'freebsd' : 'BSD',
|
|
|
|
'netbsd' : 'BSD',
|
|
|
|
'openbsd' : 'BSD',
|
|
|
|
'dragonfly' : 'BSD',
|
|
|
|
}.get(host_machine.system(), 'UNKNOWN_OS')
|
|
|
|
conf_data.set(os_family_name, 1)
|
2021-01-04 23:54:37 +01:00
|
|
|
|
2020-12-14 04:14:08 +01:00
|
|
|
conf_data.set10('C_MODEM', get_option('use_sdl2_net'))
|
|
|
|
conf_data.set10('C_IPX', get_option('use_sdl2_net'))
|
|
|
|
conf_data.set10('C_OPENGL', get_option('use_opengl'))
|
|
|
|
conf_data.set10('C_FLUIDSYNTH', get_option('use_fluidsynth'))
|
|
|
|
conf_data.set10('C_SSHOT', get_option('use_png'))
|
2021-01-12 20:45:49 +01:00
|
|
|
conf_data.set10('C_FPU', true)
|
2021-02-06 18:58:02 +01:00
|
|
|
conf_data.set10('C_FPU_X86', host_machine.cpu_family() in ['x86', 'x86_64'])
|
2020-12-14 04:14:08 +01:00
|
|
|
|
2021-01-14 21:53:42 +01:00
|
|
|
if get_option('enable_debugger') != 'none'
|
|
|
|
conf_data.set10('C_DEBUG', true)
|
2020-12-14 04:14:08 +01:00
|
|
|
endif
|
|
|
|
|
2021-01-14 21:53:42 +01:00
|
|
|
if get_option('enable_debugger') == 'heavy'
|
|
|
|
conf_data.set10('C_HEAVY_DEBUG', true)
|
2021-01-12 22:14:51 +01:00
|
|
|
endif
|
|
|
|
|
2021-01-21 16:18:40 +01:00
|
|
|
foreach osdef : ['LINUX', 'WIN32', 'MACOSX', 'BSD']
|
|
|
|
if conf_data.has(osdef)
|
|
|
|
conf_data.set10('C_DIRECTSERIAL', true)
|
|
|
|
endif
|
|
|
|
endforeach
|
|
|
|
|
2021-01-14 21:53:42 +01:00
|
|
|
if cc.has_function('clock_gettime', prefix : '#include <time.h>')
|
|
|
|
conf_data.set10('HAVE_CLOCK_GETTIME', true)
|
2020-12-14 04:14:08 +01:00
|
|
|
endif
|
|
|
|
|
2021-01-14 21:53:42 +01:00
|
|
|
if cc.has_function('mprotect', prefix : '#include <sys/mman.h>')
|
|
|
|
conf_data.set10('HAVE_MPROTECT', true)
|
2020-12-17 07:15:53 +01:00
|
|
|
endif
|
|
|
|
|
2021-01-04 21:32:03 +01:00
|
|
|
if cc.has_function('realpath', prefix : '#include <stdlib.h>')
|
|
|
|
conf_data.set10('HAVE_REALPATH', true)
|
|
|
|
endif
|
|
|
|
|
2021-01-14 21:53:42 +01:00
|
|
|
if cc.has_member('struct dirent', 'd_type', prefix : '#include <dirent.h>')
|
|
|
|
conf_data.set10('HAVE_STRUCT_DIRENT_D_TYPE', true)
|
2020-12-17 07:15:53 +01:00
|
|
|
endif
|
|
|
|
|
2021-01-14 22:35:18 +01:00
|
|
|
foreach header : ['pwd.h', 'strings.h', 'netinet/in.h', 'sys/socket.h']
|
|
|
|
if cc.has_header(header)
|
|
|
|
conf_data.set('HAVE_' + header.underscorify().to_upper(), 1)
|
|
|
|
endif
|
|
|
|
endforeach
|
2021-01-04 21:57:58 +01:00
|
|
|
|
2021-01-21 16:33:25 +01:00
|
|
|
# Header windows.h defines old min/max macros, that conflict with C++11
|
|
|
|
# std::min/std::max. Defining NOMINMAX prevents these macros from appearing.
|
|
|
|
if cxx.get_id() == 'msvc'
|
|
|
|
conf_data.set('NOMINMAX', true)
|
|
|
|
endif
|
|
|
|
|
2021-02-06 18:58:02 +01:00
|
|
|
if host_machine.system() in ['windows', 'cygwin']
|
2021-01-21 22:49:07 +01:00
|
|
|
conf_data.set('_USE_MATH_DEFINES', true)
|
|
|
|
endif
|
|
|
|
|
2020-12-23 07:51:26 +01:00
|
|
|
if host_machine.endian() == 'big'
|
|
|
|
conf_data.set('WORDS_BIGENDIAN', 1)
|
|
|
|
endif
|
|
|
|
|
2021-01-12 22:00:50 +01:00
|
|
|
# Non-4K memory page size is supported only for ppc64 at the moment.
|
2021-02-06 18:58:02 +01:00
|
|
|
if host_machine.cpu_family() in ['ppc64', 'ppc64le']
|
2021-01-12 22:00:50 +01:00
|
|
|
conf_data.set('PAGESIZE', 65536)
|
|
|
|
endif
|
|
|
|
|
2021-01-13 02:04:50 +01:00
|
|
|
set_prio_code = '''
|
|
|
|
#include <sys/resource.h>
|
|
|
|
int main() {
|
|
|
|
return setpriority(PRIO_PROCESS, 0, PRIO_MIN + PRIO_MAX);
|
|
|
|
}
|
|
|
|
'''
|
|
|
|
if cc.compiles(set_prio_code, name : 'test for setpriority support')
|
|
|
|
conf_data.set('HAVE_SETPRIORITY', 1)
|
|
|
|
endif
|
|
|
|
|
2021-01-21 15:49:04 +01:00
|
|
|
# New compilers can check for this feature using __has_builtin, but this is
|
|
|
|
# broken prior to Clang 10 and GCC 10, so we prefer to have this compilation
|
|
|
|
# check for now:
|
|
|
|
builtin_expect_code = '''
|
|
|
|
void fun(bool test) {
|
|
|
|
// value of 'test' is usually going to be true
|
|
|
|
if (__builtin_expect(test, true)) {
|
|
|
|
/* likely branch */
|
|
|
|
} else {
|
|
|
|
/* unlikely branch */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'''
|
|
|
|
if cxx.compiles(builtin_expect_code, name : 'test for __builtin_expect support')
|
|
|
|
conf_data.set('C_HAS_BUILTIN_EXPECT', 1)
|
|
|
|
endif
|
|
|
|
|
2020-12-14 04:14:08 +01:00
|
|
|
|
|
|
|
# external dependencies
|
|
|
|
#
|
2021-01-18 22:56:03 +01:00
|
|
|
optional_dep = dependency('', required : false)
|
|
|
|
threads_dep = dependency('threads')
|
|
|
|
sdl2_dep = dependency('sdl2', version : '>= 2.0.2')
|
|
|
|
sdl2_net_dep = optional_dep
|
|
|
|
opengl_dep = optional_dep
|
|
|
|
fluid_dep = optional_dep
|
|
|
|
opus_dep = optional_dep
|
|
|
|
png_dep = optional_dep
|
|
|
|
z_dep = optional_dep
|
|
|
|
curses_dep = optional_dep # necessary for debugger builds
|
2021-01-21 13:44:19 +01:00
|
|
|
alsa_dep = optional_dep # Linux-only
|
|
|
|
coreaudio_dep = optional_dep # macOS-only
|
|
|
|
coremidi_dep = optional_dep # macOS-only
|
2021-01-22 01:36:26 +01:00
|
|
|
winsock2_dep = optional_dep # Windows-only
|
|
|
|
winmm_dep = optional_dep # Windows-only
|
2021-01-18 22:56:03 +01:00
|
|
|
|
2020-12-14 04:14:08 +01:00
|
|
|
msg = 'You can disable this dependency with: -D@0@=false'
|
|
|
|
|
|
|
|
if get_option('use_sdl2_net')
|
|
|
|
sdl2_net_dep = dependency('SDL2_net', version : '>= 2.0.1',
|
|
|
|
not_found_message : msg.format('use_sdl2_net'))
|
|
|
|
endif
|
|
|
|
|
|
|
|
if get_option('use_opengl')
|
|
|
|
opengl_dep = dependency('gl', not_found_message : msg.format('use_opengl'))
|
|
|
|
endif
|
|
|
|
|
|
|
|
if get_option('use_fluidsynth')
|
|
|
|
fluid_dep = dependency('fluidsynth', version : '>= 2.0.0',
|
|
|
|
not_found_message : msg.format('use_fluidsynth'))
|
|
|
|
endif
|
|
|
|
|
|
|
|
if get_option('use_opusfile')
|
|
|
|
opus_dep = dependency('opusfile', not_found_message : msg.format('use_opusfile'))
|
|
|
|
endif
|
|
|
|
|
|
|
|
if get_option('use_png')
|
|
|
|
png_dep = dependency('libpng', not_found_message : msg.format('use_png'))
|
|
|
|
z_dep = dependency('zlib') # libpng in Ubuntu 16.04 needs zlib linked explicitly
|
|
|
|
endif
|
|
|
|
|
2021-01-18 22:56:03 +01:00
|
|
|
if get_option('enable_debugger') != 'none'
|
2020-12-17 07:15:53 +01:00
|
|
|
curses_dep = dependency('ncurses') # or pdcurses on Windows
|
|
|
|
endif
|
|
|
|
|
2021-01-18 21:48:12 +01:00
|
|
|
# macOS-only dependencies
|
|
|
|
#
|
|
|
|
if host_machine.system() == 'darwin'
|
|
|
|
coreaudio_dep = dependency('appleframeworks',
|
|
|
|
modules : ['CoreAudio', 'AudioUnit', 'AudioToolbox'],
|
|
|
|
required : false)
|
|
|
|
if coreaudio_dep.found()
|
2021-01-21 13:28:54 +01:00
|
|
|
conf_data.set('C_COREAUDIO', 1)
|
2021-01-18 21:48:12 +01:00
|
|
|
else
|
|
|
|
warning('''Core Audio support disabled: compiler can't detect/use Apple Frameworks''')
|
|
|
|
endif
|
|
|
|
|
|
|
|
coremidi_dep = dependency('appleframeworks',
|
|
|
|
modules : ['CoreMIDI', 'CoreFoundation'],
|
|
|
|
required : false)
|
|
|
|
if coremidi_dep.found()
|
2021-01-21 13:28:54 +01:00
|
|
|
conf_data.set('C_COREMIDI', 1)
|
2021-01-18 21:48:12 +01:00
|
|
|
else
|
|
|
|
warning('''Core MIDI support disabled: compiler can't detect/use Apple Frameworks''')
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2021-01-21 13:44:19 +01:00
|
|
|
# Linux-only dependencies
|
|
|
|
#
|
|
|
|
if host_machine.system() == 'linux'
|
|
|
|
alsa_dep = dependency('alsa')
|
|
|
|
conf_data.set('C_ALSA', 1)
|
|
|
|
endif
|
|
|
|
|
2021-01-22 01:36:26 +01:00
|
|
|
# Windows-only dependencies
|
|
|
|
#
|
2021-02-06 18:58:02 +01:00
|
|
|
if host_machine.system() in ['windows', 'cygwin']
|
2021-01-22 01:36:26 +01:00
|
|
|
winsock2_dep = cxx.find_library('ws2_32', required : true)
|
|
|
|
winmm_dep = cxx.find_library('winmm', required : true)
|
|
|
|
endif
|
|
|
|
|
2020-12-14 04:14:08 +01:00
|
|
|
|
|
|
|
# include directories
|
|
|
|
#
|
|
|
|
incdir = include_directories('include', '.')
|
|
|
|
|
|
|
|
|
|
|
|
# bundled dependencies
|
|
|
|
#
|
|
|
|
subdir('src/libs/decoders')
|
|
|
|
subdir('src/libs/nuked')
|
|
|
|
subdir('src/libs/ppscale')
|
|
|
|
|
|
|
|
libdecoders_dep = declare_dependency(link_with : libdecoders)
|
|
|
|
libnuked_dep = declare_dependency(link_with : libnuked)
|
|
|
|
libppscale_dep = declare_dependency(link_with : libppscale)
|
|
|
|
|
|
|
|
|
|
|
|
# internal libs
|
|
|
|
#
|
|
|
|
internal_deps = []
|
|
|
|
subdir('src/cpu')
|
|
|
|
subdir('src/debug')
|
|
|
|
subdir('src/dos')
|
|
|
|
subdir('src/fpu')
|
|
|
|
subdir('src/gui')
|
|
|
|
subdir('src/hardware')
|
|
|
|
subdir('src/ints')
|
|
|
|
subdir('src/midi')
|
|
|
|
subdir('src/misc')
|
|
|
|
subdir('src/shell')
|
|
|
|
|
|
|
|
|
2021-01-12 20:45:49 +01:00
|
|
|
# generate config.h
|
|
|
|
#
|
|
|
|
configure_file(input : 'src/config.h.in', output : 'config.h',
|
|
|
|
configuration : conf_data)
|
|
|
|
|
|
|
|
|
2020-12-19 00:32:37 +01:00
|
|
|
# tests
|
|
|
|
#
|
2021-02-06 18:58:02 +01:00
|
|
|
# Some tests use relative paths; in meson 0.56.0 this can be replaced
|
|
|
|
# with meson.project_source_root().
|
|
|
|
project_source_root = meson.current_source_dir()
|
|
|
|
subdir('tests')
|
2020-12-19 00:32:37 +01:00
|
|
|
|
|
|
|
|
2020-12-14 04:14:08 +01:00
|
|
|
# dosbox executable
|
|
|
|
#
|
|
|
|
executable('dosbox', ['src/main.cpp', 'src/dosbox.cpp'],
|
|
|
|
dependencies : [threads_dep, sdl2_dep] + internal_deps,
|
2021-02-04 16:56:23 +01:00
|
|
|
include_directories : incdir,
|
|
|
|
install : true)
|
|
|
|
|
|
|
|
|
|
|
|
# additional files for installation
|
|
|
|
#
|
|
|
|
data_dir = get_option('datadir')
|
|
|
|
licenses_dir = data_dir / 'licenses' / 'dosbox-staging'
|
|
|
|
doc_dir = data_dir / 'doc' / 'dosbox-staging'
|
|
|
|
|
|
|
|
install_man('docs/dosbox.1')
|
|
|
|
install_data('COPYING', install_dir : licenses_dir)
|
|
|
|
install_data('AUTHORS', 'README', 'THANKS', install_dir : doc_dir)
|
|
|
|
|
|
|
|
subdir('contrib/linux')
|
|
|
|
subdir('contrib/icons')
|