1# SPDX-License-Identifier: LGPL-2.1 2# 3# Copyright (c) 2023 Daniel Wagner, SUSE LLC 4 5project( 6 'libtracecmd', ['c'], 7 meson_version: '>= 0.50.0', 8 license: 'GPL-2.0', 9 version: '1.5.2', 10 default_options: [ 11 'c_std=gnu99', 12 'buildtype=debug', 13 'default_library=both', 14 'prefix=/usr/local', 15 'warning_level=1']) 16 17cc = meson.get_compiler('c') 18 19prefixdir = get_option('prefix') 20mandir = join_paths(prefixdir, get_option('mandir')) 21htmldir = join_paths(prefixdir, get_option('htmldir')) 22 23libtracecmd_standalone_build = true 24 25library_version = meson.project_version() 26 27conf = configuration_data() 28 29libtraceevent_dep = dependency('libtraceevent', version: '>= 1.5.0', required: true) 30libtracefs_dep = dependency('libtracefs', version: '>= 1.6.0', required: true) 31 32threads_dep = dependency('threads', required: true) 33dl_dep = cc.find_library('dl', required : false) 34 35zlib_dep = dependency('zlib', required: false) 36conf.set('HAVE_ZLIB', zlib_dep.found(), description: 'Is zlib avialable?') 37 38libzstd_dep = dependency('libzstd', version: '>= 1.4.0', required: false) 39conf.set('HAVE_ZSTD', libzstd_dep.found(), description: 'Is libzstd available?') 40 41cunit_dep = dependency('cunit', required : false) 42 43vsock_defined = get_option('vsock') and cc.has_header('linux/vm_sockets.h') 44conf.set('VSOCK', vsock_defined, description: 'Is vsock available?') 45 46perf_defined = cc.has_header('linux/perf_event.h') 47conf.set('PERF', perf_defined, description: 'Is perf available?') 48 49have_ptrace = get_option('ptrace') and cc.compiles( 50 ''' 51 #include <stdio.h> 52 #include <sys/ptrace.h> 53 54 int main (void) 55 { 56 int ret; 57 ret = ptrace(PTRACE_ATTACH, 0, NULL, 0); 58 ptrace(PTRACE_TRACEME, 0, NULL, 0); 59 ptrace(PTRACE_GETSIGINFO, 0, NULL, NULL); 60 ptrace(PTRACE_GETEVENTMSG, 0, NULL, NULL); 61 ptrace(PTRACE_SETOPTIONS, NULL, NULL, 62 PTRACE_O_TRACEFORK | 63 PTRACE_O_TRACEVFORK | 64 PTRACE_O_TRACECLONE | 65 PTRACE_O_TRACEEXIT); 66 ptrace(PTRACE_CONT, NULL, NULL, 0); 67 ptrace(PTRACE_DETACH, 0, NULL, NULL); 68 ptrace(PTRACE_SETOPTIONS, 0, NULL, 69 PTRACE_O_TRACEFORK | 70 PTRACE_O_TRACEVFORK | 71 PTRACE_O_TRACECLONE | 72 PTRACE_O_TRACEEXIT); 73 return ret; 74 } 75 ''', 76 name: 'ptrace') 77if not have_ptrace 78 conf.set10('NO_PTRACE', true, description: 'Is ptrace missing?') 79 conf.set('WARN_NO_PTRACE', true, description: 'Issue no ptrace warning?') 80endif 81 82audit_dep = dependency('audit', required: false) 83if not audit_dep.found() 84 conf.set10('NO_AUDIT', true, description: 'Is audit missing?') 85 conf.set('WARN_NO_AUDIT', true, description: 'Issue no audit warning?') 86endif 87 88add_project_arguments( 89 [ 90 '-D_GNU_SOURCE', 91 '-include', 'trace-cmd/include/private/config.h', 92 ], 93 language : 'c') 94 95libtracecmd_ext_incdir = include_directories( 96 [ 97 '../include', 98 '../include/trace-cmd', 99 '../tracecmd/include' 100 ]) 101 102subdir('trace-cmd/include') 103subdir('trace-cmd/include/private') 104subdir('trace-cmd') 105if libtracecmd_standalone_build 106 subdir('Documentation/libtracecmd') 107 108 custom_target( 109 'docs', 110 output: 'docs', 111 depends: [html, man], 112 command: ['echo']) 113endif 114 115install_headers( 116 '../include/trace-cmd/trace-cmd.h', 117 subdir: 'trace-cmd') 118