meson.build 50.8 KB
Newer Older
Salamandar's avatar
Salamandar committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
project('gimp',
  'c', 'cpp',
  version: '2.99.1',
  meson_version: '>=0.50.0',
  default_options: [
    'cpp_std=gnu++14',
  ],
)

project_url = 'https://gitlab.gnome.org/GNOME/gimp'
project_url_issues = project_url + '/issues/new'

conf = configuration_data()

15 16
warnings = []

Salamandar's avatar
Salamandar committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
################################################################################
# Project info

prettyname = 'GIMP'
full_name  = 'GNU Image Manipulation Program'

# General version
gimp_version = meson.project_version()

package_string= prettyname + ' ' + gimp_version

gimp_app_version_arr = gimp_version.split('.')
gimp_app_version_major = gimp_app_version_arr[0].to_int()
gimp_app_version_minor = gimp_app_version_arr[1].to_int()
gimp_app_version_micro = gimp_app_version_arr[2].to_int()

# Override for Release-candidates
gimp_app_version = '@0@.@1@'.format(
  gimp_app_version_major,
  gimp_app_version_minor
)


# API & pkg-config version
api_version_major = gimp_app_version_major
api_version_minor = gimp_app_version_minor

if api_version_minor == 99
  api_version_major += 1
  api_version_minor = 0
endif

gimp_api_version = '@0@.@1@'.format(api_version_major, api_version_minor)
gimp_api_name = 'gimp-' + gimp_api_version



gimp_command  = 'gimp-' + gimp_app_version

gettext_package= 'gimp@0@@1@'.format(api_version_major, api_version_minor)
conf.set_quoted('GETTEXT_PACKAGE', gettext_package)

conf.set_quoted('GIMP_VERSION', gimp_version)

stable = (gimp_app_version_minor % 2 == 0)
conf.set10('GIMP_UNSTABLE', not stable)

versionconfig = configuration_data()
versionconfig.set('GIMP_FULL_NAME',     full_name)
versionconfig.set('GIMP_MAJOR_VERSION', gimp_app_version_major)
versionconfig.set('GIMP_MINOR_VERSION', gimp_app_version_minor)
versionconfig.set('GIMP_MICRO_VERSION', gimp_app_version_micro)
versionconfig.set('GIMP_VERSION',       gimp_version)
versionconfig.set('GIMP_API_VERSION',   gimp_api_version)


luzpaz's avatar
luzpaz committed
73
# Libtool versioning
Salamandar's avatar
Salamandar committed
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
gimp_interface_age = 0
lt_current = 0
lt_revision = gimp_app_version_micro
lt_age = 100*api_version_minor + 0
so_version = '@0@.@1@.@2@'.format(lt_current, lt_age, lt_revision)


################################################################################
# Get configuration and Meson modules

pkgconfig = import('pkgconfig')
i18n      = import('i18n')
gnome     = import('gnome')
pythonmod = import('python')

cc        = meson.get_compiler('c')
cxx       = meson.get_compiler('cpp')
prefix    = get_option('prefix')
buildtype = get_option('buildtype')

compiler_args = []
linker_args = []

################################################################################
# Host system detection

cpu = host_machine.cpu().to_lower()

arch_x86_64 = (cpu == 'x86_64')
arch_x86    = (cpu.startswith('i') and cpu.endswith('86')) or arch_x86_64
arch_ppc64  = (cpu == 'ppc64' or cpu == 'powerpc64')
arch_ppc    = (cpu == 'ppc'   or 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_linux = (
  host_os.contains('linux')
)

platform_windows = (
  host_os.contains('mingw') or
  host_os.contains('cygwin') or
  host_os.contains('windows')
)

platform_osx = (
  host_os.contains('machten') or
  host_os.contains('rhapsody') or
  host_os.contains('darwin')
)

conf.set('PLATFORM_OSX', platform_osx)

if platform_windows
  windows = import('windows')
  # AC_CHECK_PROG(ms_librarian, lib.exe, yes, no)
  # AM_CONDITIONAL(MS_LIB_AVAILABLE, test "x$ms_librarian" = xyes)
  # compiler_args += '-Wl,--large-address-aware'
endif


if cc.get_id() == 'gcc' and cc.version() == '7.2.0'
147
  gcc_warning = '''
Salamandar's avatar
Salamandar committed
148 149 150 151
    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
152 153 154
  '''
  warning(gcc_warning)
  warnings += gcc_warning
Salamandar's avatar
Salamandar committed
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
endif



################################################################################
# Compiler CPU extensions for optimizations

if (get_option('buildtype') == 'release' or
    get_option('buildtype') == 'debugoptimized')

  # Check for compiler CPU extensions
  existing_cpu_exts = [
    '-mfpmath=sse',
    '-mmmx',
    '-msse',
    '-msse2',
    '-msse4.1',
  ]
  supported_cpu_exts = cc.get_supported_arguments(existing_cpu_exts)

  compiler_args += supported_cpu_exts

  conf.set  ('USE_MMX',                   '-mmmx'    in supported_cpu_exts)
  conf.set  ('USE_SSE',                   '-msse'    in supported_cpu_exts)
  conf.set10('COMPILE_SSE2_INTRINISICS',  '-msse2'   in supported_cpu_exts)
  conf.set10('COMPILE_SSE4_1_INTRINISICS','-msse4.1' in supported_cpu_exts)


  have_altivec        = false
  have_altivec_sysctl = false
  if arch_ppc
    altivec_args = cc.get_supported_arguments([
      '-faltivec',
      '-maltivec',
      '-mabi=altivec',
    ])

    if altivec_args != []
      compiler_args += altivec_args
      linker_args   += altivec_args

      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)

endif


################################################################################
# CFlags


if get_option('profiling') and cc.get_id() == 'gcc'
  compiler_args += '-pg'
  linker_args   += '-pg'
endif

if get_option('ansi')
  compiler_args += [ '-ansi', '-pedantic']
endif

warning_cflags_common = [
  '-fdiagnostics-show-option',
  '-fno-common',

  '-Wformat-security',
  '-Winit-self',
  '-Wlogical-op',
  '-Wmissing-declarations',
  '-Wmissing-format-attribute',
  '-Wpointer-arith',
  '-Wreturn-type',
  '-Wtype-limits',

  # You can uncomment this to debug with less warning outputs
  '-Wno-deprecated-declarations',
]
warning_cflags_c = [
  '-Wdeclaration-after-statement',
  '-Wold-style-definition',
  '-Wno-strict-prototypes',
245 246

  '-Werror=implicit-function-declaration',
Salamandar's avatar
Salamandar committed
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
]
warning_cflags_cpp = [
]

compiler_args += cc.get_supported_arguments(warning_cflags_common)
add_project_arguments(cc .get_supported_arguments(warning_cflags_c),   language: 'c')
add_project_arguments(cxx.get_supported_arguments(warning_cflags_cpp), language: 'cpp')


