project('comet', 'c', version: '1.3-dev', default_options: ['c_std=c99', 'warning_level=0'], meson_version: '>=0.62.0', # dependency('dl') license: 'GPLv2' ) cc = meson.get_compiler('c') # Required dependencies flex = find_program('flex', 'lex', required: true) bison = find_program('bison', 'yacc', 'byacc', required: true) socket_dep = cc.find_library('socket', required: false) sqlite3_dep = dependency('sqlite3', required: true) dl_dep = dependency('dl', required: false) ltdl_dep = cc.find_library('ltdl', required: true) crypt_dep = cc.find_library('crypt', required: false) if not crypt_dep.found() crypt_dep = cc.find_library('descrypt', required: false) endif # Optional dependencies hyperscan_dep = dependency('libhs', version: '>=4', required: get_option('hyperscan')) have_hyperscan = hyperscan_dep.found() sctp_dep = cc.find_library('sctp', has_headers: ['netinet/sctp.h'], required: get_option('sctp')) have_sctp = sctp_dep.found() # Priority: mbedTLS > OpenSSL > GnuTLS tls_backend = 'none' tls_deps = [] have_openssl = false have_mbedtls = false have_gnutls = false # TLS libraries mbedtls_lib = cc.find_library('mbedtls', required: get_option('mbedtls')) mbedx509_lib = cc.find_library('mbedx509', required: get_option('mbedtls')) mbedcrypto_lib = cc.find_library('mbedcrypto', required: get_option('mbedtls')) openssl_dep = dependency('openssl', version: '>=1.1.0', required: get_option('openssl')) gnutls_dep = dependency('gnutls', required: get_option('gnutls')) if mbedtls_lib.found() and mbedx509_lib.found() and mbedcrypto_lib.found() tls_backend = 'mbedtls' tls_deps = [mbedtls_lib, mbedx509_lib, mbedcrypto_lib] have_mbedtls = true elif openssl_dep.found() tls_backend = 'openssl' tls_deps = [openssl_dep] have_openssl = true elif gnutls_dep.found() tls_backend = 'gnutls' tls_deps = [gnutls_dep] have_gnutls = true endif message('TLS backend: ' + tls_backend) fhs_paths = get_option('fhs_paths') prefix = get_option('prefix') # Convert standard Meson directories to absolute paths libdir = prefix / get_option('libdir') bindir = prefix / get_option('bindir') libexecdir = prefix / get_option('libexecdir') datadir = prefix / get_option('datadir') localstatedir = prefix / get_option('localstatedir') sysconfdir_base = prefix / get_option('sysconfdir') if fhs_paths pkglibexecdir = libexecdir / meson.project_name() pkgrundir = prefix / 'run' / meson.project_name() pkglocalstatedir = localstatedir / 'lib' / meson.project_name() default_logdir = localstatedir / 'log' / meson.project_name() default_helpdir = datadir / meson.project_name() / 'help' default_moduledir = libdir / meson.project_name() / 'modules' else pkglibexecdir = bindir pkgrundir = sysconfdir_base pkglocalstatedir = localstatedir default_logdir = prefix / 'logs' default_helpdir = prefix / 'help' default_moduledir = prefix / 'modules' endif # User-overridable options with dynamic defaults option_defaults = { 'logdir': default_logdir, 'helpdir': default_helpdir, 'moduledir': default_moduledir, 'confdir': sysconfdir_base, 'custom_branding': meson.project_name(), 'custom_version': meson.project_version(), } foreach varname, default : option_defaults opt = get_option(varname) set_variable(varname, opt == '' ? default : opt) endforeach # rundir default depends on fhs_paths and confdir default_rundir = fhs_paths ? prefix / 'run' : confdir rundir_opt = get_option('rundir') rundir = rundir_opt == '' ? default_rundir : rundir_opt conf_data = configuration_data() # Basic defines conf_data.set_quoted('PACKAGE_NAME', meson.project_name()) conf_data.set_quoted('PACKAGE_VERSION', meson.project_version()) # Path defines conf_data.set_quoted('IRCD_PREFIX', prefix) conf_data.set_quoted('ETC_DIR', confdir) conf_data.set_quoted('LOG_DIR', logdir) conf_data.set_quoted('HELP_DIR', helpdir) conf_data.set_quoted('MODULE_DIR', moduledir) conf_data.set_quoted('PKGLIBEXECDIR', pkglibexecdir) conf_data.set_quoted('PKGLOCALSTATEDIR', pkglocalstatedir) conf_data.set_quoted('PKGRUNDIR', rundir) # FHS paths if fhs_paths conf_data.set('ENABLE_FHS_PATHS', 1) endif # Protocol limits conf_data.set('NICKLEN', get_option('nicklen') + 1) conf_data.set('TOPICLEN', get_option('topiclen')) # Branding conf_data.set_quoted('BRANDING_NAME', custom_branding) conf_data.set_quoted('BRANDING_VERSION', custom_version) if get_option('custom_branding') != '' conf_data.set('CUSTOM_BRANDING', 1) endif # Program prefix program_prefix = get_option('program_prefix') conf_data.set_quoted('PROGRAM_PREFIX', program_prefix) # Features if get_option('oper_chghost') conf_data.set('ENABLE_OPER_CHGHOST', 1) endif if have_sctp conf_data.set('HAVE_LIBSCTP', 1) endif if have_hyperscan conf_data.set('HAVE_HYPERSCAN', 1) endif # Performance if get_option('profile') conf_data.set('SOLANUM_PROFILE', 1) endif # Heap sizes conf_data.set('NICKNAMEHISTORYLENGTH', 15000) # Size of the WHOWAS array. conf_data.set('CHANNEL_HEAP_SIZE', 8192) conf_data.set('BAN_HEAP_SIZE', 4096) conf_data.set('CLIENT_HEAP_SIZE', 8192) conf_data.set('LCLIENT_HEAP_SIZE', 1024) conf_data.set('PCLIENT_HEAP_SIZE', 256) conf_data.set('USER_HEAP_SIZE', 8192) conf_data.set('DNODE_HEAP_SIZE', 8192) conf_data.set('TOPIC_HEAP_SIZE', 4096) conf_data.set('LINEBUF_HEAP_SIZE', 2048) conf_data.set('MEMBER_HEAP_SIZE', 32768) conf_data.set('ND_HEAP_SIZE', 512) conf_data.set('CONFITEM_HEAP_SIZE', 256) conf_data.set('MONITOR_HEAP_SIZE', 1024) conf_data.set('FD_HEAP_SIZE', 1024) conf_data.set('AWAY_HEAP_SIZE', 512) # System checks system_checks = { 'HAVE_STRINGS_H': cc.check_header('strings.h'), 'HAVE_SYS_PARAM_H': cc.check_header('sys/param.h'), } foreach define, found : system_checks if found conf_data.set(define, 1) endif endforeach if not cc.check_header('stdarg.h') error('stdarg.h is required') endif if not cc.check_header('stdbool.h') error('stdbool.h is required') endif conf_data.set_quoted('PATH_DEVNULL', '/dev/null') if cc.has_type('uintptr_t', prefix: '#include ') conf_data.set('HAVE_UINTPTR_T', 1) endif # For compat with autotools. See https://www.gnu.org/software/libtool/manual/html_node/Autoconf-macros.html#index-LT_005fSYS_005fMODULE_005fEXT # We only support Linux, though conf_data.set_quoted('LT_MODULE_EXT', '.so') if get_option('b_ndebug') == 'true' assertions_enabled = false elif get_option('b_ndebug') == 'if-release' and get_option('buildtype') == 'release' assertions_enabled = false else assertions_enabled = true endif c_args = [] link_args = [] if get_option('profile') if cc.has_argument('-pg') c_args += ['-pg'] link_args += ['-pg'] endif endif rpath = prefix / get_option('libdir') add_project_arguments(c_args, language: 'c') add_project_arguments('-D_GNU_SOURCE', language: 'c') subdir('include') subdir('librb') subdir('ircd') subdir('ssld') subdir('authd') subdir('bandb') subdir('tools') subdir('modules') subdir('extensions') subdir('help') subdir('doc') subdir('tests') install_emptydir(logdir) install_emptydir(pkglocalstatedir) # needed for FHS paths summary({ 'prefix': prefix, 'confdir': confdir, 'logdir': logdir, 'helpdir': helpdir, 'moduledir': moduledir, 'pkglocalstatedir': pkglocalstatedir, 'FHS paths': fhs_paths, }, section: 'Directories') summary({ 'TLS backend': tls_backend, 'SCTP': have_sctp, 'Hyperscan': have_hyperscan, 'OPER CHGHOST': get_option('oper_chghost'), }, section: 'Features') summary({ 'Assertions': assertions_enabled, 'Profile': get_option('profile'), 'Warnings': get_option('warning_level'), }, section: 'Debug Options') summary({ 'Nickname length': get_option('nicklen'), 'Topic length': get_option('topiclen'), }, section: 'Protocol Limits') summary({ 'Branding name': custom_branding, 'Branding version': custom_version, 'Program prefix': program_prefix, }, section: 'Branding')