Wednesday, April 30, 2014

Makefile example


FC=/usr/local/intel/composerxe-2011.2.137/bin/intel64/ifort
CFLAGS = -O3 -shared-intel
LD=$(FC)
LDFLAGS = -O3 -shared-intel -Wl,
RM = rm

EXE = debufr
FSRC = main_read_ssmis.f90
##  FOBJ depending on $(FSRC) , convert FSRC from .f90 to .o
FOBJ = ${FSRC:.f90=.o}    

# Clear out all suffixes
.SUFFIXES:
# List only those we use
.SUFFIXES: .o .f90

# Define a suffix rule for .f90 -> .o   (Suffix rule / implicit rule )
How to convert .f90 -> .o
.f90.o:
        $(FC) $(CFLAGS) -c $<

all : $(EXE)

$(EXE): $(FOBJ) ../libbufr.a
        $(LD) $(LDFLAGS) -o $@ $(FOBJ) -L../ -lbufr

clean:
        $(RM) -f $(FOBJ)
cleaner:
        $(RM) -f $(EXE) $(FOBJ)

No comments:

Post a Comment