# Ensure MSVC-compatible struct packing convention is used when
# compiling for Win32 with gcc.
if platform_windows and cc.get_id() == 'gcc'
  msvc_compat_args = cc.first_supported_argument([
    '-fnative-struct',
    '-mms-bitfields',
  ])
  if msvc_compat_args == []
    error('''
      GCC does not support '-fnative-struct' nor '-mms-bitfields'.
      Build will be incompatible with GTK+ DLLs.
    ''')
  endif
  compiler_args += msvc_compat_args
endif


conf.set('HAVE__NL_MEASUREMENT_MEASUREMENT',
  cc.compiles('''
    #include<langinfo.h>
    int main() {
      char c = *((unsigned char *)  nl_langinfo(_NL_MEASUREMENT_MEASUREMENT));
    }
  ''')
)


################################################################################
# Dependencies
no_dep = dependency('', required: false)

################################################################################
# Mandatory Dependencies

290 291 292 293 294 295 296 297 298 299 300 301 302 303
if get_option('relocatable-bundle').enabled()
  relocatable_bundle = true
elif get_option('relocatable-bundle').disabled()
  relocatable_bundle = false
else # .auto()
  # By default, assume building for Windows or macOS everything to be on
  # the same prefix and can be relocated.
  # On other platforms, build-time paths are meaningful.
  if platform_windows or platform_osx
      relocatable_bundle = true
  else
      relocatable_bundle = false
  endif
endif
Salamandar's avatar
Salamandar committed
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
conf.set('ENABLE_RELOCATABLE_RESOURCES', relocatable_bundle)


math              = cc.find_library('m')
dl                = platform_windows ? no_dep : cc.find_library('dl')
rpc               = platform_windows ? cc.find_library('rpcrt4') : no_dep
dbghelp           = platform_windows ? cc.find_library('dbghelp') : no_dep
winsock           = platform_windows ? cc.find_library('ws2_32') : no_dep

atk               = dependency('atk',                version: '>=2.4.0')

babl              = dependency('babl',               version: '>=0.1.72')

cairo             = dependency('cairo',              version: '>=1.12.2')

dbus_glib         = dependency('dbus-glib-1')

# fontconfig_name   = platform_windows ? 'fontconfig_win32' : 'fontconfig'
fontconfig_name   = 'fontconfig'
fontconfig        = dependency(fontconfig_name,      version: '>=2.12.4')

freetype2         = dependency('freetype2',          version: '>=2.1.7')

gdk_pixbuf        = dependency('gdk-pixbuf-2.0',     version: '>=2.30.8')

gegl              = dependency('gegl-0.4',           version: '>=0.4.17')

gexiv2            = dependency('gexiv2',             version: '>=0.10.6')

gio               = dependency('gio-2.0')
gio_specific_name = platform_windows ? 'gio-windows-2.0' : 'gio-unix-2.0'
gio_specific      = dependency(gio_specific_name)

Jehan's avatar
Jehan committed
337
glib_version      = platform_windows ? '>=2.56.2' : '>=2.54.2'
Salamandar's avatar
Salamandar committed
338
glib              = dependency('glib-2.0',           version: glib_version)
Jehan's avatar
Jehan committed
339 340

conf.set('G_DISABLE_DEPRECATED', glib.version().version_compare('>=2.57'))
Salamandar's avatar
Salamandar committed
341 342 343 344 345 346 347 348 349 350 351

gobject           = dependency('gobject-2.0',        version: '>=2.54.2')
gmodule           = dependency('gmodule-no-export-2.0')

gtk3              = dependency('gtk+-3.0',           version: '>=3.16.10')

harfbuzz          = dependency('harfbuzz',           version: '>=0.9.19')
lcms              = dependency('lcms2',              version: '>=2.8')

libmypaint        = dependency('libmypaint',         version: '>=1.3.0')

352
mypaint_brushes   = dependency('mypaint-brushes-1.0', version: '>=1.3.0')
Salamandar's avatar
Salamandar committed
353

354 355 356 357 358
if relocatable_bundle
  mypaint_brushes_dir = '${gimp_installation_dir}'/'share'/'mypaint-data'/'1.0'/'brushes'
else
  mypaint_brushes_dir = mypaint_brushes.get_pkgconfig_variable('brushesdir')
endif
Salamandar's avatar
Salamandar committed
359

360
conf.set_quoted('MYPAINT_BRUSHES_DIR', mypaint_brushes_dir)
Salamandar's avatar
Salamandar committed
361 362 363 364 365 366 367 368 369 370 371

pangocairo        = dependency('pangocairo',         version: '>=1.29.4')
pangoft2          = dependency('pangoft2',           version: '>=1.29.4')
rsvg              = dependency('librsvg-2.0',        version: '>=2.40.6')

conf.set('PANGO_DISABLE_DEPRECATED',pangocairo.version().version_compare('<1.43'))


################################################################################
# Check for GLib Networking

372 373 374 375 376
glib_networking_works_run=false
if meson.is_cross_build() and not meson.has_exe_wrapper()
    # Cross-compilation without run capability: we won't be able to
    # check networking support.
    glib_networking_works = true
377
    glib_warning = '''
378 379
      Test for glib-networking cannot be performed while cross-compiling,
      unless you set an `exe_wrapper` binary in your toolchain file.
Salamandar's avatar
Salamandar committed
380 381 382 383 384
      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.
385 386 387
    '''
    warning(glib_warning)
    warnings += glib_warning
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
else # not meson.is_cross_build() or meson.has_exe_wrapper()
    glib_networking_works_run = cc.run(
      '''#include <gio/gio.h>
      int main() {
        return !g_tls_backend_supports_tls (g_tls_backend_get_default ());
      }''',
      dependencies: gio,
    )
    glib_networking_works = (glib_networking_works_run.compiled() and
                             glib_networking_works_run.returncode() == 0)
    if not glib_networking_works and meson.is_cross_build()
        # Since cross-platform test runs may be unreliable, let's be
        # flexible and pass the test with a warning.
        glib_networking_works = true
        glib_warning = '''
      The cross-platform test for glib-networking failed, using the
      `exe_wrapper` set in your toolchain file.
      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.
        '''
        warning(glib_warning)
        warnings += glib_warning
    endif
endif

if not glib_networking_works
  error('Test for glib-networking failed. This is required.')
Salamandar's avatar
Salamandar committed
418 419 420 421 422
endif

################################################################################
# Check if Pango is built with a recent fontconfig

Jehan's avatar
Jehan committed
423
pango_check = cc.links(
Salamandar's avatar
Salamandar committed
424 425 426 427 428 429 430 431
  '''#include <fontconfig/fontconfig.h>
  int main() {
    FcObjectSet *os; os = FcObjectSetBuild (FC_FAMILY, FC_WIDTH);
  }''',
  dependencies: fontconfig,
)

