ref: d6e9cb0603817437aea15849228255661e19b2b6
parent: ce0f141e2da6bcb23ad999a6cac1ffe6abb27684
author: Steve Lhomme <slhomme@videolan.org>
date: Fri Sep 28 10:30:57 EDT 2018
build: use local getopt for anything system where it's missing Do not force include the compat folder as it may contain headers that do exist for the compiler. Include the compat headers individually when they are needed and use an explicit path to compat/
--- a/include/compat/getopt.h
+++ b/include/compat/getopt.h
@@ -50,8 +50,6 @@
* specific block, only when *not* __UNISTD_H_SOURCED__, in which
* to declare the extended API.
*/
-#endif /* !defined(__GETOPT_H__) */
-
#if !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__)
#define __GETOPT_LONG_H__
@@ -93,3 +91,5 @@
#endif
#endif /* !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) */
+
+#endif /* !defined(__GETOPT_H__) */
--- a/meson.build
+++ b/meson.build
@@ -44,7 +44,9 @@
thread_dependency = declare_dependency(sources: ['src/win32/thread.c'])
endif
-dav1d_inc_dirs = include_directories(['include', 'include/dav1d'])
+if cc.has_function('getopt_long', prefix : '#include <getopt.h>')
+ cdata.set('HAVE_GETOPT_H',1)
+endif
#
# Option handling
@@ -170,6 +172,11 @@
#
# Generate config headers
#
+if cdata.has('HAVE_GETOPT_H')
+ dav1d_inc_dirs = include_directories(['include', 'include/dav1d'])
+else
+ dav1d_inc_dirs = include_directories(['include', 'include/dav1d', 'include/compat'])
+endif
config_h_target = configure_file(output: 'config.h', configuration: cdata)
@@ -331,7 +338,7 @@
'tools/output/yuv.c'
)
-if cc.get_id() == 'msvc'
+if not cdata.has('HAVE_GETOPT_H')
dav1d_sources += files('tools/compat/getopt.c')
endif