1# SPDX-License-Identifier: MIT
2#
3# Copyright (c) 2025, Oracle and/or its affiliates.
4#
5# Permission is hereby granted, free of charge, to any person obtaining a
6# copy of this software and associated documentation files (the "Software"),
7# to deal in the Software without restriction, including without limitation
8# the rights to use, copy, modify, merge, publish, distribute, sublicense,
9# and/or sell copies of the Software, and to permit persons to whom the
10# Software is furnished to do so, subject to the following conditions:
11#
12# The above copyright notice and this permission notice (including the next
13# paragraph) shall be included in all copies or substantial portions of the
14# Software.
15#
16# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22# DEALINGS IN THE SOFTWARE.
23#
24
25project(
26  'smproxy',
27  'c',
28  version: '1.0.8',
29  license: 'MIT-Open-Group',
30  license_files: 'COPYING',
31  meson_version: '>= 1.1.0',
32)
33
34cc = meson.get_compiler('c')
35
36conf = configuration_data()
37conf.set_quoted('PACKAGE_STRING',
38                ' '.join(meson.project_name(), meson.project_version()))
39
40# Replaces AC_USE_SYSTEM_EXTENSIONS
41if host_machine.system() == 'sunos'
42    system_extensions = '__EXTENSIONS__'
43elif host_machine.system() == 'netbsd'
44    system_extensions = '_NETBSD_SOURCE'
45else
46    system_extensions = '_GNU_SOURCE'
47endif
48conf.set(system_extensions, 1,
49         description: 'Enable non-standardized system API extensions')
50
51# Replacement for XORG_DEFAULT_OPTIONS
52if cc.has_argument('-fno-strict-aliasing')
53  add_project_arguments('-fno-strict-aliasing', language: 'c')
54endif
55
56# Checks for library functions.
57conf.set('HAVE_ASPRINTF', cc.has_function('asprintf') ? '1' : false)
58conf.set('HAVE_MKSTEMP', cc.has_function('mkstemp') ? '1' : false)
59conf.set('HAVE_MKTEMP', cc.has_function('mktemp') ? '1' : false)
60
61# Checks for pkg-config packages
62dep_libsm = dependency('sm', required: true)
63dep_libice = dependency('ice', required: true)
64dep_libxt = dependency('xt', required: true)
65dep_libxmuu = dependency('xmuu', required: true)
66
67config_h = configure_file(output: 'config.h', configuration: conf)
68add_project_arguments('-DHAVE_CONFIG_H', language: ['c'])
69
70executable(
71  'smproxy',
72  [config_h, 'save.c', 'smproxy.c', 'smproxy.h'],
73  dependencies: [dep_libsm, dep_libice, dep_libxt, dep_libxmuu],
74  install: true
75)
76
77prog_sed = find_program('sed')
78
79custom_target(
80  'smproxy.man',
81  input: 'man/smproxy.man',
82  output: 'smproxy.1',
83  command: [
84    prog_sed,
85    '-e', 's/__xorgversion__/"smproxy @0@" "X Version 11"/'.format(meson.project_version()),
86    '-e', 's/__appmansuffix__/1/g',
87    '@INPUT@',
88  ],
89  capture: true,
90  install: true,
91  install_dir: get_option('mandir') / 'man1',
92)
93