easyblock = 'Bundle'

name = 'X11'
version = '20170314'
versionsuffix = '-test'

homepage = 'https://www.x.org'
description = "The X Window System (X11) is a windowing system for bitmap displays"

toolchain = SYSTEM

source_urls = [
    XORG_LIB_SOURCE,
    XORG_PROTO_SOURCE,
    'http://xcb.freedesktop.org/dist/',
    'http://xkbcommon.org/download/',
    'http://cgit.freedesktop.org/xorg/util/macros/snapshot',
    'http://www.x.org/pub/individual/data',
    'https://www.x.org/pub/individual/font',
    'https://www.x.org/pub/individual/app',
    'https://www.x.org/pub/individual/xserver'
]

dependencies = [
    ('bzip2', '1.0.6'),
    ('fontconfig', '2.12.1', '-libpng-1.6.29'),
    ('freetype', '2.7.1', '-libpng-1.6.29'),
    ('zlib', '1.2.11'),
    ('Mesa', '17.0.2', '', ('intel', '2017a')),
    ('nettle', '3.3', '', ('intel', '2017a')),
    #    ('XKeyboardConfig', '2.21'),
]
builddependencies = [
    ('Autotools', '20150215'),
    ('Bison', '3.0.4'),
    ('gettext', '0.19.8.1'),
    ('pkg-config', '0.29.2'),
    # use same local_binutils version that was used when building GCCcore toolchain
    ('binutils', '2.27', '', True),
]

default_easyblock = 'ConfigureMake'

common_specs = {
    'sources': [SOURCE_TAR_GZ],
    'start_dir': '%(name)s-%(version)s',
    'parallel': '16',
}

server_specs = {
    'sources': [SOURCE_TAR_GZ],
    'start_dir': '%(name)s-%(version)s',
    'preconfigopts': 'export XSERVERCFLAGS_CFLAGS=" " && export XSERVERCFLAGS_LIBS=$EBROOTX11/lib &&',
    # --with-xkb-path=%(installdir)s/share/X11/xkb
    'configopts': '--disable-glamor --enable-suid-wrapper --disable-systemd-logind --with-xkb-path=/apps/all/X11/20170314-test/share/X11/xkb',
}


