[Dart-dev] [3805] DART/trunk/mkmf/mkmf: This change largely tracks Balaji' s version for FMS
nancy at ucar.edu
nancy at ucar.edu
Thu Apr 9 14:30:34 MDT 2009
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/dart-dev/attachments/20090409/702c3898/attachment.html
-------------- next part --------------
Modified: DART/trunk/mkmf/mkmf
===================================================================
--- DART/trunk/mkmf/mkmf 2009-04-09 20:29:25 UTC (rev 3804)
+++ DART/trunk/mkmf/mkmf 2009-04-09 20:30:33 UTC (rev 3805)
@@ -43,7 +43,7 @@
use File::Basename;
use Getopt::Std;
use Config; # use to put in platform-specific stuff
-use vars qw( $opt_a $opt_c $opt_d $opt_f $opt_m $opt_p $opt_t $opt_v $opt_w $opt_x ); # declare these global to be shared with Getopt:Std
+use vars qw( $opt_a $opt_c $opt_d $opt_f $opt_l $opt_m $opt_o $opt_p $opt_t $opt_v $opt_w $opt_x ); # declare these global to be shared with Getopt:Std
#subroutines
sub ensureTrailingSlash {
@@ -54,7 +54,7 @@
my $version = '$Id$ ';
# initialize variables: use getopts for these
-getopts( 'a:c:dfm:p:t:vwx' ) || die "\aSyntax: $0 [-a abspath] [-c cppdefs] [-d] [-f] [-m makefile] [-p program] [-t template] [-v] [-w] [-x] [targets]\n";
+getopts( 'a:c:df:l:m:o:p:t:vwx' ) || die "\aSyntax: $0 [-a abspath] [-c cppdefs] [-d] [-f] [-l loadflags] [-m makefile] [-o otherflags] [-p program] [-t template] [-v] [-w] [-x] [targets]\n";
$opt_v = 1 if $opt_d; # debug flag turns on verbose flag also
print "$0 $version\n" if $opt_v;
@@ -79,23 +79,24 @@
my @src_suffixes = ( q/\.F/, q/\.F90/, q/\.c/, q/\.f/, q/\.f90/ );
my @inc_suffixes = ( q/\.H/, q/\.fh/, q/\.h/, q/\.inc/ );
push @inc_suffixes, @src_suffixes; # sourcefiles can be includefiles too
+my @tgt_suffixes = ( q/\.a/ );
print "Using MPI wrappers\n" if $opt_w;
my %compile_cmd;
if ( $opt_w ) {
- %compile_cmd = ( # mpi wrappers to create .o file from a given source file suffix
- q/.F/ => q/$(MPIFC) $(CPPDEFS) $(CPPFLAGS) $(FFLAGS) -c/,
- q/.F90/ => q/$(MPIFC) $(CPPDEFS) $(CPPFLAGS) $(FFLAGS) -c/,
- q/.c/ => q/$(MPICC) $(CPPDEFS) $(CPPFLAGS) $(CFLAGS) -c/,
- q/.f/ => q/$(MPIFC) $(FFLAGS) -c/,
- q/.f90/ => q/$(MPIFC) $(FFLAGS) -c/ );
+ %compile_cmd = ( # mpi wrappers to create .o file from a given source file suffix
+ q/.F/ => q/$(MPIFC) $(CPPDEFS) $(CPPFLAGS) $(FFLAGS) $(OTHERFLAGS) -c/,
+ q/.F90/ => q/$(MPIFC) $(CPPDEFS) $(CPPFLAGS) $(FFLAGS) $(OTHERFLAGS) -c/,
+ q/.c/ => q/$(MPICC) $(CPPDEFS) $(CPPFLAGS) $(CFLAGS) $(OTHERFLAGS) -c/,
+ q/.f/ => q/$(MPIFC) $(FFLAGS) $(OTHERFLAGS) -c/,
+ q/.f90/ => q/$(MPIFC) $(FFLAGS) $(OTHERFLAGS) -c/ );
} else {
- %compile_cmd = ( # default command to create .o file from a given source file suffix
- q/.F/ => q/$(FC) $(CPPDEFS) $(CPPFLAGS) $(FFLAGS) -c/,
- q/.F90/ => q/$(FC) $(CPPDEFS) $(CPPFLAGS) $(FFLAGS) -c/,
- q/.c/ => q/$(CC) $(CPPDEFS) $(CPPFLAGS) $(CFLAGS) -c/,
- q/.f/ => q/$(FC) $(FFLAGS) -c/,
- q/.f90/ => q/$(FC) $(FFLAGS) -c/ );
+ %compile_cmd = ( # default command to create .o file from a given source file suffix
+ q/.F/ => q/$(FC) $(CPPDEFS) $(CPPFLAGS) $(FFLAGS) $(OTHERFLAGS) -c/,
+ q/.F90/ => q/$(FC) $(CPPDEFS) $(CPPFLAGS) $(FFLAGS) $(OTHERFLAGS) -c/,
+ q/.c/ => q/$(CC) $(CPPDEFS) $(CPPFLAGS) $(CFLAGS) $(OTHERFLAGS) -c/,
+ q/.f/ => q/$(FC) $(FFLAGS) $(OTHERFLAGS) -c/,
+ q/.f90/ => q/$(FC) $(FFLAGS) $(OTHERFLAGS) -c/ );
}
my %delim_match = ( q/'/ => q/'/, # hash to find includefile delimiter pair
q/"/ => q/"/,
@@ -142,8 +143,9 @@
}
&print_formatted_list("CPPDEFS = $opt_c") if $opt_c;
}
-print MAKEFILE "\n.DEFAULT:\n\t-touch \$@\n";
-print MAKEFILE "all: $opt_p\n"; # first target should be program, so you can type just 'make'
+print MAKEFILE "\nOTHERFLAGS = $opt_o" if $opt_o;
+print MAKEFILE "\n.DEFAULT:\n\t-touch \$@\n";
+print MAKEFILE "all: $opt_p\n"; # first target should be program, so you can type just 'make'
#if cppdefs flag is present, look for changes in cppdefs
my %chgdefs;
@@ -456,10 +458,15 @@
print MAKEFILE "localize: \$(OFF)\n\tcp \$(OFF) .\n" if $noff > 0;
print MAKEFILE "TAGS: \$(SRC)\n\tetags \$(SRC)\n";
print MAKEFILE "tags: \$(SRC)\n\tctags \$(SRC)\n";
-if ( $opt_w ) {
- print MAKEFILE "$opt_p: \$(OBJ)\n\t\$(MPILD) \$(OBJ) -o $opt_p \$(LDFLAGS)\n";
+( $name, $path, $suffix ) = fileparse( $opt_p, @tgt_suffixes );
+if( $suffix eq '.a' ) {
+ print MAKEFILE "$opt_p: \$(OBJ)\n\t\$(AR) \$(ARFLAGS) $opt_p \$(OBJ)\n";
+} elsif ( $opt_w ){
+ print MAKEFILE "$opt_p: \$(OBJ)\n\t\$(MPILD) \$(OBJ) -o $opt_p $opt_l \$(LDFLAGS)\n";
} else {
- print MAKEFILE "$opt_p: \$(OBJ)\n\t\$(LD) \$(OBJ) -o $opt_p \$(LDFLAGS)\n";
+# opt_l is a new flag added to take care of libraries
+# print MAKEFILE "$opt_p: \$(OBJ) $opt_l\n\t\$(LD) \$(OBJ) -o $opt_p $opt_l \$(LDFLAGS)\n";
+ print MAKEFILE "$opt_p: \$(OBJ)\n\t\$(LD) \$(OBJ) -o $opt_p $opt_l \$(LDFLAGS)\n";
}
close MAKEFILE;
print " $opt_m is ready.\n";
More information about the Dart-dev
mailing list