if not pango_check
432
  pango_warning = '\n  *** '.join([
Salamandar's avatar
Salamandar committed
433 434 435 436 437 438 439 440 441 442
  '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.',
443 444 445
  ])
  warning(pango_warning)
  warnings += pango_warning
Salamandar's avatar
Salamandar committed
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480
endif

################################################################################
# Optional Dependencies

libsocket         = cc.find_library('socket', required: false)
conf.set('HAVE_LIBSOCKET', libsocket.found())

################################################################################
# Check for extension support

appstream_glib = dependency('appstream-glib',     version: '>=0.7.7')

libarchive = dependency('libarchive')


################################################################################
# Check for debug console (Win32)

if platform_windows
  conf.set('ENABLE_WIN32_DEBUG_CONSOLE', get_option('win32-debug-console'))
endif

################################################################################
# Check for 32-bit DLLs (Win32 64-bit)

if platform_windows and arch_x86_64
  conf.set_quoted('WIN32_32BIT_DLL_FOLDER', get_option('win32-32bits-dll-folder'))
endif

################################################################################
# Check for detailed backtraces support

## Check for libbacktrace

481 482 483 484
if get_option('libbacktrace')
  libbacktrace = cc.find_library('backtrace', required: false)

  if libbacktrace.found()
Jehan's avatar
Jehan committed
485
    libbacktrace_links = cc.links('''
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501
        #include <stddef.h>
        #include <backtrace.h>
        #include <backtrace-supported.h>

        #if ! BACKTRACE_SUPPORTED
        #   error ! BACKTRACE_SUPPORTED
        #endif

        int main() {
          (void) backtrace_create_state (NULL, 0, NULL, NULL);
          return 0;
        }
      ''',
      dependencies: libbacktrace,
    )

Jehan's avatar
Jehan committed
502
    if not libbacktrace_links
503 504 505 506 507 508 509 510 511 512 513
      warning(
        'libbacktrace was found, but the test compilation failed.\n' +
        'You can find more info in meson-logs/meson-logs.txt.'
      )
      libbacktrace = no_dep
    endif

  endif
else
  libbacktrace = no_dep
endif
Salamandar's avatar
Salamandar committed
514 515 516 517 518 519 520 521 522 523 524 525 526
conf.set('HAVE_LIBBACKTRACE', libbacktrace.found())

## Check for libunwind
libunwind = ( get_option('libunwind')
  ? dependency('libunwind', version: '>=1.1.0', required: false)
  : no_dep
)
conf.set('HAVE_LIBUNWIND', libunwind.found())


## Check for Dr. Mingw
drmingw = no_dep
if platform_windows
Jehan's avatar
Jehan committed
527
  exchndl = cc.find_library('exchndl', required: false)
Salamandar's avatar
Salamandar committed
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783
  exchndl_fn = cc.has_function('ExcHndlSetLogFileNameA', dependencies: exchndl)
  if exchndl.found() and exchndl_fn
    drmingw = declare_dependency(dependencies: exchndl)
  endif
endif
conf.set('HAVE_EXCHNDL', drmingw.found())


detailed_backtraces = (
  libbacktrace.found() or
  libunwind.found() or
  drmingw.found()
)

################################################################################
# Check for x11 support

x11_target = gtk3.get_pkgconfig_variable('targets').contains('x11')

x11   = x11_target ? dependency('x11')    : no_dep
xmu   = x11_target ? dependency('xmu')    : no_dep
xext  = x11_target ? dependency('xext')   : no_dep
xfixes= x11_target ? dependency('xfixes') : no_dep
x11_deps = [ x11, xmu, xext, xfixes ]
conf.set('HAVE_XFIXES', xfixes.found())

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 : [ 'XmuClientWindow', 'XShapeGetRectangles', ]
    if not cc.has_function(function, dependencies: [ xext, xmu ])
      error('x11 install does not provide required function ' + function)
    endif
  endforeach
endif
conf.set('HAVE_X11_EXTENSIONS_SHAPE_H', x11_target and cc.has_header('X11/extensions/shape.h'))
conf.set('HAVE_X11_XMU_WINUTIL_H',      x11_target and cc.has_header('X11/Xmu/WinUtil.h'))


# Features requiring x11

have_doc_shooter= x11_target

if get_option('print').disabled()
  have_print = false
elif get_option('print').enabled() and not x11_target
  error('Printing requires x libs')
else
  have_print = x11_target
endif

if get_option('screenshot').disabled()
  have_screenshot = false
elif get_option('screenshot').enabled() and not x11_target
  error('Printing requires x libs')
else
  have_screenshot = x11_target
endif

################################################################################
# Plugins (optional dependencies)

# The list of MIME types that are supported by plug-ins
MIMEtypes = [
  'image/bmp',
  'image/g3fax',
  'image/gif',
  'image/svg+xml',
  'image/x-compressed-xcf',
  'image/x-fits',
  'image/x-gimp-gbr',
  'image/x-gimp-gih',
  'image/x-gimp-pat',
  'image/x-pcx',
  'image/x-portable-anymap',
  'image/x-portable-bitmap',
  'image/x-portable-graymap',
  'image/x-portable-pixmap',
  'image/x-psd',
  'image/x-sgi',
  'image/x-tga',
  'image/x-xbitmap',
  'image/x-xcf',
  'image/x-xwindowdump',
]



libtiff = dependency('libtiff-4', required: get_option('tiff'))
if libtiff.found()
  MIMEtypes += 'image/tiff'
endif


libjpeg = dependency('libjpeg', required: get_option('jpeg'))
conf.set('HAVE_LIBJPEG', libjpeg.found())
if libjpeg.found()
  MIMEtypes += 'image/jpeg'
endif


zlib = dependency('zlib')
MIMEtypes += 'image/x-psp'

bz2 = cc.find_library('bz2')

liblzma = dependency('liblzma', version: '>=5.0.0')


ghostscript = cc.find_library('gs', required: get_option('ghostscript'))
if ghostscript.found()
  MIMEtypes += 'application/postscript'
else
  ghostscript = disabler()
endif


libpng = dependency('libpng', version: '>=1.6.25', required: get_option('png'))
if libpng.found()
  MIMEtypes += [ 'image/png', 'image/x-icon']
endif


libmng = cc.find_library('mng', required: get_option('mng'))

libaa = cc.find_library('aa', required: get_option('aa'))

libxpm = dependency('xpm', required: get_option('xpm'))
if libxpm.found()
  MIMEtypes += 'image/x-xpixmap'
endif


openexr = dependency('OpenEXR', version: '>=1.6.1', required: get_option('openexr'))
if openexr.found()
  MIMEtypes += 'image/x-exr'
