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