aad97a83878956f9ff57b32ee3e334a2799d9bc0
[platform/upstream/gstreamer.git] / meson.build
1 project('gst-plugins-base', 'c', 'cpp',
2   version : '1.9.90',
3   meson_version : '>= 0.35.0',
4   default_options : [ 'warning_level=1',
5                       'c_std=gnu99',
6                       'buildtype=debugoptimized' ])
7
8 gst_version = meson.project_version()
9 version_arr = gst_version.split('.')
10 gst_version_major = version_arr[0]
11 gst_version_minor = version_arr[1]
12 gst_version_micro = version_arr[2]
13 if version_arr.length() == 4
14   gst_version_nano = version_arr[3]
15 else
16   gst_version_nano = 0
17 endif
18
19 glib_req = '>= 2.40.0'
20 orc_req = '>= 0.4.24'
21 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
22
23 api_version = '1.0'
24 soversion = 0
25 # maintaining compatibility with the previous libtool versioning
26 # current = minor * 100 + micro
27 # FIXME: should be able to convert string to int somehow so we can just do maths
28 libversion = '@0@.@1@.0'.format(soversion, gst_version_minor.to_int() * 100 + gst_version_micro.to_int())
29
30 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
31
32 cc = meson.get_compiler('c')
33
34 if cc.get_id() == 'msvc'
35   # Ignore several spurious warnings for things gstreamer does very commonly
36   # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
37   # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
38   # NOTE: Only add warnings here if you are sure they're spurious
39   add_global_arguments('/wd4018', '/wd4244', '/wd4996', language : 'c')
40   # Disable SAFESEH with MSVC for plugins and libs that use external deps that
41   # are built with MinGW
42   noseh_link_args = ['/SAFESEH:NO']
43 else
44   noseh_link_args = []
45 endif
46
47 core_conf = configuration_data()
48 check_headers = [
49   ['HAVE_DLFCN_H', 'dlfcn.h'],
50   ['HAVE_EMMINTRIN_H', 'emmintrin.h'],
51   ['HAVE_INTTYPES_H', 'inttypes.h'],
52   ['HAVE_MEMORY_H', 'memory.h'],
53   ['HAVE_PROCESS_H', 'process.h'],
54   ['HAVE_SMMINTRIN_H', 'smmintrin.h'],
55   ['HAVE_STDINT_H', 'stdint.h'],
56   ['HAVE_STDLIB_H', 'stdlib.h'],
57   ['HAVE_STRINGS_H', 'strings.h'],
58   ['HAVE_STRING_H', 'string.h'],
59   ['HAVE_SYS_SOCKET_H', 'sys/socket.h'],
60   ['HAVE_SYS_STAT_H', 'sys/stat.h'],
61   ['HAVE_SYS_TYPES_H', 'sys/types.h'],
62   ['HAVE_SYS_WAIT_H', 'sys/wait.h'],
63   ['HAVE_UNISTD_H', 'unistd.h'],
64   ['HAVE_WINSOCK2_H', 'winsock2.h'],
65   ['HAVE_XMMINTRIN_H', 'xmmintrin.h'],
66 ]
67 foreach h : check_headers
68   if cc.has_header(h.get(1))
69     core_conf.set(h.get(0), 1)
70   endif
71 endforeach
72
73 check_functions = [
74   ['HAVE_DCGETTEXT', 'dcgettext'],
75   ['HAVE_GMTIME_R', 'gmtime_r'],
76   ['HAVE_LRINTF', 'lrintf'],
77   ['HAVE_MMAP', 'mmap'],
78 ]
79
80 foreach f : check_functions
81   if cc.has_function(f.get(1))
82     core_conf.set(f.get(0), 1)
83   endif
84 endforeach
85
86 core_conf.set('SIZEOF_CHAR', cc.sizeof('char'))
87 core_conf.set('SIZEOF_INT', cc.sizeof('int'))
88 core_conf.set('SIZEOF_LONG', cc.sizeof('long'))
89 core_conf.set('SIZEOF_SHORT', cc.sizeof('short'))
90 core_conf.set('SIZEOF_VOIDP', cc.sizeof('void*'))
91
92 core_conf.set('GETTEXT_PACKAGE', '"gst-plugins-base-1.0"')
93 core_conf.set('PACKAGE', '"gst-plugins-base"')
94 core_conf.set('VERSION', '"@0@"'.format(gst_version))
95 core_conf.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
96 core_conf.set('GST_PACKAGE_NAME', '"GStreamer Base Plug-ins"')
97 core_conf.set('GST_PACKAGE_ORIGIN', '"Unknown package origin"')
98 core_conf.set('GST_API_VERSION', '"@0@"'.format(api_version))
99 core_conf.set('GST_INSTALL_PLUGINS_HELPER', '"/FIXME"')
100 core_conf.set('GST_DATADIR', '"/FIXME"')
101 core_conf.set('GST_LICENSE', '"LGPL"')
102 # FIXME: These should be configure options
103 core_conf.set('DEFAULT_VIDEOSINK', '"autovideosink"')
104 core_conf.set('DEFAULT_AUDIOSINK', '"autoaudiosink"')
105
106 # Set whether the audioresampling method should be detected at runtime
107 core_conf.set('AUDIORESAMPLE_FORMAT_' + get_option('audioresample_format').to_upper(), true)
108
109 gst_plugins_base_args = ['-DHAVE_CONFIG_H']
110 if get_option('default_library') == 'static'
111   gst_plugins_base_args += ['-DGST_STATIC_COMPILATION']
112 endif
113
114 libm = cc.find_library('m', required : false)
115 # X11 checks are for sys/ and tests/
116 x11_dep = dependency('x11', required : false)
117 # GLib checks are for the entire project
118 giounix_dep = dependency('gio-unix-2.0', version : glib_req, required : false)
119 # Almost everything that uses glib also uses gobject
120 glib_deps = [dependency('glib-2.0', version : glib_req),
121              dependency('gobject-2.0', version : glib_req)]
122 gio_dep = dependency('gio-2.0', version : glib_req)
123
124 core_conf.set('HAVE_X', x11_dep.found())
125 core_conf.set('HAVE_GIO_UNIX_2_0', giounix_dep.found())
126
127 runcmd = run_command('pkg-config', '--variable=giomoduledir', 'gio-2.0')
128 if runcmd.returncode() == 0
129   core_conf.set('GIO_MODULE_DIR', '"@0@"'.format(runcmd.stdout().strip()))
130 endif
131 runcmd = run_command('pkg-config', '--variable=libdir', 'gio-2.0')
132 if runcmd.returncode() == 0
133   core_conf.set('GIO_LIBDIR', '"@0@"'.format(runcmd.stdout().strip()))
134 endif
135 runcmd = run_command('pkg-config', '--variable=prefix', 'gio-2.0')
136 if runcmd.returncode() == 0
137   core_conf.set('GIO_PREFIX', '"@0@"'.format(runcmd.stdout().strip()))
138 endif
139
140 configinc = include_directories('.')
141 libsinc = include_directories('gst-libs')
142
143 # To use the subproject make subprojects directory
144 # and put gstreamer meson git there (symlinking is fine)
145 gst_dep = dependency('gstreamer-1.0', version : gst_req,
146   fallback : ['gstreamer', 'gst_dep'])
147 gst_base_dep = dependency('gstreamer-base-1.0', version : gst_req,
148   fallback : ['gstreamer', 'gst_base_dep'])
149 gst_net_dep = dependency('gstreamer-net-1.0', version : gst_req,
150   fallback : ['gstreamer', 'gst_net_dep'])
151 gst_check_dep = dependency('gstreamer-check-1.0', version : gst_req,
152   fallback : ['gstreamer', 'gst_check_dep'])
153 gst_controller_dep = dependency('gstreamer-controller-1.0', version : gst_req,
154   fallback : ['gstreamer', 'gst_controller_dep'])
155
156 vs_module_defs_dir = meson.current_source_dir() + '/win32/common/'
157
158 # Used by the *_mkenum.py helper scripts
159 glib_mkenums = find_program('glib-mkenums')
160
161 have_orcc = false
162 orcc_args = []
163 if get_option('use_orc') != 'no'
164   need_orc = get_option('use_orc') == 'yes'
165   # Used by various libraries/elements that use Orc code
166   orc_dep = dependency('orc-0.4', version : orc_req, required : need_orc)
167   orcc = find_program('orcc', required : need_orc)
168   if orc_dep.found() and orcc.found()
169     have_orcc = true
170     orcc_args = [orcc, '--include', 'glib.h']
171     core_conf.set('HAVE_ORC', 1)
172   else
173     message('Orc Compiler not found, will use backup C code')
174     core_conf.set('DISABLE_ORC', 1)
175   endif
176 else
177   core_conf.set('DISABLE_ORC', 1)
178 endif
179
180 # Used to build SSE* things in audio-resampler
181 sse_args = '-msse'
182 sse2_args = '-msse2'
183 sse41_args = '-msse4.1'
184
185 have_sse = cc.has_argument(sse_args)
186 have_sse2 = cc.has_argument(sse2_args)
187 have_sse41 = cc.has_argument(sse41_args)
188
189 # FIXME: Meson should have a way for portably adding -fPIC when needed for use
190 # with static libraries that are linked into shared libraries. Or, it should
191 # add it by default with an option to turn it off if needed.
192 pic_args = ['-fPIC']
193 if host_machine.system() == 'windows'
194   pic_args = []
195 endif
196
197 subdir('gst-libs')
198 subdir('gst')
199 subdir('ext')
200 subdir('sys')
201 subdir('tools')
202 subdir('tests')
203 subdir('pkgconfig')
204
205 # Use core_conf after all subdirs have set values
206 configure_file(input : 'config.h.meson',
207   output : 'config.h',
208   configuration : core_conf)
209
210 python3 = find_program('python3')
211 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')