endif

webp_libs = [
  dependency('libwebp',     version: '>=0.6.0', required: get_option('webp')),
  dependency('libwebpmux',  version: '>=0.6.0', required: get_option('webp')),
  dependency('libwebpdemux',version: '>=0.6.0', required: get_option('webp')),
]
webp_found = true
foreach lib : webp_libs
  webp_found = webp_found and  lib.found()
endforeach

if webp_found
  MIMEtypes += 'image/x-webp'
endif


libheif = dependency('libheif', version: '>=1.3.2', required: get_option('heif'))
conf.set('HAVE_LIBHEIF_4_1_0', libheif.version().version_compare('>=1.4.0'))

if libheif.found()
  MIMEtypes += [
    'image/heif',
    'image/heic',
  ]
endif

webkit = dependency('webkit2gtk-4.0', version: '>=2.20.3', required: get_option('webkit'))
conf.set('HAVE_WEBKIT', webkit.found())


if get_option('poppler')
  poppler = [
    dependency('poppler-glib', version: '>=0.69.0'),
    dependency('poppler-data', version: '>=0.4.9'),
  ]
else
  poppler = no_dep
endif


cairopdf = dependency('cairo-pdf', version: '>=1.12.2', required: get_option('cairo-pdf'))

# PDF import support is a granted feature.
MIMEtypes += 'application/pdf'

wmf = dependency('libwmf', version: '>=0.2.8', required: get_option('wmf'))
if wmf.found()
  MIMEtypes += 'image/x-wmf'
endif


openjpeg = dependency('libopenjp2', version: '>=2.1.0', required: get_option('jpeg2000'))
if openjpeg.found()
  MIMEtypes += [ 'image/jp2', 'image/jpeg2000', 'image/jpx', ]
endif


xmc = dependency('xcursor', required: get_option('xcursor'))
if xmc.found()
  MIMEtypes += 'image/x-xcursor'
endif


alsa = dependency('alsa', version: '>=1.0.0', required: get_option('alsa'))
conf.set('HAVE_ALSA', alsa.found())


if get_option('linux-input').disabled()
  have_linuxinput = false
elif get_option('linux-input').enabled() and not cc.has_header('linux/input.h')
  error('linux/input.h header not found.')
else
  have_linuxinput = x11_target
endif

# DirectX DirectInput
directx = no_dep
directx_sdk_path = get_option('directx-sdk-dir')
if directx_sdk_path != '' and platform_windows
  if directx_sdk_path.contains(' ') or directx_sdk_path.contains('\\')
    error('\n'.join([
      'The DirectX SDK path should be given :',
      '* without spaces (use MSys mounts)',
      '* with plain (forward) slashes only,'
    ]))
  endif

  directx = declare_dependency(
    link_with: cc.find_library('dxguid',
                  dirs:  directx_sdk_path / 'Lib' / 'x86'),
    include_directories: directx_sdk_path / 'Include',
  )
endif
conf.set('HAVE_DX_DINPUT', directx.found())

gudev = dependency('gudev-1.0', version: '>=167', required: get_option('gudev'))
conf.set('HAVE_LIBGUDEV', gudev.found())


################################################################################
# Email sending
email_message = false

sendmail_choice = get_option('with-sendmail')
if not [ '', 'false', 'no', ].contains(sendmail_choice)
  if [ 'true', 'yes' ].contains(sendmail_choice)
    sendmail_path = 'sendmail'
  else
    sendmail_path = sendmail_choice
  endif

  sendmail = find_program(sendmail_path, required: false)
  if sendmail.found()
    sendmail_path = sendmail.path()
  else
784 785 786
    mail_warning = 'Sendmail specified but not found. It should be installed at runtime!'
    warning(mail_warning)
    warnings += mail_warning
Salamandar's avatar
Salamandar committed
787 788 789 790 791 792 793 794 795 796
  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
797 798 799
    mail_warning = 'Xdg-email not found, but required at runtime for email sending.'
    warning(mail_warning)
    warnings += mail_warning
Salamandar's avatar
Salamandar committed
800 801 802 803 804 805 806 807 808
  endif

  email_message = '@0@ (@1@)'.format(true, xdg_email_path)
endif


################################################################################
# ISO codes

809 810 811 812 813 814
isocodes = dependency('iso-codes', required: false)
if isocodes.found()
  isocodes_prefix = isocodes.get_pkgconfig_variable('prefix')
  isocodes_location = isocodes_prefix / get_option('datadir') / 'xml' / 'iso-codes'
  isocodes_localedir= isocodes_prefix / get_option('datadir') / 'locale'
endif
Salamandar's avatar
Salamandar committed
815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834
conf.set('HAVE_ISO_CODES', isocodes.found())


################################################################################
# Program tools

perl = find_program('perl5', 'perl', 'perl5.005', 'perl5.004', 'perl')

## Python

# By default, we want packagers to install Python plug-ins to get the
# optimum experience. -Dpython=true will check for a Python 3
# interpreter and PyGObject, and warns without.
# It is up to the packager to ensure they are available at run time.
# This can be useful in particular when cross-compiling since anyway
# the interpreter is not useful at build time.

python3_required_version = '>=3.6.0'

if get_option('python') == 'never'
835
  python_warning = '''
Salamandar's avatar
Salamandar committed
836 837 838 839 840
    You disabled the installation of core Python plug-ins. This is discouraged
    as it won't provide the full GIMP experience.
    Note that you may install the Python plug-ins even if you have no Python
    interpreter at build-time by passing the configure option -Dpython=always.
    Just make sure that a Python @0@ interpreter is available at run-time.
841 842 843
  '''.format(python3_required_version)
  warning(python_warning)
  warnings += python_warning
Salamandar's avatar
Salamandar committed
844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877

  have_python = false

else
  always_install = get_option('python') == 'always'

  python = pythonmod.find_installation('python3', required: false)

  python_found = (
    python.found() and
    python.language_version().version_compare(python3_required_version)
  )
  if python_found
    pygobject_found = run_command(
      python, '-c',
      '\n'.join([
        '''import sys, gi''',
        '''version = '@0@' '''.format('3.0'),
        '''sys.exit(gi.check_version(version))''',
      ]),
    ).returncode() == 0
    python_found = python_found and pygobject_found
  endif

  if (not python_found) and (not always_install)
    error('''
    Python @0@ or PyGObject was not found.
    Note that you may install the Python plug-ins even if you have no Python
    interpreter at build-time by passing the configure option -Dpython=always.
    Just make sure that a Python @0@ interpreter is available at run-time.
    '''.format(python3_required_version))
  endif

  if (not python_found) and (always_install)
