Skip to content

Commit 033c597

Browse files
committed
Merge pull request open-mpi#619 from miked-mellanox/topic/v2.x_vendor_patches
v2.x - BUILD: allow platform patches
2 parents 5fabe48 + 2e2e0a6 commit 033c597

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

config/opal_load_platform.m4

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,73 @@ AC_DEFUN([OPAL_LOAD_PLATFORM], [
9797
AC_SUBST(OPAL_PARAM_FROM_PLATFORM, "no")
9898
fi
9999

100+
patch_dir="${with_platform}.patches"
101+
patch_done="${srcdir}/.platform_patches"
102+
patch_found=no
103+
104+
if test -d "${patch_dir}"; then
105+
if test ! -f "${patch_done}"; then
106+
107+
AC_MSG_NOTICE([Checking patches from ${patch_dir}/ directory ])
108+
for one_patch in $patch_dir/*.patch ; do
109+
110+
AC_MSG_CHECKING([patch: $one_patch for errors ])
111+
patch -d ${srcdir} -p1 -t -s --dry-run < ${one_patch}
112+
if test "$?" != "0"; then
113+
AC_MSG_RESULT([fail])
114+
AC_MSG_ERROR([Platform patches failed to apply])
115+
else
116+
AC_MSG_RESULT([ok])
117+
fi
118+
119+
AC_MSG_CHECKING([patch: $one_patch for unsupported configury changes ])
120+
has_configury_items=$(patch -d ${srcdir} -p1 -t --dry-run < ${one_patch} 2>&1 | egrep "^patching" | egrep '*\.(am|m4)$' | wc -l)
121+
122+
if test $has_configury_items -ne 0; then
123+
AC_MSG_RESULT([fail])
124+
AC_MSG_ERROR([Platform patches should not change configury files])
125+
else
126+
AC_MSG_RESULT([ok])
127+
fi
128+
done
129+
130+
131+
for one_patch in $patch_dir/*.patch ; do
132+
AC_MSG_NOTICE([Applying patch ${one_patch}])
133+
patch -d ${srcdir} -p1 -t -s < ${one_patch}
134+
if test "$?" != "0"; then
135+
AC_MSG_ERROR([Failed to apply patch ${one_patch}])
136+
fi
137+
patch_found=yes
138+
done
139+
140+
if test "$patch_found" = "yes"; then
141+
142+
platform_root_short="$(basename $platform_base)"
143+
144+
# If platform file resides under platform/ root folder - use filename as ident
145+
if [ test "$platform_root_short" = "platform" ]; then
146+
platform_ident="$platform_file"
147+
else
148+
platform_ident="$(basename $platform_base)"
149+
fi
150+
151+
# Set custom ident for platform patched OMPI
152+
if [ test -z "$with_ident_string" ]; then
153+
with_ident_string="Platform: $platform_ident"
154+
fi
155+
156+
AC_MSG_NOTICE([Platform patches applied, created stamp file ${patch_done}])
157+
touch ${patch_done}
158+
fi
159+
160+
else
161+
AC_MSG_WARN([Platform patches already applied, skipping. ${patch_done} can be removed to re-apply ])
162+
fi
163+
else
164+
AC_MSG_NOTICE([No platform patches in ${patch_dir}])
165+
fi
166+
100167
else
101168
AC_SUBST(OPAL_DEFAULT_MCA_PARAM_CONF, [openmpi-mca-params.conf])
102169
fi

0 commit comments

Comments
 (0)