diff options
author | allen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2001-03-10 15:23:42 +0000 |
---|---|---|
committer | allen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2001-03-10 15:23:42 +0000 |
commit | c7b4df6f78c0f9673fd7e67f6ea639f3c2ff9679 (patch) | |
tree | cc8b0457da933c1cdd11012abfc01c3f10dc21d9 /lib/make/configure.pl | |
parent | 416d2129ea3832a988e91ba61542f423525f6b88 (diff) |
Fix for Cactus/547 and more.
Hopefully configuring with and without the different fortran compilers
now works. You can (hopefully) say
F90=none
and/or
F77=none
and get no complaints about unknown compilers and get all the underscores sorted out.
In doing this I removed for now the F90_NOT_SET that I had put in before
so that you get a semi decent line if you try and compile a fortran file
with no fortran compiler since it was stretching my logic capabilities. Now
you will get a less decent line, but it will still say "none" for the
compiler rather than saying nothing. I'll try and remember to put it
back.
I'm think we can easily add the ability to have different F77 and F90
compilers as well, so long as they have the same underscore behaviour,
but probably noone needs that.
git-svn-id: http://svn.cactuscode.org/flesh/trunk@2074 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib/make/configure.pl')
-rwxr-xr-x | lib/make/configure.pl | 396 |
1 files changed, 223 insertions, 173 deletions
diff --git a/lib/make/configure.pl b/lib/make/configure.pl index 68ad9555..0be47791 100755 --- a/lib/make/configure.pl +++ b/lib/make/configure.pl @@ -31,97 +31,26 @@ foreach $line (@routines) sub test_fortran_name { local($data); + local($use_f77,$use_f90); local($retcode, $line, $name, $case, $n_underscores); local($underscore_suffix, $normal_suffix, $case_prefix); - if($compiler && $compiler ne "" && $compiler !~ /NOT_SET/) - { - # Create a test file - open(OUT, ">fname_test.f") || die "Cannot open fname_test.f\n"; - - print OUT <<EOT; - subroutine test(a) - integer a - a = 1 - call test_name(a) - return - end - -EOT - - close OUT; - - # Compile the test file - print "Compiling test file with $compiler $opts...\n"; - system("$compiler $opts -c fname_test.f"); - - $retcode = $? >> 8; - - if($retcode > 0) - { - print "Failed to compile fname_test.f\n"; - } - - - # Search the object file for the appropriate symbols - open(IN, "<fname_test.o") || open(IN, "<fname_test.obj") || die "Cannot open fname_test.o\n"; - - while(<IN>) - { - $line = $_; - if($line =~ m:(TEST_NAME)(_*):i) - { - $name = $1; - $underscores = $2; - - # Extremely quick hack to sort out problems later on with common block - # names. - - if($_ =~ m:_TEST_NAME:i) - { - $symbols_preceeded_by_underscores=1; - } - else - { - $symbols_preceeded_by_underscores=0; - } - - # Find out suffices. - if($name =~ m:TEST_NAME:) - { - print "Uppercase - "; - $case = 1; - } - if($name =~ m:test_name:) - { - print "Lowercase - "; - $case = 0; - } - if($underscores eq "") - { - print " No trailing underscore\n"; - $n_underscores = 0; - } - if($underscores eq "_") - { - print "One trailing underscore\n"; - $n_underscores = 1; - } - if($underscores eq "__") - { - print "Two trailing underscores\n"; - $n_underscores = 2; - } - - last; - } - } - - close IN; - - # Delete the temporary files - unlink <fname_test.*>; + $use_f77 = 0; + $use_f90 = 0; + if($compiler_f77 && $compiler_f77 ne "" && $compiler_f77 !~ /none/) + { + ($case, $n_underscores) = &compile_fortran_common_name($compiler_f77,$opts_f77); + $use_f77 = 1; + } + elsif ($compiler_f90 && $compiler_f90 ne "" && $compiler_f90 !~ /none/) + { + ($case, $n_underscores) = &compile_fortran_common_name($compiler_f90,$opts_f90); + $use_f90 = 1; + } + + if($use_f90 || $use_f77) + { # Determine the case and number of underscores ($underscore_suffix, $normal_suffix, $case_prefix) = &determine_transformation($n_underscores, $case); @@ -173,93 +102,22 @@ sub test_fortran_common_name local($retcode, $line, $name, $case, $n_underscores); local($underscore_suffix, $normal_suffix, $case_prefix); - if($compiler && $compiler ne "" && $compiler !~ /NOT_SET/) - { - # Create a test file - open(OUT, ">fname_test.f") || die "Cannot open fname_test.f\n"; - - print OUT <<EOT; - subroutine test_name - real b - common /test_common/b - b = 2.0 - return - end - -EOT - - close OUT; - - # Compile the test file - print "Compiling test file with $compiler $opts...\n"; - system("$compiler $opts -c fname_test.f"); - - $retcode = $? >> 8; - - if($retcode > 0) - { - print "Failed to compile fname_test.f\n"; - } - - - # Search the object file for the appropriate symbols - open(IN, "<fname_test.o") || open(IN, "<fname_test.obj") || die "Cannot open fname_test.o\n"; - - while(<IN>) - { - $line = $_; - if($line =~ m:(_[\w_]*)?(TEST_COMMON)(_*):i) - { - $prefix = $1; - $name = $2; - $underscores = $3; - - # This is a pain. If all symbols have underscores, need to remove - # the first one here. - - if($symbols_preceeded_by_underscores) - { - if($prefix =~ m:^_(.*):) - { - $prefix = $1; - } - } - - if($name =~ m:TEST_COMMON:) - { - print "Uppercase - "; - $case = 1; - } - if($name =~ m:test_common:) - { - print "Lowercase - "; - $case = 0; - } - if($underscores eq "") - { - print " No trailing underscore\n"; - $n_underscores = 0; - } - if($underscores eq "_") - { - print "One trailing underscore\n"; - $n_underscores = 1; - } - if($underscores eq "__") - { - print "Two trailing underscores\n"; - $n_underscores = 2; - } - - last; - } - } - - close IN; - - # Delete the temporary files - unlink <fname_test.*>; + $use_f77 = 0; + $use_f90 = 0; + if($compiler_f77 && $compiler_f77 ne "" && $compiler_f77 !~ /none/) + { + ($case, $n_underscores) = &compile_fortran_common_name($compiler_f77,$opts_f77); + $use_f77 = 1; + } + elsif ($compiler_f90 && $compiler_f90 ne "" && $compiler_f90 !~ /none/) + { + ($case, $n_underscores) = &compile_fortran_common_name($compiler_f90,$opts_f90); + $use_f90 = 1; + } + + if($use_f90 || $use_f77) + { # Determine the case and number of underscores ($underscore_suffix, $normal_suffix, $case_prefix) = &determine_transformation($n_underscores, $case); @@ -336,3 +194,195 @@ sub determine_transformation return ($underscore_suffix, $normal_suffix, $case_prefix); } + + +sub compile_fortran_common_name +{ + local($compiler,$opts) = @_; + local($data); + local($retcode, $line, $name, $case, $n_underscores); + local($underscore_suffix, $normal_suffix, $case_prefix); + + # Create a test file + open(OUT, ">fname_test.f") || die "Cannot open fname_test.f\n"; + + print OUT <<EOT; + subroutine test_name + real b + common /test_common/b + b = 2.0 + return + end + +EOT + + close OUT; + + # Compile the test file + print "Compiling test file with $compiler $opts ...\n"; + system("$compiler $opts -c fname_test.f"); + + $retcode = $? >> 8; + + if($retcode > 0) + { + print "Failed to compile fname_test.f\n"; + } + + + # Search the object file for the appropriate symbols + open(IN, "<fname_test.o") || open(IN, "<fname_test.obj") || die "Cannot open fname_test.o\n"; + + while(<IN>) + { + $line = $_; + if($line =~ m:(_[\w_]*)?(TEST_COMMON)(_*):i) + { + $prefix = $1; + $name = $2; + $underscores = $3; + + # This is a pain. If all symbols have underscores, need to remove + # the first one here. + + if($symbols_preceeded_by_underscores) + { + if($prefix =~ m:^_(.*):) + { + $prefix = $1; + } + } + + if($name =~ m:TEST_COMMON:) + { + print "Uppercase - "; + $case = 1; + } + if($name =~ m:test_common:) + { + print "Lowercase - "; + $case = 0; + } + if($underscores eq "") + { + print " No trailing underscore\n"; + $n_underscores = 0; + } + if($underscores eq "_") + { + print "One trailing underscore\n"; + $n_underscores = 1; + } + if($underscores eq "__") + { + print "Two trailing underscores\n"; + $n_underscores = 2; + } + + last; + } + } + + close IN; + + # Delete the temporary files + unlink <fname_test.*>; + + return ($case,$n_underscores); +} + + +sub compile_fortran_name +{ + local($compiler,$opts) = @_; + local($data); + local($retcode, $line, $name, $case, $n_underscores); + local($underscore_suffix, $normal_suffix, $case_prefix); + + # Create a test file + open(OUT, ">fname_test.f") || die "Cannot open fname_test.f\n"; + + print OUT <<EOT; + subroutine test(a) + integer a + a = 1 + call test_name(a) + return + end + +EOT + + close OUT; + + # Compile the test file + print "Compiling test file with $compiler_f77 $opts_f77 ...\n"; + system("$compiler_f77 $opts_f77 -c fname_test.f"); + + $retcode = $? >> 8; + + if($retcode > 0) + { + print "Failed to compile fname_test.f\n"; + } + + + # Search the object file for the appropriate symbols + open(IN, "<fname_test.o") || open(IN, "<fname_test.obj") || die "Cannot open fname_test.o\n"; + + while(<IN>) + { + $line = $_; + if($line =~ m:(TEST_NAME)(_*):i) + { + $name = $1; + $underscores = $2; + + # Extremely quick hack to sort out problems later on with common block + # names. + + if($_ =~ m:_TEST_NAME:i) + { + $symbols_preceeded_by_underscores=1; + } + else + { + $symbols_preceeded_by_underscores=0; + } + + # Find out suffices. + if($name =~ m:TEST_NAME:) + { + print "Uppercase - "; + $case = 1; + } + if($name =~ m:test_name:) + { + print "Lowercase - "; + $case = 0; + } + if($underscores eq "") + { + print " No trailing underscore\n"; + $n_underscores = 0; + } + if($underscores eq "_") + { + print "One trailing underscore\n"; + $n_underscores = 1; + } + if($underscores eq "__") + { + print "Two trailing underscores\n"; + $n_underscores = 2; + } + + last; + } + } + + close IN; + + # Delete the temporary files + unlink <fname_test.*>; + +} |