878
    python_warning = '''
Salamandar's avatar
Salamandar committed
879 880 881 882
    Python @0@ or PyGObject was not found.
    Python plug-ins will be installed anyway but you should make sure that
    a compatible Python interpreter is available at installation, otherwise
    installed plug-ins won't be usable.
883 884 885
    '''.format(python3_required_version)
    warning(python_warning)
    warnings += python_warning
Salamandar's avatar
Salamandar committed
886 887 888 889 890 891 892 893
  endif

  have_python = python_found or always_install
endif

## Javascript

if get_option('javascript') == 'never'
894
  js_warning = '''
Salamandar's avatar
Salamandar committed
895 896 897 898 899
    You disabled the installation of core Javascript plug-ins. This is
    discouraged as it won't provide the full GIMP experience.
    Note that you may install the Javascript plug-ins even if you have no GJS
    interpreter at build-time by passing the configure option -Djavascript=always.
    Just make sure that the GJS interpreter is available at run-time.
900 901 902
  '''
  warning(js_warning)
  warnings += js_warning
Salamandar's avatar
Salamandar committed
903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919
  have_javascript = false

else
  always_install = get_option('javascript') == 'always'

  gjs = find_program('gjs', required: false)

  if (not gjs.found()) and (not always_install)
    error('''
    GJS was not found.
    Note that you may install the Javascript plug-ins even if you have no GJS
    interpreter at build-time by passing the configure option -Djavascript=always.
    Just make sure that the GJS interpreter is available at run-time.
    ''')
  endif

  if (not gjs.found()) and (always_install)
920
    js_warning = '''
Salamandar's avatar
Salamandar committed
921 922 923 924
    GJS was not found.
    JavaScript plug-ins will be installed anyway but you should make sure that
    the JavaScript interpreter GJS is available at installation, otherwise
    installed plug-ins won't be usable.
925 926 927
    '''
    warning(js_warning)
    warnings += js_warning
Salamandar's avatar
Salamandar committed
928 929 930 931 932 933 934 935
  endif

  have_javascript = gjs.found() or always_install
endif

## Lua

if get_option('lua') == 'never'
936
  lua_warning = '''
Salamandar's avatar
Salamandar committed
937 938 939 940 941
    You disabled the installation of core Lua plug-ins. This is discouraged
    as it won't provide the full GIMP experience.
    Note that you may install the Lua plug-ins even if you have no Lua LGI
    interpreter at build-time by passing the configure option -Dlua=always.
    Just make sure that the Lua LGI interpreter is available at run-time.
942 943 944
  '''
  warning(lua_warning)
  warnings += lua_warning
Salamandar's avatar
Salamandar committed
945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961
  have_lua = false

else
  always_install = get_option('lua') == 'always'

  lua = find_program('luajit', required: false)

  if (not lua.found()) and (not always_install)
    error('''
    Luajit was not found.
    Note that you may install the Lua plug-ins even if you have no Lua LGI
    interpreter at build-time by passing the configure option -Dlua=always.
    Just make sure that the Lua LGI interpreter is available at run-time.
    ''')
  endif

  if (not lua.found()) and always_install
962
    lua_warning = '''
Salamandar's avatar
Salamandar committed
963 964 965 966
    Luajit was not found.
    Lua plug-ins will be installed anyway but you should make sure that
    luajit and LGI are available at installation, otherwise
    installed plug-ins won't be usable.
967 968 969
    '''
    warning(lua_warning)
    warnings += lua_warning
Salamandar's avatar
Salamandar committed
970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999
  endif

  have_lua = lua.found() or always_install
endif


# Check for GTK Mac Integration
if platform_osx and (gtk3.get_pkgconfig_variable('targets').contains('xquartz'))
  gtk3_macos = dependency('gtk-mac-integration', version: '>=2.0.0')
else
  gtk3_macos = no_dep
endif

# Check for XML tools
xmllint             = find_program('xmllint', required: false)
xsltproc            = find_program('xsltproc')
intltool_merge      = find_program('intltool-merge')
desktop_validate    = find_program('desktop-file-validate', required: false)

appstream_util = find_program('appstream-util', required: get_option('appdata-test'))

# Check for doc generation tools
have_gtk_doc = get_option('gtk-doc')

# Check for vector icons
have_vector_icons = get_option('vec-icons')
if have_vector_icons
  # shared-mime-info is needed to correctly detect SVG files
  # (except on Windows, apparently).
  if platform_windows
1000
    vec_warning = '''
Salamandar's avatar
Salamandar committed
1001 1002 1003 1004
      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.
1005 1006 1007
    '''
    warning(vec_warning)
    warnings += vec_warning
Salamandar's avatar
Salamandar committed
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078
  else
    shared_mime_info = dependency('shared-mime-info')
  endif
endif

xvfb_run = find_program('xvfb-run', required: get_option('xvfb-run'))
conf.set('HAVE_XVFB_RUN', xvfb_run.found())

# Set bug report URL

# Allowing third-party packagers to set their own bugtracker URL, in
# order to filter first packaging bugs from core bugs.
bug_report_url = get_option('bug-report-url')

if bug_report_url == ''
  message('''
    NOTE: if you plan on packaging GIMP for distribution, it is recommended
    to override the bug report URL with option:
      -Dbug-report-url=https://example.com/
    so that you can filter packaging bugs from core bugs before reporting upstream.
  ''')

  bug_report_url = project_url_issues
endif
conf.set_quoted('PACKAGE_BUGREPORT', project_url_issues)
conf.set_quoted('BUG_REPORT_URL', bug_report_url)

# Default ICC directory #

# This is necessary because some Unix systems may have a different
# standard path for color profiles. And in particular, sandbox builds
# might mount the host system at a different root. This is for
# instance the case of flatpak which mount the host root at /run/host/.

# if not (platform_osx or platform_windows)

icc_directory = get_option('icc-directory')
if icc_directory == ''
  icc_directory = '/usr/share/color/icc'
endif
conf.set_quoted('COLOR_PROFILE_DIRECTORY', icc_directory)

# endif

enable_default_bin = get_option('enable-default-bin')
enable_console_bin = get_option('enable-console-bin')


# Possibly change default gimpdir from $XDG_CONFIG_HOME/GIMP/gimp_user_version
gimpdir = get_option('gimpdir')
if gimpdir == ''
  # Default value
  gimpdir = meson.project_name().to_upper()
endif

project_subdir = meson.project_name() / gimp_app_version
gimpdatadir    = get_option('datadir')    / project_subdir
gimpplugindir  = get_option('libdir')     / project_subdir
gimpsysconfdir = get_option('sysconfdir') / project_subdir
gimpmanpagedir = gimpdir
localedir      = get_option('datadir') / 'locale'



