1project('pkgconf', 'c', 2 version : '2.5.1', 3 license : 'ISC', 4 default_options : ['c_std=c99'], 5 meson_version: '>=0.52', 6) 7 8cc = meson.get_compiler('c') 9 10add_project_arguments( 11 '-D_BSD_SOURCE', 12 '-D_DEFAULT_SOURCE', 13 '-D_POSIX_C_SOURCE=200809L', 14 cc.get_supported_arguments( 15 '-Wimplicit-function-declaration', 16 '-Wmisleading-indentation', 17 ), 18 language : 'c', 19) 20 21cdata = configuration_data() 22 23check_functions = [ 24 ['strlcat', 'string.h'], 25 ['strlcpy', 'string.h'], 26 ['strndup', 'string.h'], 27 ['strdup', 'string.h'], 28 ['strncasecmp', 'strings.h'], 29 ['strcasecmp', 'strings.h'], 30 ['reallocarray', 'stdlib.h'], 31 ['pledge', 'unistd.h'], 32 ['unveil', 'unistd.h'], 33] 34 35foreach f : check_functions 36 name = f[0].to_upper().underscorify() 37 if cc.has_function(f[0], prefix : '#define _BSD_SOURCE\n#define _DEFAULT_SOURCE\n#define _POSIX_C_SOURCE 200809L\n#include <@0@>'.format(f[1])) and cc.has_header_symbol(f[1], f[0], prefix : '#define _BSD_SOURCE\n#define _DEFAULT_SOURCE\n#define _POSIX_C_SOURCE 200809L') 38 cdata.set('HAVE_@0@'.format(name), 1) 39 cdata.set('HAVE_DECL_@0@'.format(name), 1) 40 else 41 cdata.set('HAVE_DECL_@0@'.format(name), 0) 42 endif 43endforeach 44 45default_path = [] 46foreach f : ['libdir', 'datadir'] 47 default_path += [join_paths(get_option('prefix'), get_option(f), 'pkgconfig')] 48endforeach 49 50personality_path = [] 51foreach f : ['libdir', 'datadir'] 52 personality_path += [join_paths(get_option('prefix'), get_option(f), 'pkgconfig', 'personality.d')] 53endforeach 54 55SYSTEM_LIBDIR = get_option('with-system-libdir') 56if SYSTEM_LIBDIR != '' 57 cdata.set_quoted('SYSTEM_LIBDIR', SYSTEM_LIBDIR) 58else 59 cdata.set_quoted('SYSTEM_LIBDIR', join_paths(get_option('prefix'), get_option('libdir'))) 60endif 61SYSTEM_INCLUDEDIR = get_option('with-system-includedir') 62if SYSTEM_INCLUDEDIR != '' 63 cdata.set_quoted('SYSTEM_INCLUDEDIR', SYSTEM_INCLUDEDIR) 64else 65 cdata.set_quoted('SYSTEM_INCLUDEDIR', join_paths(get_option('prefix'), get_option('includedir'))) 66endif 67cdata.set_quoted('PKG_DEFAULT_PATH', ':'.join(default_path)) 68cdata.set_quoted('PERSONALITY_PATH', ':'.join(personality_path)) 69cdata.set_quoted('PACKAGE_NAME', meson.project_name()) 70cdata.set_quoted('PACKAGE_VERSION', meson.project_version()) 71cdata.set_quoted('PACKAGE_BUGREPORT', 'https://todo.sr.ht/~kaniini/pkgconf') 72cdata.set('abs_top_srcdir', meson.current_source_dir()) 73cdata.set('abs_top_builddir', meson.current_build_dir()) 74 75 76subdir('libpkgconf') 77 78libtype = get_option('default_library') 79if libtype == 'static' 80 build_static = '-DPKGCONFIG_IS_STATIC' 81else 82 build_static = '-DPKGCONFIG_IS_NOT_STATIC' 83endif 84 85libpkgconf = library('pkgconf', 86 'libpkgconf/argvsplit.c', 87 'libpkgconf/audit.c', 88 'libpkgconf/buffer.c', 89 'libpkgconf/bsdstubs.c', 90 'libpkgconf/cache.c', 91 'libpkgconf/client.c', 92 'libpkgconf/dependency.c', 93 'libpkgconf/fileio.c', 94 'libpkgconf/fragment.c', 95 'libpkgconf/parser.c', 96 'libpkgconf/path.c', 97 'libpkgconf/personality.c', 98 'libpkgconf/pkg.c', 99 'libpkgconf/queue.c', 100 'libpkgconf/tuple.c', 101 c_args: ['-DLIBPKGCONF_EXPORT', build_static], 102 install : true, 103 version : '7.0.0', 104 soversion : '7', 105) 106 107# For other projects using libpkgconfig as a subproject 108dep_libpkgconf = declare_dependency( 109 link_with : libpkgconf, 110 include_directories : include_directories('.'), 111) 112 113# If we have a new enough meson override the dependency so that only 114# `dependency('libpkgconf')` is required from the consumer 115if meson.version().version_compare('>= 0.54.0') 116 meson.override_dependency('libpkgconf', dep_libpkgconf) 117endif 118 119pkg = import('pkgconfig') 120pkg.generate(libpkgconf, 121 name : 'libpkgconf', 122 description : 'a library for accessing and manipulating development framework configuration', 123 url: 'http://github.com/pkgconf/pkgconf', 124 filebase : 'libpkgconf', 125 subdirs: ['pkgconf'], 126 extra_cflags : build_static 127) 128 129cli_include = include_directories('cli') 130 131pkgconf_exe = executable('pkgconf', 132 'cli/main.c', 133 'cli/getopt_long.c', 134 'cli/renderer-msvc.c', 135 link_with : libpkgconf, 136 c_args : build_static, 137 include_directories : cli_include, 138 install : true) 139 140bomtool_exe = executable('bomtool', 141 'cli/bomtool/main.c', 142 'cli/getopt_long.c', 143 link_with : libpkgconf, 144 c_args : build_static, 145 include_directories : cli_include, 146 install : true) 147 148with_tests = get_option('tests') 149kyua_exe = find_program('kyua', required : with_tests, disabler : true, native : true) 150atf_sh_exe = find_program('atf-sh', required : with_tests, disabler : true, native : true) 151kyuafile = configure_file(input : 'Kyuafile.in', output : 'Kyuafile', configuration : cdata) 152test('kyua', kyua_exe, args : ['--config=none', 'test', '--kyuafile', kyuafile, '--build-root', meson.current_build_dir()]) 153subdir('tests') 154 155install_man('man/bomtool.1') 156install_man('man/pkgconf.1') 157install_man('man/pkg.m4.7') 158install_man('man/pc.5') 159install_man('man/pkgconf-personality.5') 160install_data('pkg.m4', install_dir: 'share/aclocal') 161install_data('AUTHORS', install_dir: 'share/doc/pkgconf') 162install_data('README.md', install_dir: 'share/doc/pkgconf') 163 164if host_machine.system() == 'windows' 165 conf_data = configuration_data() 166 conf_data.set('VERSION', meson.project_version()) 167 conf_data.set('EXE', pkgconf_exe.full_path()) 168 conf_data.set('DLL', libpkgconf.full_path()) 169 if host_machine.cpu() != 'x86_64' 170 wixl_arch = 'x86' 171 else 172 wixl_arch = 'x64' 173 endif 174 conf_data.set('WIXL_ARCH', wixl_arch) 175 176 python = find_program('python3') 177 wixl = find_program('wixl', required: false, version: '>= 0.105') 178 msi_filename = 'pkgconf-@0@-@1@.msi'.format(wixl_arch, meson.project_version()) 179 180 wxsfile = configure_file(input: 'pkgconf.wxs.in', output: 'pkgconf.wxs', configuration: conf_data) 181 182 if wixl.found() 183 licensefile = custom_target( 184 'License.rtf', 185 input: 'COPYING', 186 output: 'License.rtf', 187 command: [python, files('txt2rtf.py'), '@INPUT@', '@OUTPUT@'], 188 ) 189 190 msi = custom_target( 191 msi_filename, 192 input: [wxsfile, licensefile, pkgconf_exe], 193 output: msi_filename, 194 command: [wixl, '--arch', wixl_arch, '--ext', 'ui', '-o', msi_filename, wxsfile], 195 ) 196 197 alias_target('msi', msi) 198 endif 199endif 200