Debian Codegraph @

src/interfaces/libpq/meson.build

raw
1 # Copyright (c) 2022-2025, PostgreSQL Global Development Group
2
3 libpq_sources = files(
4 'fe-auth-oauth.c',
5 'fe-auth-scram.c',
6 'fe-auth.c',
7 'fe-cancel.c',
8 'fe-connect.c',
9 'fe-exec.c',
10 'fe-lobj.c',
11 'fe-misc.c',
12 'fe-print.c',
13 'fe-protocol3.c',
14 'fe-secure.c',
15 'fe-trace.c',
16 'legacy-pqsignal.c',
17 'libpq-events.c',
18 'pqexpbuffer.c',
19 )
20 libpq_so_sources = [] # for shared lib, in addition to the above
21
22 if host_system == 'windows'
23 libpq_sources += files('pthread-win32.c', 'win32.c')
24 libpq_so_sources += rc_lib_gen.process(win32ver_rc, extra_args: [
25 '--NAME', 'libpq',
26 '--FILEDESC', 'PostgreSQL Access Library',])
27 endif
28
29 if ssl.found()
30 libpq_sources += files('fe-secure-common.c')
31 libpq_sources += files('fe-secure-openssl.c')
32 endif
33
34 if gssapi.found()
35 libpq_sources += files(
36 'fe-gssapi-common.c',
37 'fe-secure-gssapi.c',
38 )
39 endif
40
41 export_file = custom_target('libpq.exports',
42 kwargs: gen_export_kwargs,
43 )
44
45 # port needs to be in include path due to pthread-win32.h
46 libpq_inc = include_directories('.', '../../port')
47 libpq_c_args = ['-DSO_MAJOR_VERSION=5']
48
49 # The OAuth implementation differs depending on the type of library being built.
50 libpq_so_c_args = ['-DUSE_DYNAMIC_OAUTH']
51
52 # Not using both_libraries() here as
53 # 1) resource files should only be in the shared library
54 # 2) we want the .pc file to include a dependency to {pgport,common}_static for
55 # libpq_st, and {pgport,common}_shlib for libpq_sh
56 #
57 # We could try to avoid building the source files twice, but it probably adds
58 # more complexity than its worth (reusing object files requires also linking
59 # to the library on windows or breaks precompiled headers).
60 libpq_st = static_library('libpq',
61 libpq_sources,
62 include_directories: [libpq_inc],
63 c_args: libpq_c_args,
64 c_pch: pch_postgres_fe_h,
65 dependencies: [frontend_stlib_code, libpq_deps],
66 kwargs: default_lib_args,
67 )
68
69 libpq_so = shared_library('libpq',
70 libpq_sources + libpq_so_sources,
71 include_directories: [libpq_inc, postgres_inc],
72 c_args: libpq_c_args + libpq_so_c_args,
73 c_pch: pch_postgres_fe_h,
74 version: '5.' + pg_version_major.to_string(),
75 soversion: host_system != 'windows' ? '5' : '',
76 darwin_versions: ['5', '5.' + pg_version_major.to_string()],
77 dependencies: [frontend_shlib_code, libpq_deps],
78 link_depends: export_file,
79 link_args: export_fmt.format(export_file.full_path()),
80 kwargs: default_lib_args,
81 )
82
83 libpq = declare_dependency(
84 link_with: [libpq_so],
85 include_directories: [include_directories('.')]
86 )
87
88 private_deps = [
89 frontend_stlib_code,
90 libpq_deps,
91 ]
92
93 if oauth_flow_supported
94 # libpq.so doesn't link against libcurl, but libpq.a needs libpq-oauth, and
95 # libpq-oauth needs libcurl. Put both into *.private.
96 private_deps += [
97 libpq_oauth_deps,
98 '-lpq-oauth',
99 ]
100 endif
101
102 pkgconfig.generate(
103 name: 'libpq',
104 description: 'PostgreSQL libpq library',
105 url: pg_url,
106 libraries: libpq,
107 libraries_private: private_deps,
108 )
109
110 install_headers(
111 'libpq-fe.h',
112 'libpq-events.h',
113 )
114
115 install_headers(
116 'libpq-int.h',
117 'pqexpbuffer.h',
118 'fe-auth-sasl.h',
119 install_dir: dir_include_internal,
120 )
121 install_data('pg_service.conf.sample',
122 install_dir: dir_data,
123 )
124
125 subdir('test')
126
127 tests += {
128 'name': 'libpq',
129 'sd': meson.current_source_dir(),
130 'bd': meson.current_build_dir(),
131 'tap': {
132 'tests': [
133 't/001_uri.pl',
134 't/002_api.pl',
135 't/003_load_balance_host_list.pl',
136 't/004_load_balance_dns.pl',
137 't/005_negotiate_encryption.pl',
138 't/006_service.pl',
139 ],
140 'env': {
141 'with_ssl': ssl_library,
142 'with_gssapi': gssapi.found() ? 'yes' : 'no',
143 'with_krb_srvnam': 'postgres',
144 },
145 'deps': libpq_test_deps,
146 },
147 }
148
149 subdir('po', if_found: libintl)