# Check for internal tools
defcheck            = find_program('tools'/'defcheck.py')
extract_vector_icon = find_program('tools'/'extract-vector-icon.sh')
generate_changelog  = find_program('tools'/'generate_changelog.sh')
generate_news       = find_program('tools'/'generate-news')
gimppath2svg        = find_program('tools'/'gimppath2svg.py')
module_dependencies = find_program('tools'/'module-dependencies.py')
1079
meson_install_subdir= find_program('tools'/'meson_install_subdir.py')
Salamandar's avatar
Salamandar committed
1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127

gimp_mkenums        = find_program('tools'/'gimp-mkenums')
gimp_mkenums_custom_target_commonargs = [
  '--fprod','/* enumerations from "@basename@" */\n',
  '--vhead','GType\n'+
            '@enum_name@_get_type (void)\n'+
            '{\n'+
            '  static const G@Type@Value values[] =\n'+
            '  {',
  '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
  '--vtail','    { 0, NULL, NULL }\n'+
            '  };\n',
  '--dhead','  static const Gimp@Type@Desc descs[] =\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 },\n'+
            '    @endif@',
  '--dtail','    { 0, NULL, NULL }\n'+
            '  };\n'+
            '\n'+
            '  static GType type = 0;\n'+
            '\n'+
            '  if (G_UNLIKELY (! type))\n'+
            '    {\n'+
            '      type = g_@type@_register_static ("@EnumName@", values);\n'+
            '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
            '      gimp_@type@_set_value_descriptions (type, descs);\n'+
            '    }\n'+
            '\n'+
            '  return type;\n'+
            '}\n',
  '@INPUT@',
]


conf.set('ENABLE_NLS',   true)
conf.set('HAVE_GETTEXT', true)

# localedir = get_option('prefix') / get_option('localedir')


################################################################################
luzpaz's avatar
luzpaz committed
1128
# Miscellaneous configuration
Salamandar's avatar
Salamandar committed
1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321

#     #
##   ## #  ####   ####
# # # # # #      #    #
#  #  # #  ####  #
#     # #      # #
#     # # #    # #    #
#     # #  ####   ####



# Enable support for multiprocessing
conf.set10('ENABLE_MP', get_option('enable-multiproc'))

# Check for available functions
foreach fn : [
    { 'm': 'HAVE_ALLOCA',                   'v': 'alloca', },
    { 'm': 'HAVE_DCGETTEXT',                'v': 'dcgettext', },
    { 'm': 'HAVE_DIFFTIME',                 'v': 'difftime', },
    { 'm': 'HAVE_FINITE',                   'v': 'finite', },
    { 'm': 'HAVE_FINITE',                   'v': 'finite', },
    { 'm': 'HAVE_FSYNC',                    'v': 'fsync', },
    { 'm': 'HAVE_GETADDRINFO',              'v': 'getaddrinfo', },
    { 'm': 'HAVE_GETNAMEINFO',              'v': 'getnameinfo', },
    { 'm': 'HAVE_GETTEXT',                  'v': 'gettext', },
    { 'm': 'HAVE_ISFINITE',                 'v': 'isfinite', },
    { 'm': 'HAVE_MMAP',                     'v': 'mmap', },
    { 'm': 'HAVE_RINT',                     'v': 'rint', },
    { 'm': 'HAVE_THR_SELF',                 'v': 'thr_self', },
    { 'm': 'HAVE_VFORK',                    'v': 'vfork', },
  ]
  conf.set(fn['m'],
    cc.has_function(fn['v']) ? 1 : false
  )
endforeach

conf.set('HAVE_BIND_TEXTDOMAIN_CODESET',
  cc.has_header_symbol('libintl.h', 'bind_textdomain_codeset') ? 1 : false
)
conf.set('HAVE_VPRINTF',
  cc.has_header_symbol('libintl.h', 'vprintf') ? 1 : false
)


# Check for available headers
foreach header : [
    { 'm': 'HAVE_ALLOCA_H',       'v': 'alloca.h' },
    { 'm': 'HAVE_DLFCN_H',        'v': 'dlfcn.h' },
    { 'm': 'HAVE_EXECINFO_H',     'v': 'execinfo.h' },
    { 'm': 'HAVE_FCNTL_H',        'v': 'fcntl.h' },
    { 'm': 'HAVE_IEEEFP_H',       'v': 'ieeefp.h' },
    { 'm': 'HAVE_INTTYPES_H',     'v': 'inttypes.h' },
    { 'm': 'HAVE_LOCALE_H',       'v': 'locale.h' },
    { 'm': 'HAVE_MATH_H',         'v': 'math.h' },
    { 'm': 'HAVE_MEMORY_H',       'v': 'memory.h' },
    { 'm': 'HAVE_STDINT_H',       'v': 'stdint.h' },
    { 'm': 'HAVE_STDLIB_H',       'v': 'stdlib.h' },
    { 'm': 'HAVE_STRING_H',       'v': 'string.h' },
    { 'm': 'HAVE_STRINGS_H',      'v': 'strings.h' },
    { 'm': 'HAVE_SYS_PARAM_H',    'v': 'sys/param.h' },
    { 'm': 'HAVE_SYS_SELECT_H',   'v': 'sys/select.h' },
    { 'm': 'HAVE_SYS_STAT_H',     'v': 'sys/stat.h' },
    { 'm': 'HAVE_SYS_THR_H',      'v': 'sys/thr.h' },
    { 'm': 'HAVE_SYS_TIME_H',     'v': 'sys/time.h' },
    { 'm': 'HAVE_SYS_TIMES_H',    'v': 'sys/times.h' },
    { 'm': 'HAVE_SYS_TYPES_H',    'v': 'sys/types.h' },
    { 'm': 'HAVE_SYS_WAIT_H',     'v': 'sys/wait.h' },
    { 'm': 'HAVE_UNISTD_H',       'v': 'unistd.h' },
    { 'm': 'HAVE_MMAN_H',         'v': 'sys/mman.h' },
    { 'm': 'HAVE_IPC_H',          'v': 'sys/ipc.h' },
    { 'm': 'HAVE_SHM_H',          'v': 'sys/shm.h' },
  ]
  conf.set(header['m'], cc.has_header(header['v']) ? 1 : false)
endforeach



################################################################################
# Check for shared memory handling

