@@ -101,6 +101,27 @@ link_linux_system_deps() {
101101 shopt -u nullglob
102102}
103103
104+ append_pkg_config_package () {
105+ local package_name=$1
106+ local package_cflags
107+ local package_ldflags
108+ local package_libs
109+
110+ if ! pkg-config --exists " ${package_name} " ; then
111+ return 1
112+ fi
113+
114+ package_cflags=$( pkg-config --cflags " ${package_name} " )
115+ package_ldflags=$( pkg-config --libs-only-L " ${package_name} " )
116+ package_libs=$( pkg-config --libs-only-l " ${package_name} " )
117+
118+ cppflags=" ${cppflags}${package_cflags: + ${package_cflags} } "
119+ ldflags=" ${ldflags}${package_ldflags: + ${package_ldflags} } "
120+ libs=" ${libs}${package_libs: + ${package_libs} } "
121+
122+ return 0
123+ }
124+
104125install_linux_build_deps () {
105126 if command -v dnf > /dev/null 2>&1 ; then
106127 dnf install -y epel-release || true
@@ -161,8 +182,9 @@ build_linux_netcdf_c() {
161182 local cppflags
162183 local ldflags
163184 local libs
185+ local make_jobs
164186
165- netcdf_c_version=${NETCDF_C_VERSION:- 4.9.2 }
187+ netcdf_c_version=${NETCDF_C_VERSION:- 4.10.0 }
166188 netcdf_tarball=" v${netcdf_c_version} .tar.gz"
167189 netcdf_url=" https://github.com/Unidata/netcdf-c/archive/refs/tags/${netcdf_tarball} "
168190 netcdf_archive_path=" /tmp/netcdf-c-${netcdf_c_version} .tar.gz"
@@ -182,16 +204,20 @@ build_linux_netcdf_c() {
182204 download_file " ${netcdf_url} " " ${netcdf_archive_path} "
183205 tar -C /tmp -xf " ${netcdf_archive_path} "
184206
185- if [ -d /usr/include/hdf5/serial ]; then
186- cppflags=" ${cppflags} -I/usr/include/hdf5/serial"
187- fi
207+ if ! append_pkg_config_package hdf5; then
208+ if [ -d /usr/include/hdf5/serial ]; then
209+ cppflags=" ${cppflags} -I/usr/include/hdf5/serial"
210+ fi
188211
189- if [ -d /usr/lib64/hdf5/serial ]; then
190- ldflags=" ${ldflags} -L/usr/lib64/hdf5/serial"
191- elif [ -d /usr/lib/hdf5/serial ]; then
192- ldflags=" ${ldflags} -L/usr/lib/hdf5/serial"
212+ if [ -d /usr/lib64/hdf5/serial ]; then
213+ ldflags=" ${ldflags} -L/usr/lib64/hdf5/serial"
214+ elif [ -d /usr/lib/hdf5/serial ]; then
215+ ldflags=" ${ldflags} -L/usr/lib/hdf5/serial"
216+ fi
193217 fi
194218
219+ append_pkg_config_package hdf5_hl || true
220+
195221 if ! pkg-config --exists libzstd; then
196222 echo " Could not find libzstd pkg-config metadata; cannot build zstd-enabled netcdf-c" >&2
197223 exit 1
@@ -200,19 +226,36 @@ build_linux_netcdf_c() {
200226 cppflags=" ${cppflags} $( pkg-config --cflags libzstd) "
201227 ldflags=" ${ldflags} $( pkg-config --libs-only-L libzstd) "
202228 libs=" ${libs} $( pkg-config --libs-only-l libzstd) "
229+ make_jobs=$( getconf _NPROCESSORS_ONLN 2> /dev/null || echo 2)
230+ if [ " ${make_jobs} " -lt 1 ]; then
231+ make_jobs=1
232+ fi
203233
204234 (
205235 cd " ${netcdf_source_dir} "
206- CPPFLAGS=" ${cppflags} " \
207- LDFLAGS=" ${ldflags} " \
208- LIBS=" ${libs} " \
209- ./configure \
236+ if ! CPPFLAGS=" ${cppflags} " \
237+ LDFLAGS=" ${ldflags} " \
238+ LIBS=" ${libs} " \
239+ ./configure \
210240 --prefix=" ${CMOR_DEPS_PREFIX} " \
211241 --disable-dap \
212242 --disable-byterange \
213243 --disable-libxml2 \
244+ --disable-utilities \
245+ --disable-silent-rules \
214246 --enable-netcdf-4
215- make -j" $( getconf _NPROCESSORS_ONLN 2> /dev/null || echo 2) "
247+ then
248+ if [ -f config.log ]; then
249+ echo " ===== netcdf-c config.log (tail) =====" >&2
250+ tail -n 200 config.log >&2 || true
251+ fi
252+ exit 1
253+ fi
254+ echo " Building netcdf-c ${netcdf_c_version} with make -j${make_jobs} " >&2
255+ if ! make -j" ${make_jobs} " ; then
256+ echo " Parallel netcdf-c build failed; retrying with make -j1 V=1 for clearer diagnostics" >&2
257+ make -j1 V=1
258+ fi
216259 make install
217260 )
218261
0 commit comments