1 # Copyright (c) 2022-2025, PostgreSQL Global Development Group
10 'pg_popcount_avx512.c',
26 if host_system == 'windows'
27 pgport_sources += files(
38 'win32gai_strerror.c',
48 elif host_system == 'cygwin'
49 pgport_sources += files(
54 if cc.get_id() == 'msvc'
55 pgport_sources += files(
57 'win32gettimeofday.c',
61 # Replacement functionality to be built if corresponding configure symbol
76 if host_system != 'windows'
77 replace_funcs_neg += [['pthread_barrier_wait']]
80 # Replacement functionality to be built if corresponding configure symbol
84 ['pg_crc32c_sse42', 'USE_SSE42_CRC32C'],
85 ['pg_crc32c_sse42', 'USE_SSE42_CRC32C_WITH_RUNTIME_CHECK'],
86 ['pg_crc32c_sse42_choose', 'USE_SSE42_CRC32C_WITH_RUNTIME_CHECK'],
87 ['pg_crc32c_sb8', 'USE_SSE42_CRC32C_WITH_RUNTIME_CHECK'],
90 ['pg_crc32c_armv8', 'USE_ARMV8_CRC32C'],
91 ['pg_crc32c_armv8', 'USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK', 'crc'],
92 ['pg_crc32c_armv8_choose', 'USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK'],
93 ['pg_crc32c_sb8', 'USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK'],
96 ['pg_crc32c_loongarch', 'USE_LOONGARCH_CRC32C'],
99 ['pg_crc32c_sb8', 'USE_SLICING_BY_8_CRC32C'],
102 pgport_cflags = {'crc': cflags_crc}
103 pgport_sources_cflags = {'crc': []}
105 foreach f : replace_funcs_neg
107 varname = f.get(1, 'HAVE_@0@'.format(func.to_upper()))
108 filename = '@0@.c'.format(func)
110 val = '@0@'.format(cdata.get(varname, 'false'))
111 if val == 'false' or val == '0'
112 pgport_sources += files(filename)
116 foreach f : replace_funcs_pos
118 varname = f.get(1, 'HAVE_@0@'.format(func.to_upper()))
119 filename = '@0@.c'.format(func)
121 val = '@0@'.format(cdata.get(varname, 'false'))
122 if val == 'true' or val == '1'
123 src = files(filename)
125 pgport_sources_cflags += {f[2]: pgport_sources_cflags[f[2]] + src}
127 pgport_sources += src
133 if (host_system == 'windows' or host_system == 'cygwin') and \
134 (cc.get_id() != 'msvc' or cc.version().version_compare('<14.0'))
136 # Cygwin and (apparently, based on test results) Mingw both
137 # have a broken strtof(), so substitute its implementation.
138 # That's not a perfect fix, since it doesn't avoid double-rounding,
139 # but we have no better options.
140 pgport_sources += files('strtof.c')
141 message('On @0@ with compiler @1@ @2@ we will use our strtof wrapper.'.format(
142 host_system, cc.get_id(), cc.version()))
147 # Build pgport once for backend, once for use in frontend binaries, and once
148 # for use in shared libraries
151 '_srv': internal_lib_args + {
152 'dependencies': [backend_port_code],
154 '': default_lib_args + {
155 'dependencies': [frontend_port_code],
157 '_shlib': default_lib_args + {
159 'dependencies': [frontend_port_code],
163 foreach name, opts : pgport_variants
165 # Build internal static libraries for sets of files that need to be built
166 # with different cflags
168 foreach cflagname, sources : pgport_sources_cflags
169 if sources.length() == 0
172 c_args = opts.get('c_args', []) + pgport_cflags[cflagname]
173 cflag_libs += static_library('libpgport@0@_@1@'.format(name, cflagname),
178 'build_by_default': false,
184 lib = static_library('libpgport@0@'.format(name),
186 link_with: cflag_libs,
187 link_whole: cflag_libs,
190 'dependencies': opts['dependencies'] + [ssl],
193 pgport += {name: lib}
196 pgport_srv = pgport['_srv']
197 pgport_static = pgport['']
198 pgport_shlib = pgport['_shlib']
200 # autoconf generates the file there, ensure we get a conflict
201 generated_sources_ac += {'src/port': ['pg_config_paths.h']}