shmem_choice = get_option('shmem-type')
if shmem_choice == 'auto'
  shmem_choice = 'sysv'

  # MacOS X has broken SysV shm
  if platform_osx
    shmem_choice = 'posix'
  endif
  if platform_windows
    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_windows
  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) { }''')
)




################################################################################
# Set/regroup common CFlags for subdirs

######
#     # ###### ###### # #    # ######  ####
#     # #      #      # ##   # #      #
#     # #####  #####  # # #  # #####   ####
#     # #      #      # #  # # #           #
#     # #      #      # #   ## #      #    #
######  ###### #      # #    # ######  ####

# Compiler
conf.set_quoted('CC',             cc.get_id())
conf.set_quoted('CC_VERSION',     cc.version())

# Names
conf.set_quoted('GIMP_PACKAGE',   meson.project_name())
conf.set_quoted('PACKAGE_NAME',   meson.project_name())
conf.set_quoted('PACKAGE_STRING', package_string)
conf.set_quoted('GIMP_COMMAND',   gimp_command)

# Versions
conf.set_quoted('GIMP_APP_VERSION_STRING',gimp_app_version)
conf.set_quoted('GIMP_APP_VERSION',       gimp_app_version)
conf.set_quoted('GIMP_USER_VERSION',      gimp_app_version)

conf.set_quoted('GIMP_DATA_VERSION',      gimp_app_version)
conf.set_quoted('GIMP_PLUGIN_VERSION',    gimp_app_version)
conf.set_quoted('GIMP_SYSCONF_VERSION',   gimp_app_version)
conf.set_quoted('GIMP_TOOL_VERSION',      gimp_app_version)
conf.set_quoted('GIMP_PKGCONFIG_VERSION', gimp_api_version)

# Directories
conf.set_quoted('PREFIX',          prefix)
conf.set_quoted('EXEC_PREFIX',     prefix)
conf.set_quoted('GIMPDIR',         gimpdir)
conf.set_quoted('GIMPSYSCONFDIR',  prefix / gimpsysconfdir)
conf.set_quoted('GIMPDATADIR',     prefix / gimpdatadir)
conf.set_quoted('GIMPPLUGINDIR',   prefix / gimpplugindir)
conf.set_quoted('PLUGINDIR',       prefix / gimpplugindir)
conf.set_quoted('LOCALEDIR',       prefix / localedir)

conf.set_quoted('LOCALSTATEDIR',   prefix / get_option('localstatedir'))
# /usr/com?
conf.set_quoted('SHAREDSTATEDIR',  prefix / get_option('sharedstatedir'))
conf.set_quoted('SYSCONFDIR',      prefix / get_option('sysconfdir'))
conf.set_quoted('BINDIR',          prefix / get_option('bindir'))
conf.set_quoted('DATAROOTDIR',     prefix / get_option('datadir'))
conf.set_quoted('INFODIR',         prefix / get_option('infodir'))
conf.set_quoted('LIBDIR',          prefix / get_option('libdir'))
conf.set_quoted('LIBEXECDIR',      prefix / get_option('libexecdir'))
conf.set_quoted('MANDIR',          prefix / get_option('mandir'))
conf.set_quoted('SBINDIR',         prefix / get_option('sbindir'))
conf.set_quoted('SYSDATADIR',      prefix / get_option('datadir'))

# Third-party/Misc
1322 1323 1324 1325
if isocodes.found()
  conf.set_quoted('ISO_CODES_LOCATION',    isocodes_location)
  conf.set_quoted('ISO_CODES_LOCALEDIR',   isocodes_localedir)
endif
Salamandar's avatar
Salamandar committed
1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422


if platform_osx
  # libgimp_cflags += '-xobjective-c'
  # libgimp_lflags += ['-framework', 'Cocoa']
endif


################################################################################
# Generate files

  #####                                   #######
 #     #  ####  #    # ###### #  ####     #       # #      ######  ####
 #       #    # ##   # #      # #    #    #       # #      #      #
 #       #    # # #  # #####  # #         #####   # #      #####   ####
 #       #    # #  # # #      # #  ###    #       # #      #           #
 #     # #    # #   ## #      # #    #    #       # #      #      #    #
  #####   ####  #    # #      #  ####     #       # ###### ######  ####



gitversion_h1 = vcs_tag(
  input : 'app/git-version.h.in',
  output: 'git-version.h.in.1',
  command: [ 'git', 'describe', '--always', ],
  replace_string: '@GIMP_GIT_VERSION@',
  fallback: '',
)
gitversion_h2 = vcs_tag(
  input : gitversion_h1,
  output: 'git-version.h.in.2',
  command: [ 'git', 'rev-parse', '--short', 'HEAD', ],
  replace_string: '@GIMP_GIT_VERSION_ABBREV@',
  fallback: '',
)
gitversion_h = vcs_tag(
  input : gitversion_h2,
  output: 'git-version.h',
  command: [ 'git', 'log', '-n1', '--date=format:%Y', '--pretty=%cd', ],
  replace_string: '@GIMP_GIT_LAST_COMMIT_YEAR@',
  fallback: '',
)


install_conf = configuration_data()
install_conf.set('GIMP_APP_VERSION', gimp_app_version)
install_conf.set('GIMP_PKGCONFIG_VERSION', gimp_version)
install_conf.set('GIMP_VERSION', gimp_version)
install_conf.set('APPSTREAM_GLIB_REQUIRED_VERSION', appstream_glib.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('GEXIV2_REQUIRED_VERSION',       gexiv2.version())
install_conf.set('GLIB_REQUIRED_VERSION',         glib        .version())
install_conf.set('GTK_REQUIRED_VERSION',          gtk3        .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('LIBHEIF_REQUIRED_VERSION',      libheif     .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('OPENJPEG_REQUIRED_VERSION',     openjpeg.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('PYTHON3_REQUIRED_VERSION',      '3.6.0')
install_conf.set('RSVG_REQUIRED_VERSION',         rsvg        .version())
install_conf.set('WEBKITGTK_REQUIRED_VERSION',    webkit      .version())
install_conf.set('WEBP_REQUIRED_VERSION',         webp_libs[0].version())
install_conf.set('WMF_REQUIRED_VERSION',          wmf         .version())
install_conf.set('XGETTEXT_REQUIRED_VERSION', '0.19')

configure_file(
  input : 'INSTALL.in',
  output: 'INSTALL',
  configuration: install_conf
)


configure_file(
  output: 'config.h',
  configuration: conf
)
compiler_args +='-DHAVE_CONFIG_H'


add_project_arguments(compiler_args, language: [ 'c', 'cpp' ])
add_project_link_arguments(linker_args, language: [ 'c', 'cpp' ])

################################################################################
luzpaz's avatar
luzpaz committed
1423
# Miscellaneous targets
Salamandar's avatar
Salamandar committed
1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616


 #     #                    #######
 ##   ## #  ####   ####        #      ##   #####   ####  ###### #####  ####
 # # # # # #      #    #       #     #  #  #    # #    # #        #   #
 #  #  # #  ####  #            #    #    # #    # #      #####    #    ####
 #     # #      # #            #    ###### #####  #  ### #        #        #
 #     # # #    # #    #       #    #    # #   #  #    # #        #   #    #
 #     # #  ####   ####        #    #    # #    #  ####  ######   #    ####



custom_target('AUTHORS',
  input : [ 'authors.xsl', 'authors.xml', ],
  output: 'AUTHORS',
  command: [
    xsltproc,
    '-o', '@OUTPUT@',
    '@INPUT@',
  ],
  build_by_default: false,
)
custom_target('authors.md',
  input : [ 'authors4gimp-web.xsl', 'authors.xml', ],
  output: 'authors.md',
  command: [
    xsltproc,
    '--stringparam', 'today', '`date --iso-8601=seconds`',
    '-o', '@OUTPUT@',
    '@INPUT@',
  ],
  build_by_default: false,
)

if xmllint.found()
  run_target('validate-authors',
    command: [
      xmllint,
      '--noout',
      '--valid', 'authors.xml',
    ],
  )
endif

if have_python
  # TODO this python script is waiting for autotools directory/files structure
  custom_target('check-defs',
    input : [ ],
    output: [ 'check-defs', ],
    command: [
      find_program(meson.source_root() / 'tools' / 'defcheck.py'),
      meson.source_root(),
    ],
    build_by_default: false,
  )
endif

custom_target('Changelog',
  input : [ ],
  output: [ 'Changelog', ],
  command: [
    generate_changelog,
    meson.source_root(),
    '@OUTPUT@'
  ],
  build_by_default: false,
)


################################################################################
# Subdirs


rootInclude = include_directories('.')
appInclude  = include_directories('app')

if platform_windows
  subdir('build/windows')

  if get_option('windows-installer')
    subdir('po-windows-installer')
    subdir('build/windows/installer')
  endif
endif

# Tools
subdir('libgimpbase')
subdir('tools')

# Translations
subdir('po')
subdir('po-libgimp')
subdir('po-plug-ins')
subdir('po-python')
subdir('po-script-fu')
subdir('po-tags')
subdir('po-tips')
# Data / Desktop / xml files
subdir('cursors')
subdir('data')
subdir('desktop')
subdir('etc')
subdir('icons')
subdir('m4macros')
subdir('menus')
subdir('themes')

# Libraries (order here is important!)
subdir('libgimpcolor')
subdir('libgimpmath')
subdir('libgimpconfig')
subdir('libgimpmodule')
subdir('libgimpthumb')
subdir('libgimpwidgets')
subdir('libgimp')

# Executables, plugins
subdir('modules')
subdir('plug-ins')
subdir('app')
subdir('pdb')
subdir('app-tools')

# Docs
subdir('docs')
if have_gtk_doc
  subdir('devel-docs')
endif



pkgconfig.generate(libgimp,
  filebase: 'gimp-' + gimp_api_version,
  name: prettyname,
  description: 'GIMP Library',
  version: gimp_version,
  requires: [
    gdk_pixbuf,
    cairo,
    gegl,
  ],
  libraries: [
    libgimpbase,
    libgimpcolor,
    libgimpconfig,
    libgimpmath,
  ],
  subdirs: [
    gimp_api_name,
  ],
  variables: [
    'datarootdir='    +'${prefix}/'+ get_option('datadir'),
    'gimpdatadir='    +'${prefix}/'+ gimpdatadir,
    'gimplibdir='     +'${prefix}/'+ gimpplugindir,
    'gimpsysconfdir=' + gimpsysconfdir,
    'gimplocaledir='  +'${prefix}/'+ localedir,
  ],
)

pkgconfig.generate(libgimpthumb,
  filebase: 'gimpthumb-' + gimp_api_version,
  name: 'GIMP Thumb',
  description: 'GIMP Thumbnail Library',
  version: gimp_version,
  requires: [
    libgimp,
    gdk_pixbuf,
  ],
  subdirs: [
    gimp_api_name,
  ],
)

pkgconfig.generate(libgimpui,
  filebase: 'gimpui-' + gimp_api_version,
  name: 'GIMP UI',
  description: 'GIMP User Interface Library',
  version: gimp_version,
  requires: [
    libgimp,
    gtk3,
  ],
  libraries: [
    libgimpwidgets,
    libgimpmodule,
  ],
  subdirs: [
    gimp_api_name,
  ],
)



1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631
################################################################################
# Subdir installations

foreach dir : [
    { 'dir': 'libgimp',   'deps': libgimp},
    { 'dir': 'plug-ins', },
  ]
  run_target('install-' + dir.get('dir'),
    command: [
      meson_install_subdir, '-v', dir.get('dir')
    ],
    depends: dir.get('deps', [])
  )
endforeach

Salamandar's avatar
Salamandar committed
1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681
################################################################################

final_message = [
'''Extra Binaries:''',
'''  gimp-console:        @0@'''.format(enable_console_bin),
'',
'''Optional Features:''',
'''  Language selection:  @0@'''.format(isocodes.found()),
'''  Vector icons:        @0@'''.format(have_vector_icons),
'''  Dr. Mingw (Win32):   @0@'''.format(drmingw.found()),
'''  Relocatable Bundle:  @0@'''.format(relocatable_bundle),
'''  Default ICC directory:     @0@'''.format(icc_directory),
'''  32-bit DLL folder (Win32): @0@'''.format(get_option('win32-32bits-dll-folder')),
'''  Detailed backtraces:       @0@'''.format(detailed_backtraces),
'',
'''Optional Plug-Ins:''',
'''  Ascii Art:           @0@'''.format(libaa.found()),
'''  Ghostscript:         @0@'''.format(ghostscript.found()),
'''  Help Browser:        @0@'''.format(webkit.found()),
'''  JPEG 2000:           @0@'''.format(openjpeg.found()),
'''  MNG:                 @0@'''.format(libmng.found()),
'''  OpenEXR:             @0@'''.format(openexr.found()),
'''  WebP:                @0@'''.format(webp_found),
'''  Heif:                @0@'''.format(libheif.found()),
'''  PDF (export):        @0@'''.format(cairopdf.found()),
'''  Print:               @0@'''.format(have_print),
'''  Python 3 plug-ins:   @0@'''.format(have_python),
'''  Javascript plug-ins: @0@'''.format(have_javascript),
'''  Lua plug-ins:        @0@'''.format(have_lua),
'''  TWAIN (Win32):       @0@'''.format(platform_windows),
'''  Webpage:             @0@'''.format(webkit.found()),
'''  WMF:                 @0@'''.format(wmf.found()),
'''  X11 Mouse Cursor:    @0@'''.format(xmc.found()),
'''  XPM:                 @0@'''.format(libxpm.found()),
'''  Email:               @0@'''.format(email_message),
'',
'''Optional Modules:''',
'''  ALSA (MIDI Input):   @0@'''.format(alsa.found()),
'''  Linux Input:         @0@ (GUdev support: @1@)'''
                                .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()),
'',
'''Bug report URL: @0@'''.format(bug_report_url),
]

message('\n'.join(final_message))
1682 1683

if warnings.length() > 0
luzpaz's avatar
luzpaz committed
1684
  warning('Warnings occurred during configuration')
1685 1686 1687 1688
  foreach warning : warnings
    warning(warning)
  endforeach
endif