|
| 1 | +### Compute pgxs_data, used in src/meson.build to generate Makefile.global |
| 2 | +### etc, that's complete enough for PGXS to work. |
| 3 | + |
| 4 | + |
| 5 | +# Emulation of PGAC_CHECK_STRIP |
| 6 | +strip_bin = find_program(get_option('STRIP'), required: false, native: true) |
| 7 | +strip_cmd = strip_bin.found() ? [strip_bin.path()] : [':'] |
| 8 | + |
| 9 | +working_strip = false |
| 10 | +if strip_bin.found() |
| 11 | + strip_version = run_command(strip_bin, '-V', check: false) |
| 12 | + |
| 13 | + if strip_version.returncode() == 0 and ( |
| 14 | + strip_version.stdout().contains('GNU strip') or |
| 15 | + strip_version.stderr().contains('GNU strip')) |
| 16 | + working_strip = true |
| 17 | + strip_static_cmd = strip_cmd + ['-x'] |
| 18 | + strip_shared_cmd = strip_cmd + ['--strip-unneeded'] |
| 19 | + elif host_system == 'darwin' |
| 20 | + working_strip = true |
| 21 | + strip_static_cmd = strip_cmd + ['-x'] |
| 22 | + strip_shared_cmd = strip_cmd + ['-x'] |
| 23 | + endif |
| 24 | +endif |
| 25 | + |
| 26 | +if not working_strip |
| 27 | + strip_cmd = [':'] |
| 28 | + strip_static_cmd = [':'] |
| 29 | + strip_shared_cmd = [':'] |
| 30 | +endif |
| 31 | + |
| 32 | + |
| 33 | +pgxs_kv = { |
| 34 | + 'PACKAGE_URL': pg_url, |
| 35 | + 'PACKAGE_VERSION': pg_version, |
| 36 | + 'PG_MAJORVERSION': pg_version_major, |
| 37 | + 'PG_VERSION_NUM': pg_version_num, |
| 38 | + 'configure_input': 'meson', |
| 39 | + |
| 40 | + 'vpath_build': 'yes', |
| 41 | + 'autodepend': cc.get_argument_syntax() == 'gcc' ? 'yes' : 'no', |
| 42 | + |
| 43 | + 'host_cpu': host_cpu, |
| 44 | + 'host': '@0@-@1@'.format(host_cpu, host_system), |
| 45 | + 'host_os': host_system, |
| 46 | + 'build_os': build_machine.system(), |
| 47 | + 'PORTNAME': portname, |
| 48 | + 'PG_SYSROOT': pg_sysroot, |
| 49 | + |
| 50 | + 'abs_top_builddir': meson.build_root(), |
| 51 | + 'abs_top_srcdir': meson.source_root(), |
| 52 | + |
| 53 | + 'enable_thread_safety': 'yes', |
| 54 | + 'enable_rpath': 'yes', |
| 55 | + 'enable_nls': libintl.found() ? 'yes' : 'no', |
| 56 | + 'enable_tap_tests': tap_tests_enabled ? 'yes' : 'no', |
| 57 | + 'enable_debug': get_option('debug') ? 'yes' : 'no', |
| 58 | + 'enable_coverage': 'no', |
| 59 | + 'enable_dtrace': dtrace.found() ? 'yes' : 'no', |
| 60 | + |
| 61 | + 'DLSUFFIX': dlsuffix, |
| 62 | + 'EXEEXT': exesuffix, |
| 63 | + |
| 64 | + 'SUN_STUDIO_CC': 'no', # not supported so far |
| 65 | + |
| 66 | + # want the chosen option, rather than the library |
| 67 | + 'with_ssl' : get_option('ssl'), |
| 68 | + 'with_uuid': uuidopt, |
| 69 | + |
| 70 | + 'default_port': get_option('pgport'), |
| 71 | + 'with_system_tzdata': get_option('system_tzdata'), |
| 72 | + |
| 73 | + 'with_krb_srvnam': get_option('krb_srvnam'), |
| 74 | + 'krb_srvtab': krb_srvtab, |
| 75 | + |
| 76 | + 'STRIP': ' '.join(strip_cmd), |
| 77 | + 'STRIP_STATIC_LIB': ' '.join(strip_static_cmd), |
| 78 | + 'STRIP_SHARED_LIB': ' '.join(strip_shared_cmd), |
| 79 | + |
| 80 | + # these seem to be standard these days |
| 81 | + 'MKDIR_P': 'mkdir -p', |
| 82 | + 'LN_S': 'ln -s', |
| 83 | + # Just always use the install_sh fallback that autoconf uses. Unlikely to |
| 84 | + # matter performance-wise for extensions. If it turns out to do, we can |
| 85 | + 'install_bin': '$(SHELL) $(top_srcdir)/config/install-sh -c', |
| 86 | + |
| 87 | + 'CC': var_cc, |
| 88 | + 'CPP': var_cpp, |
| 89 | + 'GCC': cc.get_argument_syntax() == 'gcc' ? 'yes' : 'no', |
| 90 | + |
| 91 | + 'CPPFLAGS': var_cppflags, |
| 92 | + 'CFLAGS': var_cflags, |
| 93 | + 'CXXFLAGS': var_cxxflags, |
| 94 | + 'CFLAGS_SL': var_cflags_sl, |
| 95 | + 'CFLAGS_SL_MODULE': ' '.join(cflags_mod), |
| 96 | + 'CXXFLAGS_SL_MODULE': ' '.join(cxxflags_mod), |
| 97 | + 'PERMIT_DECLARATION_AFTER_STATEMENT': |
| 98 | + ' '.join(cflags_no_decl_after_statement), |
| 99 | + |
| 100 | + 'CFLAGS_CRC': ' '.join(cflags_crc), |
| 101 | + 'CFLAGS_UNROLL_LOOPS': ' '.join(unroll_loops_cflags), |
| 102 | + 'CFLAGS_VECTORIZE': ' '.join(vectorize_cflags), |
| 103 | + |
| 104 | + 'LDFLAGS': var_ldflags, |
| 105 | + 'LDFLAGS_EX': var_ldflags_ex, |
| 106 | + 'LDFLAGS_EX_BE': |
| 107 | + ' '.join(cc.get_supported_link_arguments('-Wl,--export-dynamic')), |
| 108 | + 'LDFLAGS_SL': var_ldflags_sl, |
| 109 | + |
| 110 | + # TODO: requires bitcode generation to be implemented for meson |
| 111 | + 'BITCODE_CFLAGS': '', |
| 112 | + 'BITCODE_CXXFLAGS': '', |
| 113 | + |
| 114 | + 'BISONFLAGS': ' '.join(bison_flags), |
| 115 | + 'FLEXFLAGS': ' '.join(flex_flags), |
| 116 | + |
| 117 | + 'LIBS': var_libs, |
| 118 | +} |
| 119 | + |
| 120 | +if llvm.found() |
| 121 | + pgxs_kv += { |
| 122 | + 'CLANG': clang.path(), |
| 123 | + 'CXX': ' '.join(cpp.cmd_array()), |
| 124 | + 'LLVM_BINPATH': llvm_binpath, |
| 125 | + } |
| 126 | +else |
| 127 | + pgxs_kv += { |
| 128 | + 'CLANG': '', |
| 129 | + 'CXX': '', |
| 130 | + 'LLVM_BINPATH': '', |
| 131 | + } |
| 132 | +endif |
| 133 | + |
| 134 | +pgxs_bins = { |
| 135 | + 'AR': |
| 136 | + find_program(['ar'], native: true, required: false), |
| 137 | + 'AWK': |
| 138 | + find_program(['gawk', 'mawk', 'nawk', 'awk'], native: true, required: false), |
| 139 | + 'BISON': bison, |
| 140 | + 'FLEX': flex, |
| 141 | + 'GZIP': gzip, |
| 142 | + 'LZ4': program_lz4, |
| 143 | + 'OPENSSL': openssl, |
| 144 | + 'PERL': perl, |
| 145 | + 'PROVE': prove, |
| 146 | + 'PYTHON': python, |
| 147 | + 'TAR': tar, |
| 148 | + 'ZSTD': program_zstd, |
| 149 | + 'DTRACE': dtrace, |
| 150 | +} |
| 151 | + |
| 152 | +pgxs_empty = [ |
| 153 | + 'ICU_CFLAGS', # needs to be added, included by public server headers |
| 154 | + |
| 155 | + # hard to see why we'd need either? |
| 156 | + 'ZIC', |
| 157 | + 'TCLSH', |
| 158 | + |
| 159 | + # docs don't seem to be supported by pgxs |
| 160 | + 'XMLLINT', |
| 161 | + 'XSLTPROC', |
| 162 | + 'DBTOEPUB', |
| 163 | + 'FOP', |
| 164 | + |
| 165 | + # supporting coverage for pgxs-in-meson build doesn't seem worth it |
| 166 | + 'GENHTML', |
| 167 | + 'LCOV', |
| 168 | + 'GCOV', |
| 169 | + 'MSGFMT_FLAGS', |
| 170 | + |
| 171 | + # translation doesn't appear to be supported by pgxs |
| 172 | + 'MSGFMT', |
| 173 | + 'XGETTEXT', |
| 174 | + 'MSGMERGE', |
| 175 | + 'WANTED_LANGUAGES', |
| 176 | + |
| 177 | + # Not needed because we don't build the server / PLs with the generated makefile |
| 178 | + 'LIBOBJS', 'PG_CRC32C_OBJS', 'TAS', |
| 179 | + 'DTRACEFLAGS', # only server has dtrace probes |
| 180 | + |
| 181 | + 'perl_archlibexp', 'perl_embed_ccflags', 'perl_embed_ldflags', 'perl_includespec', 'perl_privlibexp', |
| 182 | + 'python_additional_libs', 'python_includespec', 'python_libdir', 'python_libspec', 'python_majorversion', 'python_version', |
| 183 | + |
| 184 | + # possible that some of these are referenced explicitly in pgxs makefiles? |
| 185 | + # For now not worth it. |
| 186 | + 'TCL_INCLUDE_SPEC', 'TCL_LIBS', 'TCL_LIB_SPEC', 'TCL_SHARED_BUILD', |
| 187 | + |
| 188 | + 'LLVM_CFLAGS', 'LLVM_CPPFLAGS', 'LLVM_CXXFLAGS', 'LLVM_LIBS', |
| 189 | + |
| 190 | + 'LDAP_LIBS_BE', 'LDAP_LIBS_FE', |
| 191 | + |
| 192 | + 'UUID_LIBS', |
| 193 | + |
| 194 | + 'PTHREAD_CFLAGS', 'PTHREAD_LIBS', |
| 195 | + |
| 196 | + 'ICU_LIBS', |
| 197 | +] |
| 198 | + |
| 199 | +if host_system == 'windows' and cc.get_argument_syntax() != 'msvc' |
| 200 | + pgxs_bins += {'WINDRES': windres} |
| 201 | +else |
| 202 | + pgxs_empty += 'WINDRES' |
| 203 | +endif |
| 204 | + |
| 205 | +pgxs_dirs = { |
| 206 | + 'prefix': get_option('prefix'), |
| 207 | + |
| 208 | + 'bindir': '${exec_prefix}' / get_option('bindir'), |
| 209 | + 'datarootdir': '${prefix}' / get_option('datadir'), |
| 210 | + 'datadir': '${datarootdir}', |
| 211 | + 'docdir': '${prefix}' / dir_doc, |
| 212 | + 'exec_prefix': '${prefix}', |
| 213 | + 'htmldir': '${docdir}', |
| 214 | + 'includedir': '${prefix}' / get_option('includedir'), |
| 215 | + 'libdir': '${exec_prefix}' / get_option('libdir'), |
| 216 | + 'localedir': '${prefix}' / get_option('localedir'), |
| 217 | + 'mandir': '${prefix}' / get_option('mandir'), |
| 218 | + 'sysconfdir': '${prefix}' / get_option('sysconfdir'), |
| 219 | +} |
| 220 | + |
| 221 | +pgxs_deps = { |
| 222 | + 'bonjour': bonjour, |
| 223 | + 'bsd_auth': bsd_auth, |
| 224 | + 'gssapi': gssapi, |
| 225 | + 'icu': icu, |
| 226 | + 'ldap': ldap, |
| 227 | + 'libxml': libxml, |
| 228 | + 'libxslt': libxslt, |
| 229 | + 'llvm': llvm, |
| 230 | + 'lz4': lz4, |
| 231 | + 'nls': libintl, |
| 232 | + 'pam': pam, |
| 233 | + 'perl': perl_dep, |
| 234 | + 'python': python3_dep, |
| 235 | + 'readline': readline, |
| 236 | + 'selinux': selinux, |
| 237 | + 'systemd': systemd, |
| 238 | + 'tcl': tcl_dep, |
| 239 | + 'zlib': zlib, |
| 240 | + 'zstd': zstd, |
| 241 | +} |
| 242 | + |
| 243 | + |
| 244 | +pgxs_cdata = configuration_data(pgxs_kv) |
| 245 | + |
| 246 | +foreach b, p : pgxs_bins |
| 247 | + pgxs_cdata.set(b, p.found() ? p.path() : '') |
| 248 | +endforeach |
| 249 | + |
| 250 | +foreach pe : pgxs_empty |
| 251 | + pgxs_cdata.set(pe, '') |
| 252 | +endforeach |
| 253 | + |
| 254 | +foreach d, p : pgxs_dirs |
| 255 | + pgxs_cdata.set(d, p) |
| 256 | +endforeach |
| 257 | + |
| 258 | +foreach d, v : pgxs_deps |
| 259 | + pgxs_cdata.set('with_@0@'.format(d), v.found() ? 'yes' : 'no') |
| 260 | +endforeach |
0 commit comments