[gimp/meson] Refactoring. Add missing cflags.



commit 7171be0fd045bd1bb60ef7c6ab9f4d8a4f54da11
Author: Félix Piédallu <felix piedallu me>
Date:   Wed Feb 14 14:24:14 2018 +0100

    Refactoring. Add missing cflags.

 desktop/meson.build         |   14 +-
 meson.build                 |  667 +++++++++++++++++++++++++++++++------------
 meson_options.txt           |    5 +-
 modules/meson.build         |    6 +-
 plug-ins/common/meson.build |   25 +-
 5 files changed, 507 insertions(+), 210 deletions(-)
---
diff --git a/desktop/meson.build b/desktop/meson.build
index 34df7a0..b973cfa 100644
--- a/desktop/meson.build
+++ b/desktop/meson.build
@@ -91,9 +91,11 @@ custom_target('validate-desktop',
   build_by_default: false,
 )
 
-test('test_appdata',
-  find_program('test-appdata.sh'),
-  env: [
-    'GIMP_TESTING_ABS_TOP_BUILDDIR=' + meson.build_root(),
-  ],
-)
+if test_appdata
+  test('test_appdata',
+    find_program('test-appdata.sh'),
+    env: [
+      'GIMP_TESTING_ABS_TOP_BUILDDIR=' + meson.build_root(),
+    ],
+  )
+endif
diff --git a/meson.build b/meson.build
index 7629d15..7d02297 100644
--- a/meson.build
+++ b/meson.build
@@ -51,7 +51,10 @@ gimp_version  = meson.project_version()
 
 gimp_command  = 'gimp-' + app_version
 gimp_api_name = 'gimp-' + api_version
-package_string= prettyname + ' ' + gimp_version
+package_string  = prettyname + ' ' + gimp_version
+
+gettext_package = 'gimp20'
+conf.set_quoted('GETTEXT_PACKAGE', gettext_package)
 
 
 # TODO cleanup all this versions mess
@@ -81,37 +84,59 @@ versionconfig.set('GIMP_API_VERSION',   api_version)
 # Host system detection
 
 host_cpu = host_machine.cpu().to_lower()
-message('Architecture: ' + host_cpu)
-
-if   host_cpu.startswith('i') and host_cpu.endswith('86')
-  have_x86 = true
-  conf.set10('ARCH_X86',    true)
-elif host_cpu == 'x86_64'
-  have_x86 = true
-  conf.set10('ARCH_X86',    true)
-  conf.set10('ARCH_X86_64', true)
-elif host_cpu == 'ppc' or host_cpu == 'powerpc'
-  have_ppc = true
-  conf.set10('ARCH_PPC',    true)
-elif host_cpu == 'ppc64' or host_cpu == 'powerpc64'
-  have_ppc = true
-  conf.set10('ARCH_PPC',    true)
-  conf.set10('ARCH_PPC64',  true)
-else
+
+arch_x86_64 = (host_cpu == 'x86_64')
+arch_x86    = (
+  (host_cpu.startswith('i') and host_cpu.endswith('86'))
+  or arch_x86_64
+)
+arch_ppc64  = (host_cpu == 'ppc64' or host_cpu == 'powerpc64')
+arch_ppc    = (
+  (host_cpu == 'ppc'   or host_cpu == 'powerpc')
+  or arch_ppc64
+)
+
+if not (arch_x86 or arch_ppc)
   error('Unknown host architecture')
 endif
 
+conf.set10('ARCH_X86',    arch_x86)
+conf.set10('ARCH_X86_64', arch_x86_64)
+conf.set10('ARCH_PPC',    arch_ppc)
+conf.set10('ARCH_PPC64',  arch_ppc64)
 
 host_os = host_machine.system().to_lower()
 message('Host os: ' + host_os)
 
-platform_win32= host_os.contains('mingw') or host_os.contains('cygwin') or host_os.contains('windows')
+platform_win32= (
+  host_os.contains('mingw') or
+  host_os.contains('cygwin') or
+  host_os.contains('windows')
+)
 platform_osx  = host_os.contains('darwin')
 
-conf.set('PLATFORM_OSX',  platform_osx)
+conf.set('PLATFORM_OSX', platform_osx)
 
 if platform_win32
   windows = import('windows')
+  # AC_CHECK_PROG(ms_librarian, lib.exe, yes, no)
+  # AM_CONDITIONAL(MS_LIB_AVAILABLE, test "x$ms_librarian" = xyes)
+  # add_project_link_arguments(
+  #   '-Wl,--large-address-aware',
+  #   language: [ 'c', 'cpp' ]
+  # )
+endif
+# dirs_separator = platform_win32 ? '\\' : '/'
+# path_separator = platform_win32 ? ';'  : ':'
+
+
+if cc.version() == '7.2.0'
+  warning('''
+    GCC 7.2.0 has a serious bug affecting GEGL/GIMP. We advise
+    against using this version of the compiler (previous and
+    further versions are fine).
+    See https://bugzilla.gnome.org/show_bug.cgi?id=787222
+  ''')
 endif
 
 ################################################################################
@@ -151,7 +176,7 @@ glib              = dependency('glib-2.0',           version: '>=2.54.2')
 gobject           = dependency('gobject-2.0',        version: '>=2.54.2')
 gmodule           = dependency('gmodule-no-export-2.0')
 
-gtk2_minver       = '>=2.24.10'
+gtk2_minver       = '>=2.24.32'
 gtk2              = dependency('gtk+-2.0',           version: gtk2_minver)
 
 harfbuzz          = dependency('harfbuzz',           version: '>=0.9.19')
@@ -189,8 +214,18 @@ glib_networking_works =(glib_networking_works_run.compiled()
                     and glib_networking_works_run.returncode() == 0)
 
 if not glib_networking_works
-  error('Test for glib-networking failed. This is required.')
-# TODO check if cross-compiling
+  if is_cross_build()
+    warning('''
+      Test for glib-networking cannot be performed while cross-compiling.
+      Make sure glib-networking is installed, otherwise GIMP will not be able
+      to display the remote help pages through the help browser, nor will it
+      be able to open remote HTTPS (or other protocol using SSL/TLS) files.
+      HTTPS is becoming the expected standard and should not be considered
+      optional anymore.
+    ''')
+  else
+    error('Test for glib-networking failed. This is required.')
+  endif
 endif
 
 ################################################################################
