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