# SPDX-License-Identifier: MIT
#
# Copyright (c) 2026, 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.
#
project(
'xconsole',
'c',
version: '1.1.1',
license: 'MIT-open-group',
license_files: 'COPYING',
meson_version: '>= 1.1.0',
)
conf = configuration_data()
package_string = ' '.join(meson.project_name(), meson.project_version())
conf.set_quoted('PACKAGE_STRING', package_string)
# Replaces AC_USE_SYSTEM_EXTENSIONS
if host_machine.system() == 'sunos'
add_project_arguments('-D__EXTENSIONS__', language: ['c'])
elif host_machine.system() == 'netbsd'
add_project_arguments('-D_OPENBSD_SOURCE', language: ['c'])
else
add_project_arguments('-D_GNU_SOURCE', language: ['c'])
endif
cc = meson.get_compiler('c')
# Replacement for XORG_DEFAULT_OPTIONS
if cc.has_argument('-fno-strict-aliasing')
add_project_arguments('-fno-strict-aliasing', language: 'c')
endif
# Checks for pkg-config packages
dep_libxaw = dependency('xaw7', required: true)
dep_libxmu = dependency('xmu', required: true)
dep_libxt = dependency('xt', required: true, version: '>= 1.0')
dep_libx11 = dependency('x11', required: true)
dep_xproto = dependency('xproto', required: true, version: '>= 7.0.17')
deps = [dep_libxaw, dep_libxmu, dep_libxt, dep_libx11, dep_xproto]
# Checks for library functions.
has_openpty = cc.has_function('openpty')
if not has_openpty
dep_libutil = cc.find_library('util', required: false)
if dep_libutil.found()
has_openpty = cc.has_function('openpty', dependencies: dep_libutil)
if has_openpty
deps += dep_libutil
endif
endif
endif
conf.set('HAS_OPENPTY', has_openpty ? 1 : false)
if has_openpty
headers_to_check = ['util.h', 'libutil.h', 'pty.h']
foreach h: headers_to_check
have_h_name = 'HAVE_' + h.to_upper().underscorify()
have_h = cc.check_header(h, required: false)
conf.set(
have_h_name,
have_h ? '1' : false,
description: f'Define to 1 if you have the <@h@> header file.'
)
if have_h == true
break
endif
endforeach
endif
config_h = configure_file(output: 'config.h', configuration: conf)
add_project_arguments('-DHAVE_CONFIG_H', language: ['c'])
add_project_arguments('-D_CONST_X_STRING', language: ['c'])
executable(
'xconsole',
[config_h, 'xconsole.c'],
dependencies: deps,
install: true
)
# Find directory for installing app-defaults files
appdefaultdir = get_option('appdefaultdir')
if appdefaultdir == ''
appdefaultdir = dep_libxt.get_variable('appdefaultdir')
endif
summary('appdefaultdir', appdefaultdir)
# App default files (*.ad)
install_data(
'app-defaults/XConsole',
install_dir: appdefaultdir,
)
# Man page
prog_sed = find_program('sed')
custom_target(
'xconsole.man',
input: 'man/xconsole.man',
output: 'xconsole.1',
command: [
prog_sed,
'-e', 's/__xorgversion__/"xconsole @0@" "X Version 11"/'.format(meson.project_version()),
'-e', 's/__appmansuffix__/1/g',
'-e', 's/__miscmansuffix__/7/g',
'-e', f's%__apploaddir__%@appdefaultdir@%g',
'@INPUT@',
],
capture: true,
install: true,
install_dir: get_option('mandir') / 'man1',
)