55# Copyright (c) 2013 Mellanox Technologies, Inc.
66# All rights reserved.
77# Copyright (c) 2013-2014 Intel, Inc. All rights reserved.
8+ # Copyright (c) 2015 Research Organization for Information Science
9+ # and Technology (RIST). All rights reserved.
810# $COPYRIGHT$
911#
1012# Additional copyrights may follow
@@ -180,7 +182,6 @@ sub process_subdir {
180182 print " --- Found configure.in|ac; running autoreconf...\n " ;
181183 safe_system(" autoreconf -ivf" );
182184 print " --- Patching autotools output... :-(\n " ;
183- patch_autotools_output($start );
184185 } else {
185186 my_die " Found subdir, but no autogen.sh or configure.in|ac to do anything" ;
186187 }
@@ -189,6 +190,9 @@ sub process_subdir {
189190 my_die " Did not generate a \" configure\" executable in $dir .\n "
190191 if (! -x " configure" );
191192
193+ # Fix known issues in Autotools output
194+ patch_autotools_output($start );
195+
192196 # Chdir back to where we came from
193197 chdir ($start );
194198}
@@ -900,13 +904,19 @@ sub patch_autotools_output {
900904 unlink (" config/ltmain.sh.rej" );
901905 }
902906
907+ # If there's no configure script, there's nothing else to do.
908+ return
909+ if (! -f " configure" );
910+ my @verbose_out ;
911+
903912 # Total ugh. We have to patch the configure script itself. See below
904913 # for explainations why.
905914 open (IN, " configure" ) || my_die " Can't open configure" ;
906915 my $c ;
907916 $c .= $_
908917 while (<IN>);
909918 close (IN);
919+ my $c_orig = $c ;
910920
911921 # LT <=2.2.6b need to be patched for the PGI 10.0 fortran compiler
912922 # name (pgfortran). The following comes from the upstream LT patches:
@@ -915,7 +925,7 @@ sub patch_autotools_output {
915925 # Note that that patch is part of Libtool (which is not in this OMPI
916926 # source tree); we can't fix it. So all we can do is patch the
917927 # resulting configure script. :-(
918- verbose " $indent_str " . " Patching configure for Libtool PGI 10 fortran compiler name\n " ;
928+ push ( @verbose_out , $indent_str . " Patching configure for Libtool PGI 10 fortran compiler name\n " ) ;
919929 $c =~ s / gfortran g95 xlf95 f95 fort ifort ifc efc pgf95 lf95 ftn/ gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn/ g ;
920930 $c =~ s / pgcc\* \| pgf77\* \| pgf90\* \| pgf95\*\) / pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)/ g ;
921931 $c =~ s / pgf77\* \| pgf90\* \| pgf95\*\) / pgf77* | pgf90* | pgf95* | pgfortran*)/ g ;
@@ -925,7 +935,7 @@ sub patch_autotools_output {
925935 # Libtool install; all we can do is patch the resulting configure
926936 # script. :-( The following comes from the upstream patch:
927937 # http://lists.gnu.org/archive/html/libtool-patches/2009-11/msg00016.html
928- verbose " $indent_str " . " Patching configure for Libtool PGI version number regexps\n " ;
938+ push ( @verbose_out , $indent_str . " Patching configure for Libtool PGI version number regexps\n " ) ;
929939 $c =~ s /\* pgCC\\ \[ 1-5\]\* \| \* pgcpp\\ \[ 1-5\]\* / *pgCC\\ [1-5]\. * | *pgcpp\\ [1-5]\. */ g ;
930940
931941 # Similar issue as above -- fix the case statements that handle the Sun
@@ -960,16 +970,30 @@ sub patch_autotools_output {
960970 ;;
961971" ;
962972
963- verbose " $indent_str " . " Patching configure for Sun Studio Fortran version strings ($tag )\n " ;
973+ push ( @verbose_out , $indent_str . " Patching configure for Sun Studio Fortran version strings ($tag )\n " ) ;
964974 $c =~ s / $search_string/ $replace_string / ;
965975 }
966976
967977 # See http://git.savannah.gnu.org/cgit/libtool.git/commit/?id=v2.2.6-201-g519bf91 for details
968978 # Note that this issue was fixed in LT 2.2.8, however most distros are still using 2.2.6b
969979
970- verbose " $indent_str " . " Patching configure for IBM xlf libtool bug\n " ;
980+ push ( @verbose_out , $indent_str . " Patching configure for IBM xlf libtool bug\n " ) ;
971981 $c =~ s / (\$ LD -shared \$ libobjs \$ deplibs \$ )compiler_flags( -soname \$ soname)/ $1linker_flags$2 / g ;
972982
983+ # Fix consequence of broken libtool.m4 from libtool 2.4.3
984+ # see http://lists.gnu.org/archive/html/bug-libtool/2015-07/msg00002.html
985+ push (@verbose_out , $indent_str . " Patching configure for libtool.m4 bug\n " );
986+ $c =~ s / test x-L = \"\$ p\" / test x-L = \" x\$ p\" / g ;
987+ $c =~ s / test x-R = \"\$ p\" / test x-R = \" x\$ p\" / g ;
988+
989+ # Only write out verbose statements and a new configure if the
990+ # configure content actually changed
991+ return
992+ if ($c eq $c_orig );
993+ foreach my $str (@verbose_out ) {
994+ verbose($str );
995+ }
996+
973997 open (OUT, " >configure.patched" ) || my_die " Can't open configure.patched" ;
974998 print OUT $c ;
975999 close (OUT);
@@ -1289,6 +1313,8 @@ sub patch_autotools_output {
12891313}
12901314safe_system($cmd );
12911315
1316+ patch_autotools_output(" ." );
1317+
12921318# ---------------------------------------------------------------------------
12931319
12941320verbose "
0 commit comments