17015785aSmrg# SPDX-License-Identifier: MIT
27015785aSmrg#
37015785aSmrg# Copyright (c) 2025, Oracle and/or its affiliates.
47015785aSmrg#
57015785aSmrg# Permission is hereby granted, free of charge, to any person obtaining a
67015785aSmrg# copy of this software and associated documentation files (the "Software"),
77015785aSmrg# to deal in the Software without restriction, including without limitation
87015785aSmrg# the rights to use, copy, modify, merge, publish, distribute, sublicense,
97015785aSmrg# and/or sell copies of the Software, and to permit persons to whom the
107015785aSmrg# Software is furnished to do so, subject to the following conditions:
117015785aSmrg#
127015785aSmrg# The above copyright notice and this permission notice (including the next
137015785aSmrg# paragraph) shall be included in all copies or substantial portions of the
147015785aSmrg# Software.
157015785aSmrg#
167015785aSmrg# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
177015785aSmrg# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
187015785aSmrg# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
197015785aSmrg# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
207015785aSmrg# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
217015785aSmrg# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
227015785aSmrg# DEALINGS IN THE SOFTWARE.
237015785aSmrg#
247015785aSmrg
257015785aSmrgproject(
267015785aSmrg  'smproxy',
277015785aSmrg  'c',
287015785aSmrg  version: '1.0.8',
297015785aSmrg  license: 'MIT-Open-Group',
307015785aSmrg  license_files: 'COPYING',
317015785aSmrg  meson_version: '>= 1.1.0',
327015785aSmrg)
337015785aSmrg
347015785aSmrgcc = meson.get_compiler('c')
357015785aSmrg
367015785aSmrgconf = configuration_data()
377015785aSmrgconf.set_quoted('PACKAGE_STRING',
387015785aSmrg                ' '.join(meson.project_name(), meson.project_version()))
397015785aSmrg
407015785aSmrg# Replaces AC_USE_SYSTEM_EXTENSIONS
417015785aSmrgif host_machine.system() == 'sunos'
427015785aSmrg    system_extensions = '__EXTENSIONS__'
437015785aSmrgelif host_machine.system() == 'netbsd'
447015785aSmrg    system_extensions = '_NETBSD_SOURCE'
457015785aSmrgelse
467015785aSmrg    system_extensions = '_GNU_SOURCE'
477015785aSmrgendif
487015785aSmrgconf.set(system_extensions, 1,
497015785aSmrg         description: 'Enable non-standardized system API extensions')
507015785aSmrg
517015785aSmrg# Replacement for XORG_DEFAULT_OPTIONS
527015785aSmrgif cc.has_argument('-fno-strict-aliasing')
537015785aSmrg  add_project_arguments('-fno-strict-aliasing', language: 'c')
547015785aSmrgendif
557015785aSmrg
567015785aSmrg# Checks for library functions.
577015785aSmrgconf.set('HAVE_ASPRINTF', cc.has_function('asprintf') ? '1' : false)
587015785aSmrgconf.set('HAVE_MKSTEMP', cc.has_function('mkstemp') ? '1' : false)
597015785aSmrgconf.set('HAVE_MKTEMP', cc.has_function('mktemp') ? '1' : false)
607015785aSmrg
617015785aSmrg# Checks for pkg-config packages
627015785aSmrgdep_libsm = dependency('sm', required: true)
637015785aSmrgdep_libice = dependency('ice', required: true)
647015785aSmrgdep_libxt = dependency('xt', required: true)
657015785aSmrgdep_libxmuu = dependency('xmuu', required: true)
667015785aSmrg
677015785aSmrgconfig_h = configure_file(output: 'config.h', configuration: conf)
687015785aSmrgadd_project_arguments('-DHAVE_CONFIG_H', language: ['c'])
697015785aSmrg
707015785aSmrgexecutable(
717015785aSmrg  'smproxy',
727015785aSmrg  [config_h, 'save.c', 'smproxy.c', 'smproxy.h'],
737015785aSmrg  dependencies: [dep_libsm, dep_libice, dep_libxt, dep_libxmuu],
747015785aSmrg  install: true
757015785aSmrg)
767015785aSmrg
777015785aSmrgprog_sed = find_program('sed')
787015785aSmrg
797015785aSmrgcustom_target(
807015785aSmrg  'smproxy.man',
817015785aSmrg  input: 'man/smproxy.man',
827015785aSmrg  output: 'smproxy.1',
837015785aSmrg  command: [
847015785aSmrg    prog_sed,
857015785aSmrg    '-e', 's/__xorgversion__/"smproxy @0@" "X Version 11"/'.format(meson.project_version()),
867015785aSmrg    '-e', 's/__appmansuffix__/1/g',
877015785aSmrg    '@INPUT@',
887015785aSmrg  ],
897015785aSmrg  capture: true,
907015785aSmrg  install: true,
917015785aSmrg  install_dir: get_option('mandir') / 'man1',
927015785aSmrg)
93