diff options
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 74 |
1 files changed, 60 insertions, 14 deletions
diff --git a/meson.build b/meson.build index a8bd4ae..611408f 100644 --- a/meson.build +++ b/meson.build @@ -1,32 +1,78 @@ -project('Pong', 'c', license : 'GPL-3.0-only', version : '0.2', default_options : ['warning_level=3', 'werror=true', 'optimization=g', 'c_std=c11', 'prefix=/opt']) -add_project_link_arguments('../raylib/libraylib.a', '-lm', '-ldl', '-lrt', language : 'c') +project('Pong', 'c', license : 'GPL-3.0-only', version : '0.2', default_options : ['warning_level=3', 'werror=false', 'optimization=g', 'c_std=c11', 'prefix=/opt']) fs = import('fs') +# Checks if on UNIX/POSIX System +if host_machine.system() != 'windows' + if host_machine.system() != 'darwin' + set_variable('posix', true) + endif +else + set_variable('posix', false) +endif + +if get_variable('posix') == true + message('Cleaning raylib...') + # First clean up + run_command('make', '-C', 'raylib/src', 'clean', capture : true, check : true) + message('Building raylib...') + # Then Build + run_command('make', '-C', 'raylib/src', 'PLATFORM=PLATFORM_DESKTOP', 'RAYLIB_BUILD_MODE=RELEASE', capture : true, check : true) +else + message('Cleaning raylib...') + # Have to put OS_PLATFORM=linux or makefile will complain about del command not being found. + run_command('mingw32-make', '-C', 'raylib/src', 'PLATFORM_OS=linux', 'clean', capture : true, check : true) + message('Building raylib...') + run_command('mingw32-make', '-C', 'raylib/src', 'PLATFORM=PLATFORM_DESKTOP', 'RAYLIB_BUILD_MODE=RELEASE', capture : true, check : true) +endif -message('Cleaning raylib...') -# First clean up -run_command('make', '-C', 'raylib/src', 'clean', capture : true, check : true) -message('Building raylib...') -# Then Build -run_command('make', '-C', 'raylib/src', 'PLATFORM=PLATFORM_DESKTOP', 'RAYLIB_BUILD_MODE=RELEASE', capture : true, check : true) +# Find the static library if fs.exists('raylib/libraylib.a') == true - message('raylib successfully compiled.') + add_project_link_arguments('../raylib/libraylib.a', language : 'c') +elif fs.exists('raylib/src/libraylib.a') == true + add_project_link_arguments('../raylib/src/libraylib.a', language : 'c') else error('raylib failed to compile. Check meson-logs to see what went wrong.') endif -Raylib_Include = include_directories('raylib/src') +message('raylib successfully compiled.') + +Include_Directories = include_directories('raylib/src') # Install launcher if flatpak if get_option('build_flatpak') == true install_data('src/launch.sh', install_dir : 'bin') endif -X11_Dep = dependency('x11') -Threads_Dep = dependency('threads') +# Checks if on UNIX/POSIX System +if host_machine.system() != 'windows' + if host_machine.system() != 'darwin' + set_variable('posix', true) + endif +else + set_variable('posix', false) +endif + +if get_variable('posix') == true + X11_Dep = dependency('x11') +endif + GL_Dep = dependency('gl') +Threads_Dep = dependency('threads') Sources = ['src/main.c', 'src/enemy.c', 'src/ball.c', 'src/title.c', 'src/versus.c', 'src/marathon.c'] -executable('pong', Sources, dependencies : [X11_Dep, Threads_Dep, GL_Dep], install : true, install_dir : 'Pong', include_directories : Raylib_Include) -install_subdir('resources', install_dir : 'Pong') \ No newline at end of file +if get_variable('posix') == true + Dependencies = [GL_Dep, Threads_Dep, X11_Dep] + add_project_link_arguments('-lGL', '-lm', '-lpthread', '-ldl', '-lrt', '-lX11', language : 'c') +else + Dependencies = [GL_Dep, Threads_Dep] + add_project_link_arguments('-lopengl32', '-lgdi32', '-lwinmm', '-lpthread', '-lm', language : 'c') +endif + +# If on windows, we need the c11 threads emulation layer. +if get_variable('posix') == false + Include_Directories = include_directories(['raylib/src', 'src/windows']) +endif + +executable('pong', Sources, dependencies : Dependencies, install : true, install_dir : 'Pong', include_directories : Include_Directories) +install_subdir('resources', install_dir : 'Pong') |