1dnl -*- shell-script -*- 2dnl 3dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana 4dnl University Research and Technology 5dnl Corporation. All rights reserved. 6dnl Copyright (c) 2004-2005 The University of Tennessee and The University 7dnl of Tennessee Research Foundation. All rights 8dnl reserved. 9dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 10dnl University of Stuttgart. All rights reserved. 11dnl Copyright (c) 2004-2005 The Regents of the University of California. 12dnl All rights reserved. 13dnl Copyright (c) 2014 Intel, Inc. All rights reserved. 14dnl Copyright (c) 2015 Research Organization for Information Science 15dnl and Technology (RIST). All rights reserved. 16dnl $COPYRIGHT$ 17dnl 18dnl Additional copyrights may follow 19dnl 20dnl $HEADER$ 21dnl 22 23# OPAL_LOAD_PLATFORM() 24# -------------------- 25AC_DEFUN([OPAL_LOAD_PLATFORM], [ 26 AC_ARG_WITH([platform-patches-dir], 27 [AC_HELP_STRING([--with-platform-patches-dir=DIR], 28 [Location of the platform patches directory. If you use this option, you must also use --with-platform.])]) 29 30 AC_ARG_WITH([platform], 31 [AC_HELP_STRING([--with-platform=FILE], 32 [Load options for build from FILE. Options on the 33 command line not in FILE are used. Options on the 34 command line and in FILE are replaced by what is 35 in FILE.])]) 36 m4_ifval([autogen_platform_file], [ 37 if test "$with_platform" = "" ; then 38 with_platform=autogen_platform_file 39 fi]) 40 if test "$with_platform" = "yes" ; then 41 AC_MSG_ERROR([--with-platform argument must include FILE option]) 42 elif test "$with_platform" = "no" ; then 43 AC_MSG_ERROR([--without-platform is not a valid argument]) 44 elif test "$with_platform" != "" ; then 45 # if not an absolute path, check in contrib/platform 46 if test ! "`echo $with_platform | cut -c1`" = "/" && test ! "`echo $with_platform | cut -c2`" = ".." ; then 47 if test -r "${srcdir}/contrib/platform/$with_platform" ; then 48 with_platform="${srcdir}/contrib/platform/$with_platform" 49 fi 50 fi 51 52 # make sure file exists 53 if test ! -r "$with_platform" ; then 54 AC_MSG_ERROR([platform file $with_platform not found]) 55 fi 56 57 # eval into environment 58 OPAL_LOG_MSG([Loading environment file $with_platform, with contents below]) 59 OPAL_LOG_FILE([$with_platform]) 60 61 # setup by getting full pathname for the platform directories 62 platform_base="`dirname $with_platform`" 63 platform_file="`basename $with_platform`" 64 # get full pathname of where we are so we can return 65 platform_savedir="`pwd`" 66 # go to where the platform file is located 67 cd "$platform_base" 68 # get the full path to this location 69 platform_file_dir=`pwd` 70 71 . ./"$platform_file" 72 73 # see if they left us a name 74 if test "$OPAL_PLATFORM_LOADED" != "" ; then 75 platform_loaded="$OPAL_PLATFORM_LOADED" 76 else 77 platform_loaded="$with_platform" 78 fi 79 echo "Loaded platform arguments for $platform_loaded" 80 OPAL_LOG_MSG([Loaded platform arguments for $platform_loaded]) 81 82 # look for default mca param file 83 84 # return to where we started 85 cd "$platform_savedir" 86 87 # define an alternate default mca param filename 88 platform_alt_mca_file="`basename $platform_loaded`.conf" 89 90 # look where platform file is located for platform.conf name 91 if test -r "${platform_file_dir}/${platform_alt_mca_file}" ; then 92 AC_SUBST(OPAL_DEFAULT_MCA_PARAM_CONF, [$platform_file_dir/$platform_alt_mca_file]) 93 AC_SUBST(OPAL_PARAM_FROM_PLATFORM, "yes") 94 # if not, see if a file is there with the default name 95 elif test -r "${platform_file_dir}/openmpi-mca-params.conf" ; then 96 AC_SUBST(OPAL_DEFAULT_MCA_PARAM_CONF, [$platform_file_dir/openmpi-mca-params.conf]) 97 AC_SUBST(OPAL_PARAM_FROM_PLATFORM, "yes") 98 # if not, then just use the default 99 else 100 AC_SUBST(OPAL_DEFAULT_MCA_PARAM_CONF, [openmpi-mca-params.conf]) 101 AC_SUBST(OPAL_PARAM_FROM_PLATFORM, "no") 102 fi 103 104 patch_dir="${with_platform}.patches" 105 if test -n "$with_platform_patches_dir"; then 106 if test "$with_platform_patches_dir" = "yes"; then 107 patch_dir="${with_platform}.patches" 108 elif test "$with_platform_patches_dir" = "no"; then 109 AC_MSG_NOTICE([Disabling platform patches on user request]) 110 patch_dir="" 111 elif test -d "$with_platform_patches_dir"; then 112 patch_dir=$with_platform_patches_dir 113 else 114 AC_MSG_ERROR([User provided patches directory: $with_platform_patches_dir not found]) 115 fi 116 fi 117 118 patch_done="${srcdir}/.platform_patches" 119 patch_found=no 120 121 if test -d "${patch_dir}"; then 122 if test ! -f "${patch_done}"; then 123 124 AC_MSG_NOTICE([Checking patches from ${patch_dir}/ directory ]) 125 for one_patch in $patch_dir/*.patch ; do 126 127 AC_MSG_CHECKING([patch: $one_patch for errors ]) 128 patch -d ${srcdir} -p1 -t -s --dry-run < ${one_patch} 129 if test "$?" != "0"; then 130 AC_MSG_RESULT([fail]) 131 AC_MSG_ERROR([Platform patches failed to apply]) 132 else 133 AC_MSG_RESULT([ok]) 134 fi 135 136 AC_MSG_CHECKING([patch: $one_patch for unsupported configury changes ]) 137 has_configury_items=$(patch -d ${srcdir} -p1 -t --dry-run < ${one_patch} 2>&1 | egrep "^patching" | egrep '*\.(am|m4)$' | wc -l) 138 139 if test $has_configury_items -ne 0; then 140 AC_MSG_RESULT([fail]) 141 AC_MSG_ERROR([Platform patches should not change configury files]) 142 else 143 AC_MSG_RESULT([ok]) 144 fi 145 done 146 147 148 for one_patch in $patch_dir/*.patch ; do 149 AC_MSG_NOTICE([Applying patch ${one_patch}]) 150 patch -d ${srcdir} -p1 -t -s < ${one_patch} 151 if test "$?" != "0"; then 152 AC_MSG_ERROR([Failed to apply patch ${one_patch}]) 153 fi 154 patch_found=yes 155 done 156 157 if test "$patch_found" = "yes"; then 158 159 platform_root_short="$(basename $platform_base)" 160 161 # If platform file resides under platform/ root folder - use filename as ident 162 if [ test "$platform_root_short" = "platform" ]; then 163 platform_ident="$platform_file" 164 else 165 platform_ident="$(basename $platform_base)" 166 fi 167 168 # Set custom ident for platform patched OMPI 169 if [ test -z "$with_ident_string" ]; then 170 with_ident_string="Platform: $platform_ident" 171 fi 172 173 AC_MSG_NOTICE([Platform patches applied, created stamp file ${patch_done}]) 174 touch ${patch_done} 175 else 176 AC_MSG_NOTICE([No platform patches in ${patch_dir}]) 177 fi 178 179 else 180 AC_MSG_WARN([Platform patches already applied, skipping. ${patch_done} can be removed to re-apply ]) 181 fi 182 elif test -n "${patch_dir}"; then 183 AC_MSG_NOTICE([No platform patches in ${patch_dir}]) 184 fi 185 else 186 AC_SUBST(OPAL_DEFAULT_MCA_PARAM_CONF, [openmpi-mca-params.conf]) 187 fi 188]) 189