[babl] Meson build: Tidy up code and improve readability



commit 660ccf2696925655c53a9c79d6758912f124ffd6
Author: John Marshall <jtm home gmail com>
Date:   Sat May 19 11:48:26 2018 +0100

    Meson build: Tidy up code and improve readability

 meson.build       |   58 ++++++++++++++++++++++++++++++++++++++++------------
 meson_options.txt |    2 +-
 2 files changed, 45 insertions(+), 15 deletions(-)
---
diff --git a/meson.build b/meson.build
index d53ae46..afd3907 100644
--- a/meson.build
+++ b/meson.build
@@ -223,17 +223,43 @@ if cc.has_argument('-mmmx') and get_option('enable-mmx')
   endif
 endif
 
-have_tls_run = cc.run('int main() { static __thread char buf[1024]; return 0; }')
-conf.set('HAVE_TLS', ( have_tls_run.compiled() and have_tls_run.returncode() == 0 ))
+################################################################################
+# Check environment
 
-have_dlfcn_h = cc.has_header('dlfcn.h')
-have_dl_h    = cc.has_header('dl.h')
-if not (have_dlfcn_h or have_dl_h or platform_win32)
-  # error('Header dlfcn.h or dl.h not provided. Please provide one of them.')
-endif
+# Check headers
+check_headers = [
+  ['HAVE_DLFCN_H',      'dlfcn.h'],
+  ['HAVE_DL_H',         'dl.h'],
+]
+foreach header: check_headers
+  if cc.has_header(header[1])
+    conf.set(header[0], 1, description: 
+      'Define to 1 if the <@0@> header is available'.format(header[1]))
+  endif
+endforeach
+
+
+# Check functions
+# general
+check_functions = [
+  ['HAVE_GETTIMEOFDAY', 'gettimeofday'],
+  ['HAVE_SRANDOM',      'srandom'     ],
+]
+foreach func: check_functions
+  if cc.has_function(func[1])
+    conf.set(func[0], 1, description: 
+      'Define to 1 if the @0@() function is available'.format(func[1]))
+  endif
+endforeach
+
+
+# Check for uncommon features
 
-conf.set('HAVE_DLFCN_H', have_dlfcn_h)
-conf.set('HAVE_DL_H',    have_dl_h)
+# babl_fish_reference(), create_name() would like this
+if cc.compiles('int main() { static __thread char buf[1024]; }')
+  conf.set('HAVE_TLS', 1, description:
+    'Define to 1 if compiler supports __thread')
+endif
 
 
 ################################################################################
@@ -259,7 +285,16 @@ w3m_bin = find_program('w3m' + native_bin_ext, required: false,
   native: true)
 
 
+################################################################################
+# Configuration files
+
+# config.h
+configure_file(
+  output: 'config.h',
+  configuration: conf
+)
 
+# pkg-config file
 pkgconfig.generate(filebase: 'babl',
   name: 'babl',
   description: 'Dynamic, any to any, pixel format conversion library',
@@ -276,11 +311,6 @@ pkgconfig.generate(filebase: 'babl',
   ],
 )
 
-configure_file(
-  output: 'config.h',
-  configuration: conf
-)
-
 
 ################################################################################
 # Subdirs
diff --git a/meson_options.txt b/meson_options.txt
index febd306..b2dcc54 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -4,4 +4,4 @@ option('enable-sse2',   type: 'boolean', value: true, description: 'enable SSE2
 option('enable-sse3',   type: 'boolean', value: true, description: 'enable SSE3 support')
 option('enable-sse4_1', type: 'boolean', value: true, description: 'enable SSE4.1 support')
 option('enable-f16c',   type: 'boolean', value: true, description: 'enable hardware half-float support')
-option('with-docs',     type: 'boolean', value: true)
+option('with-docs',     type: 'boolean', value: true, description: 'build website')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]