@@ -207,37 +242,40 @@ pango_check =(pango_check_run.compiled()
           and pango_check_run.returncode() == 0)
 
 if not pango_check
-  message('''
-  *** You have a fontconfig >= fontconfig_required_version installed on your system, but your
-  *** Pango library is using an older version. This old version is probably in
-  *** /usr/X11R6. Look at the above output, and note that the result for
-  *** FONTCONFIG_CFLAGS is not in the result for PANGOCAIRO_CFLAGS, and that
-  *** there is likely an extra -I line, other than the ones for GLIB,
-  *** Freetype, and Pango itself. That's where your old fontconfig files are.
-  *** Rebuild pango, and make sure that it uses the newer fontconfig. The
-  *** easiest way be sure of this is to simply get rid of the old fontconfig.
-  *** When you rebuild pango, make sure the result for FONTCONFIG_CFLAGS is
-  *** the same as the result here.''')
+  warning('\n  *** '.join([
+  'You have a fontconfig >= fontconfig_required_version installed on your',
+  'system, but your Pango library is using an older version. This old version',
+  'is probably in /usr/X11R6. Look at the above output, and note that the',
+  'result for FONTCONFIG_CFLAGS is not in the result for PANGOCAIRO_CFLAGS,',
+  'and that there is likely an extra -I line, other than the ones for GLIB,',
+  'Freetype, and Pango itself. That\'s where your old fontconfig files are.',
+  'Rebuild pango, and make sure that it uses the newer fontconfig.',
+  'The easiest way be sure of this is to simply get rid of the old',
+  'fontconfig. When you rebuild pango, make sure the result for',
+  'FONTCONFIG_CFLAGS is the same as the result here.',
+  ]))
 endif
 
+
 # Check for Dr. Mingw
-# TODO check if that works
-have_drmingw = false
+drmingw = dependency('', required: false)
 if platform_win32
-  exchndl = cc.find_library('exchndl')
-  if exchndl.found()
-    have_drmingw = cc.has_function(
-      'ExcHndlSetLogFileNameA',
-      prefix: '',
-      dependencies: exchndl,
-    )
+  exchndl_ld = cc.find_library('exchndl')
+  exchndl_fn = cc.has_function('ExcHndlSetLogFileNameA', dependencies: exchndl)
+  if exchndl_ld.found() and exchndl_fn
+    drmingw = declare_dependency(link_with: exchndl_ld)
   endif
 endif
+conf.set('HAVE_EXCHNDL', drmingw.found())
 
 # Check for finite or isfinite
-conf.set('HAVE_FINITE',   cc.has_function('finite',   prefix: '#include <math.h>'))
-conf.set('HAVE_ISFINITE', cc.has_function('isfinite', prefix: '#include <math.h>'))
+foreach fn : [ 'finite', 'isfinite']
+  macro_name = 'HAVE_' + fn.to_upper()
+  conf.set(macro_name, cc.has_function(fn, prefix: '#include <math.h>'))
+endforeach
 
