summaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build361
1 files changed, 212 insertions, 149 deletions
diff --git a/meson.build b/meson.build
index 9f498d7ab..f758365f3 100644
--- a/meson.build
+++ b/meson.build
@@ -1,6 +1,6 @@
project('glib', 'c', 'cpp',
- version : '2.57.1',
- meson_version : '>= 0.46.0',
+ version : '2.57.2',
+ meson_version : '>= 0.47.0',
default_options : [
'buildtype=debugoptimized',
'warning_level=1',
@@ -23,6 +23,8 @@ if cc.get_id() == 'msvc'
# Disable SAFESEH with MSVC for plugins and libs that use external deps that
# are built with MinGW
noseh_link_args = ['/SAFESEH:NO']
+ # Set the input and exec encoding to utf-8, like is the default with GCC
+ add_project_arguments(cc.get_supported_arguments(['/utf-8']), language: 'c')
else
noseh_link_args = []
# -mms-bitfields vs -fnative-struct ?
@@ -54,6 +56,7 @@ gioinc = include_directories('gio')
glib_prefix = get_option('prefix')
glib_bindir = join_paths(glib_prefix, get_option('bindir'))
glib_libdir = join_paths(glib_prefix, get_option('libdir'))
+glib_libexecdir = join_paths(glib_prefix, get_option('libexecdir'))
glib_datadir = join_paths(glib_prefix, get_option('datadir'))
glib_pkgdatadir = join_paths(glib_datadir, 'glib-2.0')
glib_includedir = join_paths(glib_prefix, get_option('includedir'))
@@ -64,6 +67,11 @@ endif
glib_pkgconfigreldir = join_paths(glib_libdir, 'pkgconfig')
+installed_tests_metadir = join_paths(glib_datadir, 'installed-tests', meson.project_name())
+installed_tests_execdir = join_paths(glib_libexecdir, 'installed-tests', meson.project_name())
+installed_tests_enabled = get_option('installed_tests')
+installed_tests_template = files('template.test.in')
+
add_project_arguments('-D_GNU_SOURCE', language: 'c')
# Disable strict aliasing;
@@ -82,14 +90,13 @@ glibconfig_conf = configuration_data()
# use them later in test programs (autoconf does this automatically)
glib_conf_prefix = ''
-glib_conf.set('GLIB_VERSION', glib_version)
glib_conf.set('GLIB_MAJOR_VERSION', major_version)
glib_conf.set('GLIB_MINOR_VERSION', minor_version)
glib_conf.set('GLIB_MICRO_VERSION', micro_version)
glib_conf.set('GLIB_INTERFACE_AGE', interface_age)
glib_conf.set('GLIB_BINARY_AGE', binary_age)
glib_conf.set_quoted('GETTEXT_PACKAGE', 'glib20')
-glib_conf.set_quoted('PACKAGE_BUGREPORT', 'http://bugzilla.gnome.org/enter_bug.cgi?product=glib')
+glib_conf.set_quoted('PACKAGE_BUGREPORT', 'https://gitlab.gnome.org/GNOME/glib/issues/new')
glib_conf.set_quoted('PACKAGE_NAME', 'glib')
glib_conf.set_quoted('PACKAGE_STRING', 'glib @0@'.format(meson.project_version()))
glib_conf.set_quoted('PACKAGE_TARNAME', 'glib')
@@ -97,16 +104,8 @@ glib_conf.set_quoted('PACKAGE_URL', '')
glib_conf.set_quoted('PACKAGE_VERSION', meson.project_version())
glib_conf.set('ENABLE_NLS', 1)
-# Variables used in glib-gettextize and pkg-config files
-# These should not contain " quotes around the values
-glib_conf.set('PACKAGE', 'glib')
-glib_conf.set('VERSION', meson.project_version())
-glib_conf.set('prefix', glib_prefix)
-glib_conf.set('exec_prefix', glib_prefix)
-glib_conf.set('libdir', glib_libdir)
-glib_conf.set('includedir', glib_includedir)
-glib_conf.set('datadir', glib_datadir)
-glib_conf.set('datarootdir', glib_datadir)
+# used by the .rc.in files
+glibconfig_conf.set('LT_CURRENT_MINUS_AGE', soversion)
glib_conf.set('_GNU_SOURCE', 1)
@@ -203,54 +202,53 @@ add_project_arguments(glib_debug_cflags, language: 'c')
# check for header files
headers = [
- 'stdlib.h',
- 'string.h',
- 'strings.h',
- 'memory.h',
'alloca.h',
- 'locale.h',
- 'xlocale.h',
+ 'crt_externs.h',
+ 'dirent.h', # MSC does not come with this by default
'float.h',
- 'limits.h',
- 'pwd.h',
+ 'fstab.h',
'grp.h',
+ 'inttypes.h',
+ 'limits.h',
+ 'linux/magic.h',
+ 'locale.h',
+ 'mach/mach_time.h',
+ 'memory.h',
+ 'mntent.h',
'poll.h',
- 'termios.h',
+ 'pwd.h',
+ 'sched.h',
+ 'stdint.h',
+ 'stdlib.h',
+ 'string.h',
+ 'strings.h',
+ 'sys/auxv.h',
+ 'sys/event.h',
+ 'sys/filio.h',
+ 'sys/inotify.h',
+ 'sys/mkdev.h',
+ 'sys/mntctl.h',
+ 'sys/mnttab.h',
+ 'sys/mount.h',
'sys/param.h',
'sys/resource.h',
- 'mach/mach_time.h',
'sys/select.h',
- 'stdint.h',
- 'inttypes.h',
- 'sched.h',
- 'malloc.h',
- 'sys/vfs.h',
- 'sys/vmount.h',
'sys/statfs.h',
+ 'sys/stat.h',
'sys/statvfs.h',
- 'sys/filio.h',
- 'mntent.h',
- 'sys/mnttab.h',
- 'sys/vfstab.h',
- 'sys/mntctl.h',
- 'fstab.h',
- 'linux/magic.h',
- 'termios.h',
- 'dirent.h', # MSC does not come with this by default
+ 'sys/sysctl.h',
'sys/time.h', # MSC does not come with this by default
'sys/times.h',
+ 'sys/types.h',
+ 'sys/uio.h',
+ 'sys/vfs.h',
+ 'sys/vfstab.h',
+ 'sys/vmount.h',
'sys/wait.h',
+ 'termios.h',
'unistd.h',
'values.h',
- 'sys/types.h',
- 'sys/uio.h',
- 'sys/mkdev.h',
- 'sys/mount.h',
- 'sys/sysctl.h',
- 'crt_externs.h',
- 'sys/inotify.h',
- 'sys/event.h',
- 'sys/stat.h',
+ 'xlocale.h',
]
foreach h : headers
@@ -261,6 +259,13 @@ foreach h : headers
endif
endforeach
+# FIXME: Use cc.check_header from Meson 0.47.
+# FreeBSD includes a malloc.h which always throw compilation error.
+if cc.compiles('#include <malloc.h>', name : 'malloc.h')
+ glib_conf.set('HAVE_MALLOC_H', 1)
+ glib_conf_prefix = glib_conf_prefix + '#define HAVE_MALLOC_H 1\n'
+endif
+
if cc.has_header('linux/netlink.h')
glib_conf.set('HAVE_NETLINK', 1)
endif
@@ -305,6 +310,10 @@ struct_members = [
[ 'statfs', 'f_bavail', struct_stat_blkprefix ],
[ 'dirent', 'd_type', '''#include <sys/types.h>
#include <dirent.h>''' ],
+ [ 'statvfs', 'f_basetype', '#include <sys/statvfs.h>' ],
+ [ 'statvfs', 'f_fstypename', '#include <sys/statvfs.h>' ],
+ [ 'tm', 'tm_gmtoff', '#include <time.h>' ],
+ [ 'tm', '__tm_gmtoff', '#include <time.h>' ],
]
foreach m : struct_members
@@ -327,7 +336,12 @@ if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
test_c_args = [
'-Wall',
'-Wduplicated-branches',
+ '-Wmisleading-indentation',
'-Wstrict-prototypes',
+ '-Wunused',
+ # Due to pervasive use of things like GPOINTER_TO_UINT(), we do not support
+ # building with -Wbad-function-cast.
+ '-Wno-bad-function-cast',
'-Werror=declaration-after-statement',
'-Werror=format=2',
'-Werror=format-security',
@@ -358,68 +372,69 @@ add_project_arguments(cc.get_supported_arguments(test_c_args), language: 'c')
# improve this.
glib_link_flags = cc.get_supported_link_arguments(test_c_link_args)
-# Windows Support (Vista+)
+# Windows Support (7+)
if host_system == 'windows'
glib_conf.set('_WIN32_WINNT', '0x0601')
endif
functions = [
'alloca',
- 'mmap',
- 'memalign',
- 'valloc',
- 'fsync',
- 'pipe2',
- 'issetugid',
- 'timegm',
- 'gmtime_r',
- 'strerror_r',
- 'lstat',
- 'strsignal',
- 'vsnprintf',
- 'poll',
- 'vasprintf',
- 'setenv',
- 'unsetenv',
- 'getc_unlocked',
- 'readlink',
- 'symlink',
- 'fdwalk',
- 'lchmod',
- 'lchown',
+ 'endmntent',
+ 'endservent',
+ 'fallocate',
'fchmod',
'fchown',
- 'utimes',
- 'getresuid',
- 'getmntent_r',
- 'setmntent',
- 'endmntent',
- 'hasmntopt',
+ 'fdwalk',
+ 'fsync',
+ 'getc_unlocked',
'getfsstat',
+ 'getgrgid_r',
+ 'getmntent_r',
+ 'getpwuid_r',
+ 'getresuid',
'getvfsstat',
- 'fallocate',
- 'localtime_r',
'gmtime_r',
- 'getpwuid_r',
- 'getgrgid_r',
- 'prlimit',
- 'strnlen',
- 'wcslen',
- 'wcsnlen',
+ 'hasmntopt',
+ 'inotify_init1',
+ 'issetugid',
+ 'kevent',
+ 'kqueue',
+ 'lchmod',
+ 'lchown',
+ 'link',
+ 'localtime_r',
+ 'lstat',
'mbrtowc',
- 'wcrtomb',
+ 'memalign',
+ 'mmap',
'newlocale',
- 'uselocale',
+ 'pipe2',
+ 'poll',
+ 'prlimit',
+ 'readlink',
+ 'recvmmsg',
+ 'sendmmsg',
+ 'setenv',
+ 'setmntent',
+ 'strerror_r',
+ 'strnlen',
+ 'strsignal',
'strtod_l',
'strtoll_l',
'strtoull_l',
- 'inotify_init1',
- 'kqueue',
- 'kevent',
- 'endservent',
- 'sendmmsg',
- 'recvmmsg',
- 'link',
+ 'symlink',
+ 'timegm',
+ 'unsetenv',
+ 'uselocale',
+ 'utimes',
+ 'valloc',
+ 'vasprintf',
+ 'vsnprintf',
+ 'wcrtomb',
+ 'wcslen',
+ 'wcsnlen',
+ 'sysctlbyname',
+ '_NSGetEnviron',
]
if glib_conf.has('HAVE_SYS_STATVFS_H')
@@ -437,8 +452,11 @@ if host_system == 'windows'
iphlpapi_dep = cc.find_library('iphlpapi')
iphlpapi_funcs = ['if_nametoindex', 'if_indextoname']
foreach ifunc : iphlpapi_funcs
+ iphl_prefix = '''#define _WIN32_WINNT @0@
+ #include <winsock2.h>
+ #include <iphlpapi.h>'''.format(glib_conf.get('_WIN32_WINNT'))
if cc.has_function(ifunc,
- prefix : '#define _WIN32_WINNT 0x0601\n#include <winsock2.h>\n#include <iphlpapi.h>',
+ prefix : iphl_prefix,
dependencies : iphlpapi_dep)
idefine = 'HAVE_' + ifunc.underscorify().to_upper()
glib_conf.set(idefine, 1)
@@ -478,6 +496,11 @@ if cc.has_function('posix_memalign', prefix : '#include <stdlib.h>')
glib_conf.set('HAVE_POSIX_MEMALIGN', 1)
endif
+# Check that posix_spawn() is usable; must use header
+if cc.has_function('posix_spawn', prefix : '#include <spawn.h>')
+ glib_conf.set('HAVE_POSIX_SPAWN', 1)
+endif
+
# Check whether strerror_r returns char *
if have_func_strerror_r
if cc.compiles('''#define _GNU_SOURCE
@@ -527,6 +550,8 @@ if cc.has_header_symbol('sys/sysmacros.h', 'major')
glib_conf.set('MAJOR_IN_SYSMACROS', 1)
elif cc.has_header_symbol('sys/mkdev.h', 'major')
glib_conf.set('MAJOR_IN_MKDEV', 1)
+elif cc.has_header_symbol('sys/types.h', 'major')
+ glib_conf.set('MAJOR_IN_TYPES', 1)
endif
if cc.has_header_symbol('dlfcn.h', 'RTLD_LAZY')
@@ -572,36 +597,47 @@ if host_system == 'linux'
endif
osx_ldflags = []
+glib_have_os_x_9_or_later = false
+glib_have_carbon = false
+glib_have_cocoa = false
+if host_system == 'darwin'
+ add_languages('objc')
+ objcc = meson.get_compiler('objc')
-# Mac OS X Carbon support
-glib_have_carbon = cc.compiles('''#include <Carbon/Carbon.h>
- #include <CoreServices/CoreServices.h>''',
- name : 'Mac OS X Carbon support')
+ osx_ldflags += ['-Wl,-framework,CoreFoundation']
-glib_have_os_x_9_or_later = false
+ # Mac OS X Carbon support
+ glib_have_carbon = objcc.compiles('''#include <Carbon/Carbon.h>
+ #include <CoreServices/CoreServices.h>''',
+ name : 'Mac OS X Carbon support')
-if glib_have_carbon
- glib_conf.set('HAVE_CARBON', true)
- osx_ldflags += '-Wl,-framework,Carbon'
- glib_have_os_x_9_or_later = cc.compiles('''#include <AvailabilityMacros.h>
- #if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
- #error Compiling for minimum OS X version before 10.9
- #endif''', name : 'OS X 9 or later')
-endif
+ if glib_have_carbon
+ glib_conf.set('HAVE_CARBON', true)
+ osx_ldflags += '-Wl,-framework,Carbon'
+ glib_have_os_x_9_or_later = objcc.compiles('''#include <AvailabilityMacros.h>
+ #if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
+ #error Compiling for minimum OS X version before 10.9
+ #endif''',
+ name : 'OS X 9 or later')
+ endif
-# Mac OS X Cocoa support
-glib_have_cocoa = cc.compiles('''#include <Cocoa/Cocoa.h>
- #ifdef GNUSTEP_BASE_VERSION
- #error "Detected GNUstep, not Cocoa"
- #endif''',
- name : 'Mac OS X Cocoa support')
+ # Mac OS X Cocoa support
+ glib_have_cocoa = objcc.compiles('''#include <Cocoa/Cocoa.h>
+ #ifdef GNUSTEP_BASE_VERSION
+ #error "Detected GNUstep, not Cocoa"
+ #endif''',
+ name : 'Mac OS X Cocoa support')
-if glib_have_cocoa
- glib_conf.set('HAVE_COCOA', true)
- osx_ldflags += ['-Wl,-framework,Foundation', '-Wl,-framework,AppKit']
-endif
+ if glib_have_cocoa
+ glib_conf.set('HAVE_COCOA', true)
+ osx_ldflags += ['-Wl,-framework,Foundation', '-Wl,-framework,AppKit']
+ endif
-add_project_link_arguments(osx_ldflags, language : 'c')
+ # FIXME: libgio mix C and objC source files and there is no way to reliably
+ # know which language flags it's going to use to link. Add to both languages
+ # for now. See https://github.com/mesonbuild/meson/issues/3585.
+ add_project_link_arguments(osx_ldflags, language : ['objc', 'c'])
+endif
# Check for futex(2)
if cc.links('''#include <linux/futex.h>
@@ -941,9 +977,8 @@ if cc.links('''#include <signal.h>
glib_conf.set('HAVE_SIG_ATOMIC_T', 1)
endif
-# Check if 'long long' works and what format can be used to print it
+# Check if 'long long' works
# jm_AC_TYPE_LONG_LONG
-# Nothing uses HAVE_LONG_LONG_FORMAT and HAVE_INT64_AND_I64
if cc.compiles('''long long ll = 1LL;
int i = 63;
int some_func (void) {
@@ -1363,8 +1398,8 @@ if has_syspoll and has_systypes
#include<sys/types.h>'''
elif has_winsock2
poll_includes = '''
- #define _WIN32_WINNT 0x0600
- #include <winsock2.h>'''
+ #define _WIN32_WINNT @0@
+ #include <winsock2.h>'''.format(glib_conf.get('_WIN32_WINNT'))
else
# FIXME?
error('FIX POLL* defines')
@@ -1492,7 +1527,6 @@ if host_system == 'windows' and not get_option('force_posix_threads')
glibconfig_conf.set('g_threads_impl_def', 'WIN32')
glib_conf.set('THREADS_WIN32', 1)
else
- # FIXME: probably needs more tweaking in meson for things like -D_REENTRANT etc.
thread_dep = dependency('threads')
threads_implementation = 'posix'
pthread_prefix = '''
@@ -1607,7 +1641,7 @@ if get_option('internal_pcre')
pcre = []
use_system_pcre = false
else
- pcre = dependency('libpcre', required : false) # Should check for Unicode support, too. FIXME
+ pcre = dependency('libpcre', version: '>= 8.31', required : false) # Should check for Unicode support, too. FIXME
if not pcre.found()
if cc.get_id() == 'msvc'
# MSVC: Search for the PCRE library by the configuration, which corresponds
@@ -1647,7 +1681,6 @@ endif
libm = cc.find_library('m', required : false)
libffi_dep = dependency('libffi', version : '>= 3.0.0', fallback : ['libffi', 'ffi_dep'])
-zlib_libname = '-lz'
if cc.get_id() != 'msvc'
libz_dep = dependency('zlib', fallback : ['zlib', 'zlib_dep'])
else
@@ -1659,30 +1692,32 @@ else
# of using ZLib's win32/makefile.msc.
if not libz_dep.found()
libz_dep = cc.find_library('zlib1', required : false)
- if libz_dep.found()
- zlib_libname = '-lzlib1'
- else
+ if not libz_dep.found()
libz_dep = cc.find_library('zlib', required : false)
- if libz_dep.found()
- zlib_libname = '-lzlib'
- else
+ if not libz_dep.found()
libz_dep = subproject('zlib').get_variable('zlib_dep')
endif
endif
endif
endif
-# Only used on non-glibc targets
-libintl = cc.find_library('intl', required : false)
-if host_system == 'windows' and not libintl.found()
- # Used only when the gettext library is not available (MSVC, not MinGW)
- libintl = subproject('proxy-libintl').get_variable('intl_dep')
- glib_conf.set('HAVE_DCGETTEXT', 1)
+# First check in libc, fallback to libintl, and as last chance build
+# proxy-libintl subproject.
+# FIXME: glib-gettext.m4 has much more checks to detect broken/uncompatible
+# implementations. This could be extended if issues are found in some platforms.
+if cc.has_function('ngettext')
+ libintl = []
else
- glib_conf.set('HAVE_DCGETTEXT', cc.has_header_symbol('libintl.h', 'dcgettext'))
+ libintl = cc.find_library('intl', required : false)
+ if not libintl.found()
+ libintl = subproject('proxy-libintl').get_variable('intl_dep')
+ endif
endif
+
# We require gettext to always be present
+glib_conf.set('HAVE_DCGETTEXT', 1)
glib_conf.set('HAVE_GETTEXT', 1)
+
glib_conf.set_quoted('GLIB_LOCALE_DIR', join_paths(glib_datadir, 'locale'))
# xgettext is optional (on Windows for instance)
xgettext = find_program('xgettext', required : false)
@@ -1745,7 +1780,29 @@ if host_system != 'windows' and get_option('xattr')
endif
endif
-python = import('python3').find_python()
+# Test if we have strlcpy/strlcat with a compatible implementation:
+# https://bugzilla.gnome.org/show_bug.cgi?id=53933
+if cc_can_run
+ rres = cc.run('''#include <stdlib.h>
+ #include <string.h>
+ int main() {
+ char p[10];
+ (void) strlcpy (p, "hi", 10);
+ if (strlcat (p, "bye", 0) != 3)
+ return 1;
+ return 0;
+ }''',
+ name : 'OpenBSD strlcpy/strlcat')
+ if rres.compiled() and rres.returncode() == 0
+ glib_conf.set('HAVE_STRLCPY', 1)
+ endif
+elif meson.get_cross_property('have_strlcpy', false)
+ glib_conf.set('HAVE_STRLCPY', 1)
+endif
+
+python = import('python').find_installation('python3')
+# used for '#!/usr/bin/env <name>'
+python_name = 'python3'
# Determine which user environment-dependent files that we want to install
have_bash = find_program('bash', required : false).found() # For completion scripts
@@ -1755,12 +1812,15 @@ have_sh = find_program('sh', required : false).found() # For glib-gettextize
# FIXME: defines in config.h that are not actually used anywhere
# (we add them for now to minimise the diff)
glib_conf.set('HAVE_DLFCN_H', 1)
-glib_conf.set('__EXTENSIONS__', 1)
glib_conf.set('STDC_HEADERS', 1)
-# THREADS_NONE
glib_conf.set('SIZEOF___INT64', 8)
-glib_conf.set('GIO_MODULE_DIR', glib_giomodulesdir)
+# FIXME: How to detect Solaris? https://github.com/mesonbuild/meson/issues/1578
+if host_system == 'sunos'
+ glib_conf.set('_XOPEN_SOURCE_EXTENDED', 1)
+ glib_conf.set('_XOPEN_SOURCE', 2)
+ glib_conf.set('__EXTENSIONS__',1)
+endif
# Sadly Meson does not expose this value:
# https://github.com/mesonbuild/meson/pull/3460
@@ -1848,15 +1908,20 @@ if xgettext.found()
endif
subdir('tests')
-# NOTE: We skip glib-zip.in because the filenames it assumes don't match ours
-
# Install glib-gettextize executable, if a UNIX-style shell is found
if have_sh
+ # These should not contain " quotes around the values
+ gettexize_conf = configuration_data()
+ gettexize_conf.set('PACKAGE', 'glib')
+ gettexize_conf.set('VERSION', meson.project_version())
+ gettexize_conf.set('prefix', glib_prefix)
+ gettexize_conf.set('datarootdir', glib_datadir)
+ gettexize_conf.set('datadir', glib_datadir)
configure_file(input : 'glib-gettextize.in',
install : true,
install_dir : 'bin',
output : 'glib-gettextize',
- configuration : glib_conf)
+ configuration : gettexize_conf)
endif
if have_m4
@@ -1872,9 +1937,7 @@ if host_system != 'windows'
install_dir : join_paths(get_option('datadir'), 'glib-2.0', 'valgrind'))
endif
-configure_file(input : 'config.h.meson',
- output : 'config.h',
- configuration : glib_conf)
+configure_file(output : 'config.h', configuration : glib_conf)
if host_system == 'windows'
install_headers([ 'msvc_recommended_pragmas.h' ], subdir : 'glib-2.0')