#***************************************************************************** # AUTOMATIC MAKEFILE GENERATOR # # (makemake) # # Rosario Caltabiano October 7, 1987 # # ALLIANT COMPUTER SYSTEMS CORPORATION # #***************************************************************************** # # The "makemake" command generates automatically the makefile needed to # build the executable image of a fortran application program to be run on an # ALLIANT computer. # No input parameters are necessary - all the needed information is # interactively provided by the user as answer to specific questions asked by # makemake. Makemake simply looks at all the *.f files and generates a makefile # depending on the input given during the interactive dialog that precedes the # generation itself. # # The command is able to generate a makefile that is capable of handling: # # * different directories than the current for source and object files # * archive of object files # * compiler options # * subroutine-by-subroutine last-update dependency # * libraries # * SCCS environment (Berkeley Interface) # # # JUST TYPE "makemake" AND TRY IT OUT ! # #**************************************************************************** # # GET INPUT PARAMETERS # if ( -e Makefile | -e makefile ) then if ( -e Makefile ) then set ttt = Makefile else set ttt = makefile endif echo 'YOUR MAKEFILE IS BEING SAVED IN "'$ttt'.save"' echo ' ' cp $ttt $ttt'.save' endif echo echo 'Type image name (press return if a.out)' set image = $< if ( $image == '') then set image = a.out endif echo 'Type directory containing sources (press return if current directory)' set srcdir = $< if ($srcdir != '') then set srcdirroot = $srcdir set srcdir = $srcdir'/' else set srcdirroot = '' endif echo 'If you want to place your objects in a library, type name of library' echo 'press return otherwise' set ans = $< if ($ans != '') then set objlib = $ans set objdir = '' else echo 'Type directory containing objects (press return if current directory)' set objlib = '' set objdir = $< if ($objdir != '') then set objdir = $objdir'/' endif endif echo 'List additional libraries and/or objects to add to the link (or return)' set libraries = $< echo "Type fortran options (you don't need to type -c)" set opt = $< echo "Type linkage options (return if same as compiler options)" set linkopt = $< if ("$linkopt" == '') then set linkopt = ($opt[*]) endif echo 'Type name of makefile to be generated (press return for "Makefile")' set makefile = $< if ($makefile == '') then set makefile = Makefile endif echo Generating $makefile . . . . . if ( -d $srcdir'SCCS' && -e $srcdir'SCCS' ) then set Sccs = 1 set files = $srcdir'SCCS/s.*.f' else set files = $srcdir'*.f' set Sccs = 0 endif # # COUNT FILES # @ number_of_files = 0 foreach src ($files) @ number_of_files = $number_of_files + 1 end # # GENERATE MAKEFILE # echo 'OBJ = \' > $makefile if ($objlib != '') then echo ' '$objlib >> $makefile else @ count = 0 foreach src ($files) set srcf = $src if ( $Sccs == 1 ) then set temp = $src:t set temp = $temp:r set srcf = $temp:e'.f' endif set srco = $srcf:t set srco = $objdir$srco:r.o @ count = $count + 1 if ( $count < $number_of_files ) then echo ' '$srco' \' >> $makefile else echo ' '$srco >> $makefile endif end endif echo ' ' >> $makefile echo 'OPT = '$opt >> $makefile echo ' ' >> $makefile echo 'LINKOPT = '$linkopt >> $makefile echo ' ' >> $makefile echo 'LIBS = '$libraries >> $makefile echo ' ' >> $makefile echo $image' : $(OBJ)' >> $makefile if ($objlib != '') then echo ' ranlib' $objlib >> $makefile endif echo ' fortran $(LINKOPT) $(OBJ) $(LIBS) -o '$image >> $makefile echo ' ' >> $makefile foreach src ($files) echo ' ' >> $makefile set srcf = $src if ( $Sccs == 1 ) then set temp = $src:t set temp = $temp:r set srcf = $temp:e'.f' set srcf = $srcdir$srcf endif if ($objlib != '') then set srco = $objlib echo $srco' :: '$srcf >> $makefile else set srco = $srcf:t set srco = $objdir$srco:r.o echo $srco' : '$srcf >> $makefile endif echo ' fortran -c $(OPT) '$srcf >> $makefile set srcftail = $srcf:t if ($objdir != '') then echo ' mv -f '$srcftail:r.o $srco >> $makefile echo ' rm -f '$srcftail:r.o >> $makefile endif if ($objlib != '') then echo ' ar r '$objlib $srcftail:r.o >> $makefile echo ' rm -f '$srcftail:r.o >> $makefile endif if ($Sccs == 1 ) then echo $srcf' : '$src >> $makefile echo ' sccs get '$srcf >> $makefile if ($srcdir != '') then echo ' mv -f '$srcf:t $srcf >> $makefile echo ' rm -f '$srcf:t >> $makefile endif endif end