blargh fighting with meson

This commit is contained in:
Jōshin 2018-12-27 10:27:28 -08:00
parent 7a7e7b30f8
commit 8ef34bea65
5 changed files with 30 additions and 25 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

View File

View File

@ -3,6 +3,8 @@
#include <stddef.h> #include <stddef.h>
#include <ent/config.h>
/* /*
* Fills buf with high-quality entropy. * Fills buf with high-quality entropy.
* *

23
include/ent/meson.build Normal file
View File

@ -0,0 +1,23 @@
conf_data = configuration_data()
compiler = meson.get_compiler('c')
code = '''#include <unistd.h>
#include <sys/random.h>
int main() { return getentropy((void*)0, 0); }
'''
have_getentropy = compiler.links(code, name : 'system getentropy')
conf_data.set('ENT_USE_GETENTROPY', have_getentropy)
if not have_getentropy
code = '''#include <fcntl.h>
int main() { return -1 != open("/dev/urandom", O_RDONLY) ? 0 : 1; }
'''
use_urandom = compiler.run(code, name : 'open /dev/urandom')
conf_data.set('ENT_USE_URANDOM', use_urandom.returncode() == 0)
endif
configure_file(output : 'config.h',
configuration : conf_data,
install_dir : 'include/ent')
install_headers('ent.h', subdir : 'ent')

View File

@ -3,34 +3,13 @@ project('libent', 'c', 'cpp',
version : '0.0.1', version : '0.0.1',
license : 'MIT') license : 'MIT')
conf_data = configuration_data() subdir('include/ent')
compiler = meson.get_compiler('c')
code = '''#include <unistd.h> inc = include_directories('include')
#include <sys/random.h>
int main() { return getentropy((void*)0, 0); }
'''
have_getentropy = compiler.links(code,name : 'system getentropy')
conf_data.set('USE_GETENTROPY', have_getentropy)
if not have_getentropy ent_sources = ['ent.c']
code = '''#include <fcntl.h>
int main() { return -1 != open("/dev/urandom", O_RDONLY) ? 0 : 1; }
'''
use_urandom = compiler.run(code, name : 'open /dev/urandom')
conf_data.set('USE_URANDOM', use_urandom.returncode() == 0)
endif
configure_file(output : 'config.h', libent = both_libraries('ent',
configuration : conf_data)
inc = include_directories('.', 'include')
install_headers('include/ent.h')
ent_sources = ['src/ent.c']
libent = shared_library('ent',
ent_sources, ent_sources,
include_directories : inc, include_directories : inc,
install : true) install : true)