1 # Copyright (c) 2022-2024, PostgreSQL Global Development Group
26 if host_system == 'windows'
27 pgport_sources += files(
47 elif host_system == 'cygwin'
48 pgport_sources += files(
53 if cc.get_id() == 'msvc'
54 pgport_sources += files(
56 'win32gettimeofday.c',
60 # Replacement functionality to be built if corresponding configure symbol
74 if host_system != 'windows'
75 replace_funcs_neg += [['pthread_barrier_wait']]
78 # Replacement functionality to be built if corresponding configure symbol
82 ['pg_crc32c_sse42', 'USE_SSE42_CRC32C'],
83 ['pg_crc32c_sse42', 'USE_SSE42_CRC32C_WITH_RUNTIME_CHECK', 'crc'],
84 ['pg_crc32c_sse42_choose', 'USE_SSE42_CRC32C_WITH_RUNTIME_CHECK'],
85 ['pg_crc32c_sb8', 'USE_SSE42_CRC32C_WITH_RUNTIME_CHECK'],
88 ['pg_crc32c_armv8', 'USE_ARMV8_CRC32C'],
89 ['pg_crc32c_armv8', 'USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK', 'crc'],
90 ['pg_crc32c_armv8_choose', 'USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK'],
91 ['pg_crc32c_sb8', 'USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK'],
94 ['pg_crc32c_loongarch', 'USE_LOONGARCH_CRC32C'],
97 ['pg_crc32c_sb8', 'USE_SLICING_BY_8_CRC32C'],
100 pgport_cflags = {'crc': cflags_crc}
101 pgport_sources_cflags = {'crc': []}
103 foreach f : replace_funcs_neg
105 varname = f.get(1, 'HAVE_@0@'.format(func.to_upper()))
106 filename = '@0@.c'.format(func)
108 val = '@0@'.format(cdata.get(varname, 'false'))
109 if val == 'false' or val == '0'
110 pgport_sources += files(filename)
114 foreach f : replace_funcs_pos
116 varname = f.get(1, 'HAVE_@0@'.format(func.to_upper()))
117 filename = '@0@.c'.format(func)
119 val = '@0@'.format(cdata.get(varname, 'false'))
120 if val == 'true' or val == '1'
121 src = files(filename)
123 pgport_sources_cflags += {f[2]: pgport_sources_cflags[f[2]] + src}
125 pgport_sources += src
131 if (host_system == 'windows' or host_system == 'cygwin') and \
132 (cc.get_id() != 'msvc' or cc.version().version_compare('<14.0'))
134 # Cygwin and (apparently, based on test results) Mingw both
135 # have a broken strtof(), so substitute its implementation.
136 # That's not a perfect fix, since it doesn't avoid double-rounding,
137 # but we have no better options.
138 pgport_sources += files('strtof.c')
139 message('On @0@ with compiler @1@ @2@ we will use our strtof wrapper.'.format(
140 host_system, cc.get_id(), cc.version()))
145 # Build pgport once for backend, once for use in frontend binaries, and once
146 # for use in shared libraries
149 '_srv': internal_lib_args + {
150 'dependencies': [backend_port_code],
152 '': default_lib_args + {
153 'dependencies': [frontend_port_code],
155 '_shlib': default_lib_args + {
157 'dependencies': [frontend_port_code],
161 foreach name, opts : pgport_variants
163 # Build internal static libraries for sets of files that need to be built
164 # with different cflags
166 foreach cflagname, sources : pgport_sources_cflags
167 if sources.length() == 0
170 c_args = opts.get('c_args', []) + pgport_cflags[cflagname]
171 cflag_libs += static_library('libpgport@0@_@1@'.format(name, cflagname),
176 'build_by_default': false,
182 lib = static_library('libpgport@0@'.format(name),
184 link_with: cflag_libs,
187 'dependencies': opts['dependencies'] + [ssl],
190 pgport += {name: lib}
193 pgport_srv = pgport['_srv']
194 pgport_static = pgport['']
195 pgport_shlib = pgport['_shlib']
197 # autoconf generates the file there, ensure we get a conflict
198 generated_sources_ac += {'src/port': ['pg_config_paths.h']}