next up previous contents
Nächste Seite: Über dieses Dokument ... Aufwärts: Sample Session Vorherige Seite: Fortran90/95 Source   Inhalt


Makefile

A working Makefile is shown in this section.


###
###  Makefile for some tests of fortran90/95 compilers
###

#
# notes:
# OSTYPE : defined by system
# F90    : defined by user in shell;  nag, lahey
# DEBUG 0/1
#

SRCDIR  = LAPACK77

SOURCES = test_lapack77.f90

INCLUDE_FILES = 
OBJECTS       = $(SOURCES:.f90=.o)
MODULES	      = *.mod
OUTPUT        = test_lapack77
MAKEFILE      = Makefile

RM = rm -f

# setting ostype 
OSTYPE    = $(shell uname)


# define standard Fortran90 compiler
FC = f90
LD = $(FC)
# define libs
BLAS      = -lblas
LAPACK77  = -llapack
LIBS      = $(LAPACK77) $(BLAS) $(SPECIAL_LIBG2C)

ifeq ($(OSTYPE), Linux)
##### linux #####
  ifeq ($(F90), nag)
    ### NAGf95 ###
    ## disable warnings from license manager
    export NAG_LM_OPTS=nowarn
    S_BLAS    = libblas.a libblas.so
    S_LAPACK  = liblapack.a liblapack.so
    FC        = f95-nag
    LD	      = $(FC)
    ifeq ($(DEBUG), 1)
      DEBUGFLAG = -C -g -g90 -gline
    else
      DEBUGFLAG = 
    endif
    FFLAGS    = -v -u -O4 -nan
    LDFLAGS   = 
    BLAS      = -lblas
    LAPACK77  = -llapack
    ifeq ($(DEBUG), 1)
      LIBS      = $(LAPACK77) $(BLAS) $(SPECIAL_LIBG2C) -lefence
    else
      LIBS      = $(LAPACK77) $(BLAS) $(SPECIAL_LIBG2C)
    endif
    CUT_ASM_WARN = 
  endif

  ifeq ($(F90), lahey)
    ### Lahey ###
    S_BLAS    = libblas.a libblas.so
    S_LAPACK  = liblapack.a liblapack.so
    FC        = f95-lah
    LD        = $(FC)
    ifeq ($(DEBUG), 1)
      DEBUGFLAG = --chk -g --trace
    else
      DEBUGFLAG = 
    endif
    FFLAGS    = --wo --warn --f95 -O --tpp --ap
    LDFLAGS   = 
    BLAS      = -lblas
    LAPACK77  = -llapack
    ifeq ($(DEBUG), 1)
      LIBS      = $(LAPACK77) $(BLAS) $(SPECIAL_LIBG2C) -lefence
    else
      LIBS      = $(LAPACK77) $(BLAS) $(SPECIAL_LIBG2C)
    endif
    CUT_ASM_WARN = 2>&1 | grep -v "/tmp/asm"
  endif
endif


$(OUTPUT): $(OBJECTS) 
	$(LD) $(OBJECTS) -o $(OUTPUT) $(LDFLAGS) $(LIBS) $(DEBUGFLAG)

%.o : %.f90 $(MAKEFILE) 
	$(FC) $(@:.o=.f90) -c -o $@ $(DEBUGFLAG) $(FFLAGS) $(CUT_ASM_WARN)


install: $(OUTPUT) 
	cp $(OUTPUT) $(HOME)/bin/$(OUTPUT)


basic-clean:
	$(RM) $(OBJECTS) $(MODULES)

clean: basic-clean
	( $(RM) *.o *.mod *.g90 *~ core \#* $(OUTPUT) )

dist:
	( cd ..; tar -zcvf $(SRCDIR)-`date +"%Y-%m-%d"`.tar.gz \
	  $(SRCDIR)/*.f90 $(SRCDIR)/test_lapack_in.dat \
	  $(SRCDIR)/Doc \
	  $(SRCDIR)/Makefile $(SRCDIR)/README \
	  $(SRCDIR)/no_arch -X $(SRCDIR)/no_arch )

distclean: clean dist

The meaning of important variables is as follows:

FC
Fortran95 compiler
LD
use $(FC) as loader
FFLAGS
compiler flags
LAPACK77
-llapack: lapack77 library
BLAS
-lblas: blas library
SPECIAL_LIBG2C
special library which is needed (libg2c.a)
in our case this is set by system
LIBS
$(LAPACK77) $(BLAS) $(SPECIAL_LIBG2C): sequence is important
LDFLAGS
flags for the linker
 
For further information for compiler flags and linker flags please read the documentation of the Fortran95 compilers.

The really important steps are:



Bernhard Seiwald 2002-01-13