b34423f9c28d783470197912a83afa4026df85a1
[platform/upstream/gstreamer.git] / subprojects / gstreamer / libs / gst / helpers / meson.build
1 executable('gst-plugin-scanner',
2   'gst-plugin-scanner.c',
3   c_args : gst_c_args,
4   include_directories : [configinc],
5   dependencies : [gobject_dep, gmodule_dep, glib_dep, mathlib, gst_dep],
6   install_dir : helpers_install_dir,
7   install: true,
8 )
9
10 # Used in test env setup to make tests find plugin scanner in build tree
11 gst_scanner_dir = meson.current_build_dir()
12
13 if bashcomp_found
14   executable('gst-completion-helper',
15     'gst-completion-helper.c',
16     c_args : gst_c_args,
17     include_directories : [configinc],
18     dependencies : [gobject_dep, glib_dep, gst_dep],
19     install_dir : helpers_install_dir,
20     install: true,
21   )
22 endif
23
24 # Check PTP support
25 have_ptp = false
26 if host_system == 'android'
27   message('PTP not supported on Android because of permissions.')
28 elif host_system == 'windows'
29   message('PTP not supported on Windows, not ported yet.')
30 elif host_system == 'ios'
31   message('PTP not supported on iOS because of permissions.')
32 elif ['linux', 'darwin', 'netbsd', 'freebsd', 'openbsd', 'kfreebsd', 'dragonfly', 'sunos', 'gnu', 'gnu/kfreebsd'].contains(host_system)
33   message('PTP supported on ' + host_system + '.')
34   have_ptp = true
35 else
36   message('PTP not supported on ' + host_system + ', not ported yet.')
37 endif
38
39 if have_ptp
40   cdata.set('HAVE_PTP', 1, description : 'PTP support available')
41
42   if cc.compiles('''#include <sys/ioctl.h>
43                     #include <net/if.h>
44                     int some_func (void) {
45                       struct ifreq ifr;
46                       struct ifconf ifc;
47                       ioctl(0, SIOCGIFCONF, &ifc);
48                       ioctl(0, SIOCGIFFLAGS, &ifr);
49                       ioctl(0, SIOCGIFHWADDR, &ifr);
50                       return ifr.ifr_hwaddr.sa_data[0];
51                     }''',
52                  name : 'SIOCGIFCONF, SIOCGIFFLAGS and SIOCGIFHWADDR available')
53     cdata.set('HAVE_SIOCGIFCONF_SIOCGIFFLAGS_SIOCGIFHWADDR', 1,
54       description : 'SIOCGIFCONF, SIOCGIFFLAGS and SIOCGIFHWADDR is available')
55   endif
56
57   if cc.compiles('''#include <ifaddrs.h>
58                     #include <net/if.h>
59                     #include <net/if_dl.h>
60                     int some_func (void) {
61                       struct ifaddrs *ifaddr;
62                       getifaddrs(&ifaddr);
63                       return (ifaddr->ifa_flags & IFF_LOOPBACK) && ifaddr->ifa_addr->sa_family != AF_LINK;
64                     }''', name : 'getifaddrs() and AF_LINK available')
65     cdata.set('HAVE_GETIFADDRS_AF_LINK', 1,
66       description : 'getifaddrs() and AF_LINK is available')
67   endif
68
69   setcap_prog = find_program('setcap', '/usr/sbin/setcap', '/sbin/setcap', required : false)
70   cap_dep = dependency('libcap', required: false)
71
72   # user/group to change to in gst-ptp-helper
73   ptp_helper_setuid_user = get_option('ptp-helper-setuid-user')
74   if ptp_helper_setuid_user != ''
75     cdata.set_quoted('HAVE_PTP_HELPER_SETUID_USER', ptp_helper_setuid_user,
76       description : 'PTP helper setuid user')
77   endif
78   ptp_helper_setuid_group = get_option('ptp-helper-setuid-group')
79   if ptp_helper_setuid_group != ''
80     cdata.set_quoted('HAVE_PTP_HELPER_SETUID_GROUP', ptp_helper_setuid_group,
81       description : 'PTP helper setuid group')
82   endif
83
84   # how to install gst-ptp-helper
85   with_ptp_helper_permissions = get_option('ptp-helper-permissions')
86   if with_ptp_helper_permissions == 'auto'
87     if setcap_prog.found() and cap_dep.found()
88       with_ptp_helper_permissions = 'capabilities'
89     else
90       with_ptp_helper_permissions = 'setuid-root'
91     endif
92   endif
93   message('How to install gst-ptp-helper: ' + with_ptp_helper_permissions)
94
95   if with_ptp_helper_permissions == 'none'
96     # nothing to do
97   elif with_ptp_helper_permissions == 'setuid-root'
98     cdata.set('HAVE_PTP_HELPER_SETUID', 1,
99         description : 'Use setuid-root for permissions in PTP helper')
100   elif with_ptp_helper_permissions == 'capabilities'
101     if not setcap_prog.found()
102       error('capabilities-based ptp-helper-permissions requested, but could not find setcap tool.')
103     elif not cap_dep.found()
104       error('capabilities-based ptp-helper-permissions requested, but could not find libcap.')
105     endif
106     cdata.set('HAVE_PTP_HELPER_CAPABILITIES', 1,
107         description : 'Use capabilities for permissions in PTP helper')
108   else
109     error('Unexpected ptp helper permissions value: ' + with_ptp_helper_permissions)
110   endif
111
112   executable('gst-ptp-helper', 'gst-ptp-helper.c',
113     c_args : gst_c_args,
114     include_directories : [configinc, libsinc],
115     dependencies : [gio_dep, gobject_dep, glib_dep, mathlib, gst_dep, cap_dep],
116     install_dir : helpers_install_dir,
117     install : true)
118
119   meson.add_install_script('ptp_helper_post_install.sh',
120       helpers_install_dir, with_ptp_helper_permissions,
121       setcap_prog.found() ? setcap_prog.path() : '')
122 endif
123
124 install_data(['gst_gdb.py', 'glib_gobject_helper.py'],
125   install_dir : join_paths(get_option('datadir'), 'gstreamer-@0@'.format(apiversion), 'gdb'))
126
127 gdbconf = configuration_data()
128 gdbconf.set('GST_API_VERSION', apiversion)
129 gdbconf.set('DATADIR', '@0@/@1@'.format(get_option('prefix'), get_option('datadir')))
130
131 if host_system != 'windows'
132   # XXX: We add a leading './' because prefix is an absolute path and we
133   # need it to be a relative path so that join_paths appends it to the end.
134   gdb_install_dir = join_paths(get_option('datadir'), 'gdb', 'auto-load', './' + get_option('prefix'), get_option('libdir'))
135 else
136   # FIXME: Cannot install on Windows because the path will contain a drive
137   # letter and colons are not allowed in paths.
138   gdb_install_dir = disabler()
139 endif
140 configure_file(input : 'libgstreamer-gdb.py.in',
141   output : 'libgstreamer-@0@.so.@1@-gdb.py'.format(apiversion, libversion),
142   install_dir : gdb_install_dir,
143   configuration : gdbconf)