+
+## TODO only for release
 # Check for compiler CPU extensions
 cpuext_args = [
   '-mfpmath=sse',
@@ -255,62 +293,215 @@ conf.set10('COMPILE_SSE2_INTRINISICS',  cc.has_argument('-msse2'))
 conf.set10('COMPILE_SSE4_1_INTRINISICS',cc.has_argument('-msse4.1'))
 
 
-# TODO altivec
-has_altivec = cc.has_argument('-faltivec')
-cc.has_argument('-maltivec')
-cc.has_argument('-mabi=altivec')
+have_altivec        = false
+have_altivec_sysctl = false
+if arch_ppc
+  altivec_args = cc.get_supported_arguments([
+    '-faltivec',
+    '-maltivec',
+    '-mabi=altivec',
+  ])
+
+  if altivec_args != []
+    add_project_arguments     (altivec_args, language: [ 'c', 'cpp'])
+    add_project_link_arguments(altivec_args, language: [ 'c', 'cpp'])
+
+    if host_os.contains('darwin')
+      have_altivec = true
+      have_altivec_sysctl = true
+    elif cc.compiles('''
+      int main() { asm ("vand %v0, %v0, %v0"); return 0; }
+      ''')
+      have_altivec = true
+    endif
+  endif
+endif
+conf.set('HAVE_ALTIVEC_SYSCTL', have_altivec_sysctl)
+conf.set('USE_ALTIVEC',         have_altivec)
+
 
-# TODO shared memory handling
 
-# OpenMP
-conf.set10('ENABLE_MP', get_option('enable-openmp'))
+conf.set10('ENABLE_MP', get_option('enable-multiproc'))
 
 # Check if X11
-enable_doc_shooter = false
+x11_target = gtk2.get_pkgconfig_variable('target') == 'x11'
 
-if gtk2.get_pkgconfig_variable('target') == 'x11'
-  x11   = dependency('x11')
-  xmu   = dependency('xmu')
-  xt    = dependency('xt')
-  xext  = dependency('xext')
-  xfixes= dependency('xfixes')
+x11   = x11_target ? dependency('x11')    : dependency('', required: false)
+xmu   = x11_target ? dependency('xmu')    : dependency('', required: false)
+xt    = x11_target ? dependency('xt')     : dependency('', required: false)
+xext  = x11_target ? dependency('xext')   : dependency('', required: false)
+xfixes= x11_target ? dependency('xfixes') : dependency('', required: false)
+conf.set('HAVE_XFIXES', xfixes.found())
 
-  enable_doc_shooter = true
+enable_doc_shooter = x11_target
 
-  x11_headers   = [ 'X11/Xmu/WinUtil.h', 'X11/extensions/shape.h', ]
-  x11_functions = [ 'XmuClientWindow', 'XShapeGetRectangles', ]
-  foreach header : x11_headers
+if x11_target
+  foreach header : [ 'X11/Xmu/WinUtil.h', 'X11/extensions/shape.h', ]
     if not cc.has_header(header, dependencies: [ xext, xmu ])
       error('x11 install does not provide required header ' + header)
     endif
   endforeach
-  foreach function : x11_functions
+
+  foreach function : [ 'XmuClientWindow', 'XShapeGetRectangles', ]
     if not cc.has_function(function, dependencies: [ xext, xmu ])
       error('x11 install does not provide required function ' + function)
     endif
   endforeach
-  have_xlibs = true
-else
-  x11    = dependency('', required: false)
-  xmu    = dependency('', required: false)
-  xt     = dependency('', required: false)
-  xext   = dependency('', required: false)
-  xfixes = dependency('', required: false)
-  have_xlibs = false
 endif
+conf.set('HAVE_X11_EXTENSIONS_SHAPE_H', cc.has_header('X11/extensions/shape.h'))
+conf.set('HAVE_X11_XMU_WINUTIL_H',      cc.has_header('X11/Xmu/WinUtil.h'))
+
 
 # Print support
 have_print      = get_option('with-print')
 have_screenshot = get_option('with-screenshot')
-if have_print and not have_xlibs
+if have_print and not x11_target
   error('Printing requires x libs')
 endif
-if have_screenshot and not have_xlibs
+if have_screenshot and not x11_target
   error('Screenshot requires x libs')
 endif
 
-conf.set('HAVE_EXECINFO_H', cc.has_header('execinfo.h'))
-conf.set('HAVE_SYS_WAIT_H', cc.has_header('sys/wait.h'))
+
+# Headers
+conf.set  ('HAVE_ALLOCA_H',               cc.has_header('alloca.h'))
+conf.set  ('HAVE_DLFCN_H',                cc.has_header('dlfcn.h'))
+conf.set  ('HAVE_EXECINFO_H',             cc.has_header('execinfo.h'))
+conf.set  ('HAVE_IEEEFP_H',               cc.has_header('ieeefp.h'))
+conf.set  ('HAVE_INTTYPES_H',             cc.has_header('inttypes.h'))
+conf.set  ('HAVE_LOCALE_H',               cc.has_header('locale.h'))
+conf.set  ('HAVE_MATH_H',                 cc.has_header('math.h'))
+conf.set  ('HAVE_MEMORY_H',               cc.has_header('memory.h'))
+conf.set  ('HAVE_MMAN_H',                 cc.has_header('sys/mman.h'))
+conf.set  ('HAVE_IPC_H',                  cc.has_header('sys/ipc.h'))
+conf.set  ('HAVE_SHM_H',                  cc.has_header('sys/shm.h'))
+conf.set  ('HAVE_STDINT_H',               cc.has_header('stdint.h'))
+conf.set  ('HAVE_STDLIB_H',               cc.has_header('stdlib.h'))
+conf.set  ('HAVE_STRING_H',               cc.has_header('string.h'))
+conf.set  ('HAVE_STRINGS_H',              cc.has_header('strings.h'))
+conf.set  ('HAVE_SYS_PARAM_H',            cc.has_header('sys/param.h'))
+conf.set  ('HAVE_SYS_SELECT_H',           cc.has_header('sys/select.h'))
+conf.set  ('HAVE_SYS_STAT_H',             cc.has_header('sys/stat.h'))
+conf.set  ('HAVE_SYS_TIME_H',             cc.has_header('sys/time.h'))
+conf.set  ('HAVE_SYS_TIMES_H',            cc.has_header('sys/times.h'))
+conf.set  ('HAVE_SYS_TYPES_H',            cc.has_header('sys/types.h'))
+conf.set  ('HAVE_SYS_WAIT_H',             cc.has_header('sys/wait.h'))
+conf.set10('HAVE_UNISTD_H',               cc.has_header('unistd.h'))
+
+# Functions
+
+conf.set('HAVE_ALLOCA',                   cc.has_function('alloca'))
+conf.set('HAVE_BACKTRACE',                cc.has_function('backtrace'))
+conf.set('HAVE_DCGETTEXT',                cc.has_function('dcgettext'))
+conf.set('HAVE_DIFFTIME',                 cc.has_function('difftime'))
+conf.set('HAVE_FINITE',                   cc.has_function('finite'))
+conf.set('HAVE_FSYNC',                    cc.has_function('fsync'))
+conf.set('HAVE_GETADDRINFO',              cc.has_function('getaddrinfo'))
+conf.set('HAVE_GETNAMEINFO',              cc.has_function('getnameinfo'))
+conf.set('HAVE_GETTEXT',                  cc.has_function('gettext'))
+conf.set('HAVE_MMAP',                     cc.has_function('mmap'))
+conf.set('HAVE_RINT',                     cc.has_function('rint'))
+conf.set('HAVE_VPRINTF',                  cc.has_function('vprintf'))
+conf.set('HAVE_BIND_TEXTDOMAIN_CODESET',
+  cc.has_function('bind_textdomain_codeset')
+)
+
+# AC_HEADER_STDC
+# AC_HEADER_SYS_WAIT
+# AC_HEADER_TIME
+#
+# AC_CHECK_HEADERS(execinfo.h sys/param.h sys/time.h sys/times.h sys/wait.h
+# unistd.h)
+# AC_CHECK_FUNCS(backtrace, , AC_CHECK_LIB(execinfo, backtrace))
+#
+# AC_TYPE_PID_T
+# AC_FUNC_VPRINTF
+#
+# AC_FUNC_ALLOCA
+#
+# # check some more funcs
+# AC_CHECK_FUNCS(fsync)
+# AC_CHECK_FUNCS(difftime mmap)
+
+
+
+
+
+#undef HAVE_CFLOCALECOPYCURRENT
+#undef HAVE_CFPREFERENCESCOPYAPPVALUE
+#undef HAVE_DOPRNT
+#undef HAVE_DX_DINPUT
+#undef HAVE_LIBEXECINFO
+#undef HAVE_LIBNSL
+#undef HAVE_LIBPTHREAD
+#undef pid_t
+#undef size_t
+
+
+shmem_choice = get_option('shmem-type')
+if shmem_choice == 'auto'
+  shmem_choice = 'sysv'
+
+  # MacOS X has broken SysV shm
+  if (
+    host_os.contains('darwin') or
+    host_os.contains('rhapsody') or
+    host_os.contains('machten'))
+    shmem_choice = 'posix'
+  endif
+  if platform_win32
+    shmem_choice = 'win32'
+  endif
+endif
+
+if   shmem_choice == 'sysv'
+  check_ip_rmid_deferred_release = cc.run('''
+  #include <sys/types.h>
+  #include <sys/ipc.h>
+  #include <sys/shm.h>
+  int main() {
+    int id = shmget(IPC_PRIVATE, 4, IPC_CREAT | 0600);
+    if (id == -1)
+      exit(2);
+
+    char *shmaddr = shmat(id, 0, 0);
+    shmctl(id, IPC_RMID, 0);
+    if ((char*) shmat(id, 0, 0) == (char*) -1) {
+      shmdt(shmaddr);
+      exit(1);
+    }
+    shmdt(shmaddr);
+    shmdt(shmaddr);
+    exit(0);
+  }
+  ''').returncode() == 0
+  conf.set('IPC_RMID_DEFERRED_RELEASE', check_ip_rmid_deferred_release)
+  conf.set('USE_SYSV_SHM', true)
+elif shmem_choice == 'posix'
+  conf.set('USE_POSIX_SHM', true)
+endif
+
+
+conf.set('NO_FD_SET',
+  not platform_win32
+  and not cc.compiles('''
+    #include <sys/types.h>
+    int main() { fd_set readMask, writeMask; return 0; }
+  ''')
+)
+
+
+
+# GCC attributes
+conf.set('HAVE_FUNC_ATTRIBUTE_DESTRUCTOR',
+  cc.compiles('''__attribute__ ((destructor)) void destructor_fn(void) { }''')
+)
+
+
+libsocket = cc.find_library('socket', required: false)
+conf.set('HAVE_LIBSOCKET', libsocket.found())
+
+
 ################################################################################
 # MIME types
 # The list of MIME types that are supported by plug-ins
@@ -350,6 +541,7 @@ libjpeg = dependency('libjpeg', required: false)
 if libjpeg.found()
   MIMEtypes += 'image/jpeg'
 endif
+conf.set('HAVE_LIBJPEG', libjpeg.found())
 
 
 zlib = dependency('zlib', required: false)
@@ -429,6 +621,7 @@ if get_option('with-webkit')
 else
   webkit = dependency('', required: false)
 endif
+conf.set('HAVE_WEBKIT', webkit.found())
 
 
 if get_option('with-poppler')
@@ -455,7 +648,6 @@ MIMEtypes += 'application/pdf'
 
 
 if get_option('with-wmf')
-  wmf = [ cc.find_library('wmf'), cc.find_library('wmflite') ]
   wmf = dependency('libwmf', version: '>=0.2.8')
   MIMEtypes += [ 'image/x-wmf', ]
 else
@@ -471,7 +663,7 @@ else
 endif
 
 
-if get_option('with-xmc')
+if get_option('with-xcursor')
   xmc = dependency('xcursor')
   MIMEtypes += [ 'image/x-xcursor', ]
 else
@@ -484,39 +676,41 @@ if get_option('with-alsa')
 else
   alsa = dependency('', required: false)
 endif
+conf.set('HAVE_ALSA', alsa.found())
 
 
-have_linuxinput = false
-if get_option('with-linux-input')
+have_linuxinput = get_option('with-linux-input')
+if have_linuxinput
   if not cc.has_header('linux/input.h')
     error('linux/input.h header not found.')
   endif
-  have_linuxinput = true
 endif
 
 # DirectX DirectInput
-have_directXinput = false
+directx = dependency('', required: false)
 directx_sdk_path = get_option('with-directx-sdk')
+
 if directx_sdk_path != '' and platform_win32
   if directx_sdk_path.contains(' ')
-    message('Warning: The DirectX SDK should be accessible through a path without spaces. Use MSYS mounts.'
-        + '\nIgnoring your with-directx-sdk switch.'
-    )
+    warning('''
+    The DirectX SDK should be accessible through a path without spaces.
+    Use MSYS mounts.
+    Ignoring your with-directx-sdk switch.
+    ''')
   elif directx_sdk_path.contains('\\')
-    message('Warning: Use plain (forward) slashes only for the DirectX SDK path.'
-        + '\nIgnoring your with-directx-sdk switch.'
-    )
+    warning('''
+    Use plain (forward) slashes only for the DirectX SDK path.
+    Ignoring your with-directx-sdk switch.
+    ''')
   else
-    have_directXinput = true
-    conf.set10('HAVE_DX_DINPUT', have_directXinput)
-    dxguid = cc.find_library('dxguid',
-      dirs: join_paths(directx_sdk_path, 'Lib', 'x86'),
-    )
-    directx = declare_dependency(link_with: dxguid,
+    directx = declare_dependency(
+      link_with: cc.find_library('dxguid',
+                    dirs:  join_paths(directx_sdk_path, 'Lib', 'x86')),
       include_directories: join_paths(directx_sdk_path, 'Include'),
     )
   endif
 endif
+conf.set('HAVE_DX_DINPUT', directx.found())
 
 
 if get_option('with-gudev')
@@ -524,28 +718,58 @@ if get_option('with-gudev')
 else
   gudev = dependency('', required: false)
 endif
+conf.set('HAVE_LIBGUDEV', gudev.found())
+
+
+# sendmail
+email_message = false
+
+sendmail_choice = get_option('with-sendmail')
+if not [ '', 'false', 'no', ].contains(sendmail_choice)
+  sendmail_path = (
+    [ 'true', 'yes' ].contains(sendmail_choice) ? 'sendmail' : sendmail_choice
+  )
+  sendmail = find_program(sendmail_path, required: false)
+  if sendmail.found()
+    sendmail_path = sendmail.path()
+  else
+    warning('''
+      Sendmail specified but not found. It should be installed at runtime!
+    ''')
+  endif
 
+  email_message = '@0@ (@1@)'.format(true, sendmail_path)
+  conf.set_quoted('SENDMAIL', sendmail_path)
+else
+  xdg_email_path = 'xdg-email'
+  xdg_email = find_program(xdg_email_path, required: false)
+  if xdg_email.found()
+    xdg_email_path = xdg_email.path()
+  else
+    warning('''
+      Sendmail specified but not found. It should be installed at runtime!
+    ''')
+  endif
 
-# sendmail TODO
-have_email = true
+  email_message = '@0@ (@1@)'.format(true, xdg_email_path)
+endif
 
 # perl
 perl = find_program('perl5', 'perl', 'perl5.005', 'perl5.004', 'perl')
 
 
 # python
-have_python = false
-if get_option('with-python')
+have_python = get_option('with-python')
+if have_python
   python2 = find_program('python2')
-  pygobjectcodegen = find_program('pygobject-codegen-2.0')
 
   libpython2= dependency('python2',       version: '>=2.5.0')
   pygobject = dependency('pygobject-2.0', version: '>=2.10.4')
   pygtk2    = dependency('pygtk-2.0',     version: '>=2.10.4')
   pycairo   = dependency('pycairo',       version: '>=1.0.2')
 
+  pygobjectcodegen = find_program('pygobject-codegen-2.0')
   pygtk_defsdir = pygtk2.get_pkgconfig_variable('defsdir')
-  have_python = true
 endif
 
 
@@ -556,9 +780,15 @@ have_scriptfu = get_option('with-script-fu')
 # Check for GTK Mac Integration
 gtk_mac_integration_ok = false
 if platform_osx and (gtk2.get_pkgconfig_variable('target') == 'xquartz')
-  gtk2_macos   = dependency('gtk-mac-integration-gtk2', version: '>=2.0.0', required: false)
+  gtk2_macos = dependency('gtk-mac-integration-gtk2',
+    version: '>=2.0.0',
+    required: false
+  )
   if not gtk2_macos.found()
-    gtk2_macos = dependency('gtk-mac-integration'     , version: '>=2.0.0', required: false)
+    gtk2_macos = dependency('gtk-mac-integration',
+      version: '>=2.0.0',
+      required: false
+    )
   endif
   gtk_mac_integration_ok = gtk2_macos.found()
 endif
@@ -572,29 +802,33 @@ gdk_pixbuf_csource = find_program('gdk-pixbuf-csource')
 
 
 # Check for vector icons
-# TODO
-have_vector_icons = true
-# if get_option('with-vec-icons')
-#   # shared-mime-info is needed to correctly detect SVG files
-#   # (except on Windows, apparently).
-#   shared_mime_info = dependency('shared-mime-info', required: false)
-#   if shared_mime_info.found() or platform_win32
-#
-#   endif
-# endif
+have_vector_icons = get_option('with-vec-icons')
+if have_vector_icons
+  # shared-mime-info is needed to correctly detect SVG files
+  # (except on Windows, apparently).
+  if platform_win32
+    warning('''
+      You enabled vector icons on Win32. Make sure to run:
+      $ gdk-pixbuf-query-loaders.exe --update-cache
+      on the target machine (this command generates loaders.cache)
+      so that GdkPixbuf knows where to find the SVG loader.
+    ''')
+  else
+    shared_mime_info = dependency('shared-mime-info')
+  endif
+endif
 
 if get_option('with-xvfb-run')
   xvfb_run = find_program('xvfb-run')
 else
   xvfb_run = dependency('', required: false)
 endif
+conf.set('HAVE_XVFB_RUN', xvfb_run.found())
 
 
-if get_option('with-appdata-test')
-  appstream_util = find_program('appstream-util')
-else
-  appstream_util = dependency('', required: false)
-endif
+test_appdata = (
+  get_option('with-appdata-test') and find_program('appstream-util').found()
+)
 
 
 if get_option('with-gtk-doc')
@@ -614,9 +848,10 @@ if gimpdir == ''
   gimpdir = meson.project_name().to_upper()
 endif
 
-gimpdatadir    = join_paths(get_option('datadir'),    meson.project_name(), api_version)
-gimpplugindir  = join_paths(get_option('libdir'),     meson.project_name(), api_version)
-gimpsysconfdir = join_paths(get_option('sysconfdir'), meson.project_name(), api_version)
+project_subdir = join_paths(meson.project_name(), api_version)
+gimpdatadir    = join_paths(get_option('datadir'),    project_subdir)
+gimpplugindir  = join_paths(get_option('libdir'),     project_subdir)
+gimpsysconfdir = join_paths(get_option('sysconfdir'), project_subdir)
 gimpmanpagedir = gimpdir
 localedir      = join_paths(get_option('datadir'), 'locale')
 
@@ -665,12 +900,12 @@ add_project_arguments([
 
 
 # Check for internal tools
-defcheck            = find_program(join_paths('tools', 'defcheck.py'))
-extract_vector_icon = find_program(join_paths('tools', 'extract-vector-icon.sh'))
-generate_changelog  = find_program(join_paths('tools', 'generate_changelog.sh'))
-generate_news       = find_program(join_paths('tools', 'generate-news'))
-gimppath2svg        = find_program(join_paths('tools', 'gimppath2svg.py'))
-module_dependencies = find_program(join_paths('tools', 'module-dependencies.py'))
+defcheck            = find_program(join_paths('tools','defcheck.py'))
+extract_vector_icon = find_program(join_paths('tools','extract-vector-icon.sh'))
+generate_changelog  = find_program(join_paths('tools','generate_changelog.sh'))
+generate_news       = find_program(join_paths('tools','generate-news'))
+gimppath2svg        = find_program(join_paths('tools','gimppath2svg.py'))
+module_dependencies = find_program(join_paths('tools','module-dependencies.py'))
 
 gimp_mkenums        = find_program(join_paths('tools', 'gimp-mkenums'))
 gimp_mkenums_custom_target_commonargs = [
@@ -685,10 +920,15 @@ gimp_mkenums_custom_target_commonargs = [
             '  };\n',
   '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
             '  {',
-  '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },@if (\'@valueabbrev@\' ne \'NULL\')@\n'+
-            '    /* Translators: this is an abbreviated version of @valueudesc@.\n'+
+  '--dprod','    {\n'+
+            '      @VALUENAME@, @valuedesc@, @valuehelp@\n'+
+            '    },\n'+
+            '    @if (\'@valueabbrev@\' ne \'NULL\')@\n'+
+            '    /* Translators:\n'+
+            '       this is an abbreviated version of @valueudesc@.\n'+
             '       Keep it short. */\n'+
-            '    { @VALUENAME@, @valueabbrev@, NULL },@endif@',
+            '    { @VALUENAME@, @valueabbrev@, NULL },\n'+
+            '    @endif@',
   '--dtail','    { 0, NULL, NULL }\n'+
             '  };\n'+
             '\n'+
@@ -707,11 +947,8 @@ gimp_mkenums_custom_target_commonargs = [
 ]
 
 
-################################################################################
-# Localisation
-gettext_package = 'gimp20'
-
-conf.set_quoted('GETTEXT_PACKAGE',gettext_package)
+conf.set('ENABLE_NLS',   true)
+conf.set('HAVE_GETTEXT', true)
 
 # localedir = join_paths(get_option('prefix'), get_option('localedir'))
 
@@ -721,8 +958,13 @@ conf.set_quoted('GETTEXT_PACKAGE',gettext_package)
 
 isocodes = dependency('iso-codes')
 isocodes_prefix = isocodes.get_pkgconfig_variable('prefix')
-isocodes_location = join_paths(isocodes_prefix,get_option('datadir'),'xml','iso-codes')
-isocodes_localedir= join_paths(isocodes_prefix,get_option('datadir'),'locale')
+isocodes_location = join_paths(
+  isocodes_prefix, get_option('datadir'), 'xml', 'iso-codes'
+)
+isocodes_localedir= join_paths(
+  isocodes_prefix, get_option('datadir'), 'locale'
+)
+conf.set('HAVE_ISO_CODES', isocodes.found())
 
 
 ################################################################################
@@ -756,6 +998,7 @@ add_project_arguments(
   # '-Wstrict-prototypes',
   '-Wtype-limits',
 
+  # Performance flags
   # '--omg-optimized',
   # '--disable-instructions',
   language: [ 'c', 'cpp', ],
@@ -763,16 +1006,28 @@ add_project_arguments(
 
 # Ensure MSVC-compatible struct packing convention is used when
 # compiling for Win32 with gcc.
-if platform_win32
-  add_project_arguments(
-    cc.first_supported_argument('-fnative-struct', '-mms-bitfields'),
-    language: [ 'c', 'cpp' ],
-       )
+if platform_win32 and cc.get_id() == gcc
+  msvc_compat_args = cc.first_supported_argument([
+    '-fnative-struct',
+    '-mms-bitfielads',
+  ])
+  if msvc_compat_args == []
+    warning('''
+      GCC does not support '-fnative-struct' nor '-mms-bitfields'.
+      Build will be incompatible with GTK+ DLLs.
+    ''')
+  endif
+  add_project_arguments(msvc_compat_args, language: [ 'c', 'cpp' ])
 endif
 
-has_nl_measurement = cc.has_function(
-  'nl_langinfo',
-  prefix: '#include<langinfo.h>',
+
+conf.set('HAVE__NL_MEASUREMENT_MEASUREMENT',
+  cc.compiles('''
+    #include<langinfo.h>
+    int main() {
+      char c = *((unsigned char *)  nl_langinfo(_NL_MEASUREMENT_MEASUREMENT));
+    }
+  ''')
 )
 
 ################################################################################
@@ -803,26 +1058,26 @@ config_defines = [
   '-DGIMP_APP_VERSION_STRING="' + app_version           +'"',
 
   # Directories
-  '-DPREFIX='               +'"'+ prefix                +'"',
-  '-DEXEC_PREFIX='          +'"'+ prefix                +'"',
-  '-DGIMPDIR='              +'"'+ gimpdir               +'"',
-  '-DGIMPSYSCONFDIR='       +'"'+ gimpsysconfdir        +'"',
-  '-DGIMPDATADIR='          +'"'+ join_paths(prefix, gimpdatadir)    +'"',
-  '-DGIMPPLUGINDIR='        +'"'+ join_paths(prefix, gimpplugindir)  +'"',
-  '-DPLUGINDIR='            +'"'+ join_paths(prefix, gimpplugindir)  +'"',
-  '-DLOCALEDIR='            +'"'+ join_paths(prefix, localedir)      +'"',
-
-  '-DLOCALSTATEDIR='        +'"'+ get_option('localstatedir')        +'"',
-  '-DSHAREDSTATEDIR='       +'"'+ get_option('sharedstatedir')       +'"', # HUH ? /usr/com
-  '-DSYSCONFDIR='           +'"'+ get_option('sysconfdir')           +'"',
-  '-DBINDIR='               +'"'+ join_paths(prefix, get_option('bindir'))       +'"',
-  '-DDATAROOTDIR='          +'"'+ join_paths(prefix, get_option('datadir'))      +'"',
-  '-DINFODIR='              +'"'+ join_paths(prefix, get_option('infodir'))      +'"',
-  '-DLIBDIR='               +'"'+ join_paths(prefix, get_option('libdir'))       +'"',
-  '-DLIBEXECDIR='           +'"'+ join_paths(prefix, get_option('libexecdir'))   +'"',
-  '-DMANDIR='               +'"'+ join_paths(prefix, get_option('mandir'))       +'"',
-  '-DSBINDIR='              +'"'+ join_paths(prefix, get_option('sbindir'))      +'"',
-  '-DSYSDATADIR='           +'"'+ join_paths(prefix, get_option('datadir'))      +'"',
+  '-DPREFIX='         +'"'+ prefix                +'"',
+  '-DEXEC_PREFIX='    +'"'+ prefix                +'"',
+  '-DGIMPDIR='        +'"'+ gimpdir               +'"',
+  '-DGIMPSYSCONFDIR=' +'"'+ gimpsysconfdir        +'"',
+  '-DGIMPDATADIR='    +'"'+ join_paths(prefix, gimpdatadir)    +'"',
+  '-DGIMPPLUGINDIR='  +'"'+ join_paths(prefix, gimpplugindir)  +'"',
+  '-DPLUGINDIR='      +'"'+ join_paths(prefix, gimpplugindir)  +'"',
+  '-DLOCALEDIR='      +'"'+ join_paths(prefix, localedir)      +'"',
+
+  '-DLOCALSTATEDIR='  +'"'+ get_option('localstatedir')        +'"',
+  '-DSHAREDSTATEDIR=' +'"'+ get_option('sharedstatedir')       +'"', # /usr/com?
+  '-DSYSCONFDIR='     +'"'+ get_option('sysconfdir')           +'"',
+  '-DBINDIR='         +'"'+ join_paths(prefix, get_option('bindir'))       +'"',
+  '-DDATAROOTDIR='    +'"'+ join_paths(prefix, get_option('datadir'))      +'"',
+  '-DINFODIR='        +'"'+ join_paths(prefix, get_option('infodir'))      +'"',
+  '-DLIBDIR='         +'"'+ join_paths(prefix, get_option('libdir'))       +'"',
+  '-DLIBEXECDIR='     +'"'+ join_paths(prefix, get_option('libexecdir'))   +'"',
+  '-DMANDIR='         +'"'+ join_paths(prefix, get_option('mandir'))       +'"',
+  '-DSBINDIR='        +'"'+ join_paths(prefix, get_option('sbindir'))      +'"',
+  '-DSYSDATADIR='     +'"'+ join_paths(prefix, get_option('datadir'))      +'"',
 
   # Third-party/Misc
   '-DISO_CODES_LOCATION='   +'"'+ isocodes_location  +'"',
@@ -884,8 +1139,6 @@ subdir('po-python')
 subdir('po-script-fu')
 subdir('po-tags')
 subdir('po-tips')
-# subdir('po-windows-installer')
-
 # Data / Desktop / xml files
 subdir('cursors')
 subdir('data')
@@ -909,22 +1162,57 @@ subdir('libgimp')
 subdir('modules')
 subdir('plug-ins')
 subdir('app')
-
 subdir('pdb')
 
-# subdir('build/windows/installer')
-# subdir('po-windows-installer')
+if platform_win32
+  # subdir('build/windows/installer')
+  # subdir('po-windows-installer')
+endif
 
 # Docs
 subdir('devel-docs')
 subdir('docs')
 
+install_conf = configuration_data()
+
+install_conf.set('GIMP_APP_VERSION', app_version)
+install_conf.set('GIMP_PKGCONFIG_VERSION', gimp_version)
+install_conf.set('GIMP_VERSION', gimp_version)
+
+install_conf.set('ATK_REQUIRED_VERSION',          atk         .version())
+install_conf.set('BABL_REQUIRED_VERSION',         babl        .version())
+install_conf.set('CAIRO_PDF_REQUIRED_VERSION',    cairopdf    .version())
+install_conf.set('CAIRO_REQUIRED_VERSION',        cairo       .version())
+install_conf.set('FONTCONFIG_REQUIRED_VERSION',   fontconfig  .version())
+install_conf.set('FREETYPE2_REQUIRED_VERSION',    freetype2   .version())
+install_conf.set('GDK_PIXBUF_REQUIRED_VERSION',   gdk_pixbuf  .version())
+install_conf.set('GEGL_REQUIRED_VERSION',         gegl        .version())
+install_conf.set('GLIB_REQUIRED_VERSION',         glib        .version())
+install_conf.set('GTK_REQUIRED_VERSION',          gtk2        .version())
+install_conf.set('HARFBUZZ_REQUIRED_VERSION',     harfbuzz    .version())
+install_conf.set('INTLTOOL_REQUIRED_VERSION',     '0.40.1')
+install_conf.set('LCMS_REQUIRED_VERSION',         lcms        .version())
+install_conf.set('LIBLZMA_REQUIRED_VERSION',      liblzma     .version())
+install_conf.set('LIBMYPAINT_REQUIRED_VERSION',   libmypaint  .version())
+install_conf.set('LIBPNG_REQUIRED_VERSION',       libpng      .version())
+install_conf.set('OPENEXR_REQUIRED_VERSION',      openexr     .version())
+install_conf.set('PANGOCAIRO_REQUIRED_VERSION',   pangocairo  .version())
+install_conf.set('POPPLER_DATA_REQUIRED_VERSION', poppler[1]  .version())
+install_conf.set('POPPLER_REQUIRED_VERSION',      poppler[0]  .version())
+install_conf.set('PYTHON2_REQUIRED_VERSION',      '2.5.0')
+install_conf.set('RSVG_REQUIRED_VERSION',         rsvg        .version())
+install_conf.set('WEBKIT_REQUIRED_VERSION',       webkit      .version())
+install_conf.set('WEBP_REQUIRED_VERSION',         webp        .version())
+install_conf.set('WMF_REQUIRED_VERSION',          wmf         .version())
+
+install_conf.set('FONTCONFIG_WIN32_RECOMMENDED_VERSION', fontconfig.version())
+install_conf.set('XGETTEXT_RECOMMENDED_VERSION', '0.19')
 
-# configure_file(
-#   input : 'INSTALL.in',
-#   output: 'INSTALL',
-#   configuration: conf
-# )
+configure_file(
+  input : 'INSTALL.in',
+  output: 'INSTALL',
+  configuration: install_conf
+)
 
 configure_file(
   output: 'config.h',
@@ -1004,7 +1292,7 @@ Extra Binaries:
 Optional Features:
   Language selection:  @0@'''.format(isocodes.found()) +'''
   Vector icons:        @0@'''.format(have_vector_icons) +'''
-  Dr. Mingw (Win32):   @0@'''.format(have_drmingw) +'''
+  Dr. Mingw (Win32):   @0@'''.format(drmingw.found()) +'''
 
 Optional Plug-Ins:
   Ascii Art:           @0@'''.format(libaa.found()) +'''
@@ -1023,16 +1311,17 @@ Optional Plug-Ins:
   WMF:                 @0@'''.format(wmf.found()) +'''
   X11 Mouse Cursor:    @0@'''.format(xmc.found()) +'''
   XPM:                 @0@'''.format(libxpm.found()) +'''
-  Email:               @0@'''.format(have_email) +'''
+  Email:               @0@'''.format(email_message) +'''
 
 Optional Modules:
   ALSA (MIDI Input):   @0@'''.format(alsa.found()) +'''
-  Linux Input:         @0@'''.format(have_linuxinput) +''' (GUdev support: @0@'''.format(gudev.found()) +''')
-  DirectInput (Win32): @0@'''.format(have_directXinput) +'''
+  Linux Input:         @0@ (GUdev support: @0@)'''
+                        .format(have_linuxinput, gudev.found()) +'''
+  DirectInput (Win32): @0@'''.format(directx.found()) +'''
 
 Tests:
   Use xvfb-run         @0@'''.format(xvfb_run.found()) +'''
-  Test appdata         @0@'''.format(appstream_util.found()) +'''
+  Test appdata         @0@'''.format(test_appdata) +'''
 '''
 )
 
@@ -1077,16 +1366,16 @@ if xmllint.found()
 endif
 
 # TODO this python script is waiting for autotools directory/files structure
-custom_target('check-defs',
-  input : [ ],
-  output: [ 'check-defs', ],
-  command: [
-    python2.path(),
-    join_paths(meson.source_root(), 'tools','defcheck.py'),
-    meson.source_root(),
-  ],
-  build_by_default: false,
-)
+# custom_target('check-defs',
+#   input : [ ],
+#   output: [ 'check-defs', ],
+#   command: [
+#     python2.path(),
+#     join_paths(meson.source_root(), 'tools','defcheck.py'),
+#     meson.source_root(),
+#   ],
+#   build_by_default: false,
+# )
 
 
 custom_target('Changelog',
diff --git a/meson_options.txt b/meson_options.txt
index 4269354..da62987 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,5 +1,5 @@
 option('ansi',              type: 'boolean', value: false)
-option('enable-openmp',     type: 'boolean', value: true)
+option('enable-multiproc',  type: 'boolean', value: true)
 option('enable-default-bin',type: 'boolean', value: true)
 option('enable-console-bin',type: 'boolean', value: true)
 option('windows-installer', type: 'boolean', value: false)
@@ -19,6 +19,7 @@ option('with-mng',          type: 'boolean', value: true)
 option('with-openexr',      type: 'boolean', value: true)
 option('with-poppler',      type: 'boolean', value: true)
 option('with-print',        type: 'boolean', value: true)
+option('with-sendmail',     type: 'string',  value: '')
 option('with-screenshot',   type: 'boolean', value: true)
 option('with-python',       type: 'boolean', value: true)
 option('with-script-fu',    type: 'boolean', value: true)
@@ -26,7 +27,7 @@ option('with-vec-icons',    type: 'boolean', value: true)
 option('with-webkit',       type: 'boolean', value: true)
 option('with-webp',         type: 'boolean', value: true)
 option('with-wmf',          type: 'boolean', value: true)
-option('with-xmc',          type: 'boolean', value: true)
+option('with-xcursor',      type: 'boolean', value: true)
 option('with-xpm',          type: 'boolean', value: true)
 option('with-xvfb-run',     type: 'boolean', value: true)
 option('shmem-type',        type: 'combo',   value: 'auto',
diff --git a/modules/meson.build b/modules/meson.build
index e2f9c2d..792c6fc 100644
--- a/modules/meson.build
+++ b/modules/meson.build
@@ -57,12 +57,12 @@ if have_linuxinput
   modules += [
     [ 'controller-linux-input',
       [ 'controller-linux-input.c', 'gimpinputdevicestore-gudev.c', ],
-      [], [ controller_libs, ],
+      [ gudev, ], [ controller_libs, ],
     ],
   ]
 endif
 
-if have_directXinput
+if directx.found()
   modules += [
     [ 'controller-dx-input',
       [ 'controller-dx-dinput.c', 'gimpinputdevicestore-dx.c', ],
@@ -75,7 +75,7 @@ if not platform_win32
   modules += [
     [ 'controller-midi',
       [ 'controller-midi.c', ],
-      [], [ controller_libs, ],
+      [ alsa, ], [ controller_libs, ],
     ],
   ]
 endif
diff --git a/plug-ins/common/meson.build b/plug-ins/common/meson.build
index d943697..cacfc21 100644
--- a/plug-ins/common/meson.build
+++ b/plug-ins/common/meson.build
@@ -321,11 +321,6 @@ common_exes_list = [
     [ gtk2, gegl, gdk_pixbuf, ],
   ],
   [
-    'mail',
-    [ 'mail.c', ],
-    [ gtk2, gegl, gdk_pixbuf, ],
-  ],
-  [
     'max-rgb',
     [ 'max-rgb.c', ],
     [ gtk2, gegl, gdk_pixbuf, ],
@@ -442,13 +437,13 @@ common_exes_list = [
   ],
 ]
 
-if webkit.found()
+if platform_win32
   common_exes_list += [
     [
-      'web-page',
-      [ 'web-page.c', ],
-      [ gtk2, gegl, gdk_pixbuf, webkit, ],
-    ]
+      'mail',
+      [ 'mail.c', ],
+      [ gtk2, gegl, gdk_pixbuf, ],
+    ],
   ]
 endif
 
@@ -482,6 +477,16 @@ if libxpm.found()
   ]
 endif
 
+if webkit.found()
+  common_exes_list += [
+    [
+      'web-page',
+      [ 'web-page.c', ],
+      [ gtk2, gegl, gdk_pixbuf, webkit, ],
+    ]
+  ]
+endif
+
 foreach exe : common_exes_list
   exe_name = exe[0]
   exe_sources = exe[1]



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