summaryrefslogtreecommitdiff
path: root/meson.build
blob: 9fb20b12960f183b10b86623323ea7bfc91b2c5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
73
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
# SPDX-License-Identifier: MIT
#
# Copyright (c) 2025, Oracle and/or its affiliates.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice (including the next
# paragraph) shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#

#
# Version should match the current Randr version. XRRQueryVersion
# returns the version from randr.h, NOT the version we set here. But we
# try to keep these the same.  Note that the library has an extra
# digit in the version number to track changes which don't affect the
# protocol, so Xrandr version l.n.m corresponds to protocol version l.n
#
project(
  'libXScrnSaver',
  'c',
  version: '1.2.5',
  license: 'X11',
  license_files: 'COPYING',
  meson_version: '>= 1.1.0',
)

# Replacement for XORG_DEFAULT_OPTIONS
cc = meson.get_compiler('c')
if cc.has_argument('-fno-strict-aliasing')
  add_project_arguments('-fno-strict-aliasing', language: 'c')
endif

# Replacement for XORG_CHECK_MALLOC_ZERO
add_project_arguments('-DMALLOC_0_RETURNS_NULL', language: 'c')

# Obtain compiler/linker options for dependencies
dep_libx11    = dependency('x11', required: true)
dep_libxext   = dependency('xext', required: true)
dep_xextproto = dependency('xextproto', required: true)
dep_xssproto  = dependency('scrnsaverproto', required: true, version: '>= 1.2')

lib = library(
  'Xss',
  'src/XScrnSaver.c',
  include_directories: 'include',
  dependencies: [dep_libx11, dep_libxext, dep_xextproto, dep_xssproto],
  version: '1.0.0',
  install: true,
)

install_headers(
  'include/X11/extensions/scrnsaver.h',
  subdir: 'X11/extensions',
)

pkg = import('pkgconfig')
pkg.generate(
  name: 'XScrnSaver',
  description: 'The XScrnSaver Library',
  filebase: 'xscrnsaver',
  libraries: '-L${libdir} -lXss',
  requires: dep_xssproto,
  requires_private: [dep_libx11, dep_libxext],
  url: 'https://gitlab.freedesktop.org/xorg/lib/libXScrnSaver/'
)

prog_sed = find_program('sed')

libXss_manpages = [
  'Xss',
  'XScreenSaverQueryExtension',
  'XScreenSaverQueryVersion',
  'XScreenSaverAllocInfo',
  'XScreenSaverQueryInfo',
  'XScreenSaverSelectInput',
  'XScreenSaverSetAttributes',
  'XScreenSaverUnsetAttributes',
  'XScreenSaverRegister',
  'XScreenSaverUnregister',
  'XScreenSaverGetRegistered',
  'XScreenSaverSuspend'
]

lib_man_suffix = get_option('lib_man_suffix')
foreach man: libXss_manpages
  custom_target(
    f'@man@.man',
    input: f'man/@man@.man',
    output: f'@man@.@lib_man_suffix@',
    command: [
      prog_sed,
      '-e', 's/__vendorversion__/"libXScrnSaver @0@" "X Version 11"/'.format(meson.project_version()),
      '-e', f's/__libmansuffix__/@lib_man_suffix@/g',
      '-e', f's/__miscmansuffix__/7/g',
      '@INPUT@',
    ],
    capture: true,
    install: true,
    install_dir: get_option('prefix') / get_option('mandir') / f'man@lib_man_suffix@',
  )
endforeach