meson: Don't add static printf library to executables
[platform/upstream/gstreamer.git] / 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_machine.system() == 'android'
27   message('PTP not supported on Android because of permissions.')
28 elif host_machine.system() == 'windows'
29   message('PTP not supported on Windows, not ported yet.')
30 elif host_machine.system() == 'ios' # FIXME: is it also darwing on iOS ?
31   message('PTP not supported on iOS because of permissions.')
32 elif host_machine.system() == 'darwin'
33   if cc.has_header('MobileCoreServices/MobileCoreServices.h')
34     message('PTP not supported on iOS because of permissions.')
35   else
36     have_ptp = true
37   endif
38 elif ['linux', 'netbsd', 'freebsd', 'openbsd', 'kfreebsd', 'dragonfly', 'solaris'].contains(host_machine.system())
39   message('PTP supported on ' + host_machine.system() + '.')
40   have_ptp = true
41 endif
42
43 if have_ptp
44   cdata.set('HAVE_PTP', 1, description : 'PTP support available')
45
46   if cc.compiles('''#include <sys/ioctl.h>
47                     #include <net/if.h>
48                     int some_func (void) {
49                       struct ifreq ifr;
50                       struct ifconf ifc;
51                       ioctl(0, SIOCGIFCONF, &ifc);
52                       ioctl(0, SIOCGIFFLAGS, &ifr);
53                       ioctl(0, SIOCGIFHWADDR, &ifr);
54                       return ifr.ifr_hwaddr.sa_data[0];
55                     }''',
56                  name : 'SIOCGIFCONF, SIOCGIFFLAGS and SIOCGIFHWADDR available')
57     cdata.set('HAVE_SIOCGIFCONF_SIOCGIFFLAGS_SIOCGIFHWADDR', 1,
58       description : 'SIOCGIFCONF, SIOCGIFFLAGS and SIOCGIFHWADDR is available')
59   endif
60
61   if cc.compiles('''#include <ifaddrs.h>
62                     #include <net/if.h>
63                     #include <net/if_dl.h>
64                     int some_func (void) {
65                       struct ifaddrs *ifaddr;
66                       getifaddrs(&ifaddr);
67                       return (ifaddr->ifa_flags & IFF_LOOPBACK) && ifaddr->ifa_addr->sa_family != AF_LINK;
68                     }''', name : 'getifaddrs() and AF_LINK available')
69     cdata.set('HAVE_GETIFADDRS_AF_LINK', 1,
70       description : 'getifaddrs() and AF_LINK is available')
71   endif
72
73   gst_ptp_have_cap = false
74   cap_dep = []
75   if cc.has_header('sys/capability.h')
76     cap_dep = cc.find_library('cap', required : false)
77     if cap_dep.found() and cc.has_function('cap_init', dependencies : cap_dep)
78       gst_ptp_have_cap = true
79     endif
80   endif
81
82   setcap = find_program('setcap', '/usr/sbin/setcap', '/sbin/setcap', required : false)
83
84   # user/group to change to in gst-ptp-helper
85   ptp_helper_setuid_user = get_option('ptp-helper-setuid-user')
86   if ptp_helper_setuid_user != ''
87     cdata.set_quoted('HAVE_PTP_HELPER_SETUID_USER', ptp_helper_setuid_user,
88       description : 'PTP helper setuid user')
89   endif
90   ptp_helper_setuid_group = get_option('ptp-helper-setuid-group')
91   if ptp_helper_setuid_group != ''
92     cdata.set_quoted('HAVE_PTP_HELPER_SETUID_GROUP', ptp_helper_setuid_group,
93       description : 'PTP helper setuid group')
94   endif
95
96   # how to install gst-ptp-helper
97   with_ptp_helper_permissions = get_option('ptp-helper-permissions')
98   if with_ptp_helper_permissions == 'auto'
99     if gst_ptp_have_cap and setcap.found()
100       with_ptp_helper_permissions = 'capabilities'
101     else
102       with_ptp_helper_permissions = 'setuid-root'
103     endif
104   endif
105   message('How to install gst-ptp-helper: ' + with_ptp_helper_permissions)
106
107   if with_ptp_helper_permissions == 'none'
108     # nothing to do
109   elif with_ptp_helper_permissions == 'setuid-root'
110     cdata.set('HAVE_PTP_HELPER_SETUID', 1,
111         description : 'Use setuid-root for permissions in PTP helper')
112   elif with_ptp_helper_permissions == 'capabilities'
113     if not setcap.found()
114       error('capabilities-based ptp-helper-permissions requested, but could not find setcap tool.')
115     endif
116     cdata.set('HAVE_PTP_HELPER_CAPABILITIES', 1,
117         description : 'Use capabilities for permissions in PTP helper')
118   else
119     error('Unexpected ptp helper permissions value: ' + with_ptp_helper_permissions)
120   endif
121
122   executable('gst-ptp-helper', 'gst-ptp-helper.c',
123     c_args : gst_c_args,
124     include_directories : [configinc, libsinc],
125     dependencies : [gio_dep, gobject_dep, glib_dep, mathlib, gst_dep, cap_dep],
126     install_dir : helpers_install_dir,
127     install : true)
128
129   meson.add_install_script('ptp_helper_post_install.sh',
130       helpers_install_dir, with_ptp_helper_permissions,
131       setcap.found() ? setcap.path() : '')
132 endif