Home | History | Annotate | Line # | Download | only in dist
      1 # SPDX-License-Identifier: MIT
      2 #
      3 # Copyright (c) 2026, 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 
     25 project(
     26   'xconsole',
     27   'c',
     28   version: '1.1.1',
     29   license: 'MIT-open-group',
     30   license_files: 'COPYING',
     31   meson_version: '>= 1.1.0',
     32 )
     33 
     34 conf = configuration_data()
     35 package_string = ' '.join(meson.project_name(), meson.project_version())
     36 conf.set_quoted('PACKAGE_STRING', package_string)
     37 
     38 # Replaces AC_USE_SYSTEM_EXTENSIONS
     39 if host_machine.system() == 'sunos'
     40     add_project_arguments('-D__EXTENSIONS__', language: ['c'])
     41 elif host_machine.system() == 'netbsd'
     42     add_project_arguments('-D_OPENBSD_SOURCE', language: ['c'])
     43 else
     44     add_project_arguments('-D_GNU_SOURCE', language: ['c'])
     45 endif
     46 
     47 cc = meson.get_compiler('c')
     48 
     49 # Replacement for XORG_DEFAULT_OPTIONS
     50 if cc.has_argument('-fno-strict-aliasing')
     51   add_project_arguments('-fno-strict-aliasing', language: 'c')
     52 endif
     53 
     54 # Checks for pkg-config packages
     55 dep_libxaw = dependency('xaw7', required: true)
     56 dep_libxmu = dependency('xmu', required: true)
     57 dep_libxt  = dependency('xt', required: true, version: '>= 1.0')
     58 dep_libx11 = dependency('x11', required: true)
     59 dep_xproto = dependency('xproto', required: true, version: '>= 7.0.17')
     60 deps = [dep_libxaw, dep_libxmu, dep_libxt, dep_libx11, dep_xproto]
     61 
     62 # Checks for library functions.
     63 has_openpty = cc.has_function('openpty')
     64 if not has_openpty
     65   dep_libutil = cc.find_library('util', required: false)
     66   if dep_libutil.found()
     67     has_openpty = cc.has_function('openpty', dependencies: dep_libutil)
     68     if has_openpty
     69       deps += dep_libutil
     70     endif
     71   endif
     72 endif
     73 conf.set('HAS_OPENPTY', has_openpty ? 1 : false)
     74 if has_openpty
     75   headers_to_check = ['util.h', 'libutil.h', 'pty.h']
     76   foreach h: headers_to_check
     77     have_h_name = 'HAVE_' + h.to_upper().underscorify()
     78     have_h = cc.check_header(h, required: false)
     79     conf.set(
     80       have_h_name,
     81       have_h ? '1' : false,
     82       description: f'Define to 1 if you have the <@h@> header file.'
     83     )
     84     if have_h == true
     85       break
     86     endif
     87   endforeach
     88 endif
     89 
     90 config_h = configure_file(output: 'config.h', configuration: conf)
     91 add_project_arguments('-DHAVE_CONFIG_H', language: ['c'])
     92 
     93 add_project_arguments('-D_CONST_X_STRING', language: ['c'])
     94 
     95 executable(
     96   'xconsole',
     97   [config_h, 'xconsole.c'],
     98   dependencies: deps,
     99   install: true
    100 )
    101 
    102 # Find directory for installing app-defaults files
    103 appdefaultdir = get_option('appdefaultdir')
    104 if appdefaultdir == ''
    105   appdefaultdir = dep_libxt.get_variable('appdefaultdir')
    106 endif
    107 summary('appdefaultdir', appdefaultdir)
    108 
    109 # App default files  (*.ad)
    110 install_data(
    111  'app-defaults/XConsole',
    112  install_dir: appdefaultdir,
    113 )
    114 
    115 # Man page
    116 prog_sed = find_program('sed')
    117 
    118 custom_target(
    119   'xconsole.man',
    120   input: 'man/xconsole.man',
    121   output: 'xconsole.1',
    122   command: [
    123     prog_sed,
    124     '-e', 's/__xorgversion__/"xconsole @0@" "X Version 11"/'.format(meson.project_version()),
    125     '-e', 's/__appmansuffix__/1/g',
    126     '-e', 's/__miscmansuffix__/7/g',
    127     '-e', f's%__apploaddir__%@appdefaultdir@%g',
    128     '@INPUT@',
    129   ],
    130   capture: true,
    131   install: true,
    132   install_dir: get_option('mandir') / 'man1',
    133 )
    134