local_components = [
    ('xorg-macros', '1.19.1', {                             # 2017-01-29
        'sources': ['util-macros-%(version)s.tar.gz'],
        'start_dir': 'util-macros-%(version)s',
    }),
    ('libpthread-stubs', '0.4', common_specs),              # 2017-03-14
    ('bigreqsproto', '1.1.2', common_specs),                # 2012-03-23
    ('local_compositeproto', '0.4.2', common_specs),              # 2010-10-30
    ('damageproto', '1.2.1', common_specs),                 # 2010-10-30
    ('dmxproto', '2.3.1', common_specs),                    # 2011-01-06
    ('dri2proto', '2.8', common_specs),                     # 2012-07-11
    ('dri3proto', '1.0', common_specs),                     # 2013-11-01
    ('fixesproto', '5.0', common_specs),                    # 2011-03-08
    ('fontsproto', '2.1.3', common_specs),                  # 2014-04-14
    ('glproto', '1.4.17', common_specs),                    # 2013-12-10
    ('inputproto', '2.3.2', common_specs),                  # 2016-04-04
    ('kbproto', '1.0.7', common_specs),                     # 2015-05-01
    ('xkbdata', '1.0.1', common_specs),
    ('presentproto', '1.1', common_specs),                  # 2017-01-26
    ('randrproto', '1.5.0', common_specs),                  # 2015-05-17
    ('recordproto', '1.14.2', common_specs),                # 2012-03-23
    ('renderproto', '0.11.1', common_specs),                # 2010-08-10
    ('resourceproto', '1.2.0', common_specs),               # 2011-05-28
    ('scrnsaverproto', '1.2.2', common_specs),              # 2012-03-23
    ('videoproto', '2.3.3', common_specs),                  # 2016-03-11
    ('xcmiscproto', '1.2.2', common_specs),                 # 2012-03-23
    ('xextproto', '7.3.0', common_specs),                   # 2013-12-27
    ('xf86bigfontproto', '1.2.0', common_specs),            # 2009-08-27
    ('xf86dgaproto', '2.1', common_specs),                  # 2009-10-01
    ('xf86driproto', '2.1.1', common_specs),                # 2011-01-06
    ('xf86vidmodeproto', '2.3.1', common_specs),            # 2011-01-06
    ('xineramaproto', '1.2.1', common_specs),               # 2011-01-06
    ('xproto', '7.0.31', common_specs),                     # 2016-09-23
    ('libXau', '1.0.8', common_specs),                      # 2013-05-24
    ('libXdmcp', '1.1.2', common_specs),                    # 2015-03-21
    ('xcb-proto', '1.12', common_specs),                    # 2016-05-18
    ('libxcb', '1.12', common_specs),                       # 2016-05-18
    ('xtrans', '1.3.5', common_specs),                      # 2014-09-22
    ('libxkbcommon', '0.7.1', {                             # 2017-01-18
        'sources': ['libxkbcommon-%(version)s.tar.xz'],
        'start_dir': 'libxkbcommon-%(version)s',
    }),
    ('libX11', '1.6.5', common_specs),                      # 2017-02-26
    ('libXext', '1.3.3', common_specs),                     # 2014-07-24
    ('libFS', '1.0.7', common_specs),                       # 2015-05-01
    ('libICE', '1.0.9', common_specs),                      # 2014-06-07
    ('libSM', '1.2.2', common_specs),                       # 2013-09-08
    ('libXScrnSaver', '1.2.2', common_specs),               # 2012-03-08
    ('libXt', '1.1.5', common_specs),                       # 2015-05-01
    ('libXmu', '1.1.2', common_specs),                      # 2013-09-08
    ('libXpm', '3.5.12', common_specs),                     # 2016-12-15
    ('libXaw', '1.0.13', common_specs),                     # 2015-05-01
    ('libXfixes', '5.0.3', common_specs),                   # 2016-10-04
    ('libXlocal_composite', '0.4.4', common_specs),               # 2013-01-03
    ('libXrender', '0.9.10', common_specs),                 # 2016-10-04
    ('libXcursor', '1.1.14', common_specs),                 # 2013-05-30
    ('libXdamage', '1.1.4', common_specs),                  # 2013-01-03
    ('libfontenc', '1.1.3', common_specs),                  # 2015-05-01
    ('libXfont', '1.5.2', common_specs),                    # 2016-08-31
    ('libXfont2', '2.0.1', common_specs),                   # 2015-12-11
    ('libXft', '2.3.2', common_specs),                      # 2014-06-06
    ('libXi', '1.7.9', common_specs),                       # 2017-01-23
    ('libXinerama', '1.1.3', common_specs),                 # 2013-05-31
    ('libXrandr', '1.5.1', common_specs),                   # 2016-10-04
    ('libXres', '1.0.7', common_specs),                     # 2013-05-31
    ('libXtst', '1.2.3', common_specs),                     # 2016-10-04
    ('libXv', '1.0.11', common_specs),                      # 2016-10-04
    ('libXvMC', '1.0.10', common_specs),                    # 2016-10-04
    ('libXxf86dga', '1.1.4', common_specs),                 # 2013-05-31
    ('libXxf86vm', '1.1.4', common_specs),                  # 2015-02-24
    ('libdmx', '1.1.3', common_specs),                      # 2013-05-28
    ('libpciaccess', '0.13.4', common_specs),               # 2015-05-01
    ('libxkbfile', '1.0.9', common_specs),                  # 2015-05-01
    ('libxshmfence', '1.2', common_specs),                  # 2015-01-02
    ('xkblocal_comp', '1.4.0', common_specs),
    ('xcb-util', '0.4.0', common_specs),                    # 2014-10-15
    ('xcb-util-image', '0.4.0', common_specs),              # 2014-10-15
    ('xcb-util-keysyms', '0.4.0', common_specs),            # 2014-10-01
    ('xcb-util-renderutil', '0.3.9', common_specs),         # 2014-06-13
    ('xcb-util-wm', '0.4.1', common_specs),                 # 2014-02-19
    ('xcb-util-cursor', '0.1.3', common_specs),             # 2016-05-12
    ('xcursor-themes', '1.0.4', common_specs),
    ('font-util', '1.3.1', common_specs),
    ('encodings', '1.0.4', common_specs),
    ('font-alias', '1.0.3', common_specs),
    ('font-adobe-utopia-type1', '1.0.4', common_specs),
    ('font-bh-ttf', '1.0.3', common_specs),
    ('font-bh-type1', '1.0.3', common_specs),
    ('font-ibm-type1', '1.0.3', common_specs),
    ('font-misc-ethiopic', '1.0.3', common_specs),
    ('font-xfree86-type1', '1.0.4', common_specs),
    ('pixman', '0.34.0', common_specs),
    ('xorg-server', '1.19.3', server_specs),
]

# Python is required for xcb-proto
allow_system_deps = [('Python', SYS_PYTHON_VERSION)]
pyshortver = '.'.join(SYS_PYTHON_VERSION.split('.')[0:2])

preconfigopts = "if [ ! -f configure ]; then ./autogen.sh; fi && "

modluafooter = 'add_property("state","testing")'

# xkbcommon configuration dir
# postinstallcmds = [
#	'ln -s %(installdir)s/share/xcb %(installdir)s/share/X11/xkb'
#]

# specify that Bundle easyblock should run a full sanity check, rather
# than just trying to load the module
full_sanity_check = True

sanity_check_paths = {
    'files': [
        'include/X11/Xlib.h',
        'include/X11/Xutil.h'],
    'dirs': [
        'include/GL',
        'include/X11',
        'include/X11/extensions',
        'lib',
        'lib/python%s/site-packages/xcbgen' %
        pyshortver,
        'lib/pkgconfig',
        'share/pkgconfig'],
}

moduleclass = 'vis'