Fortran Makefile in Linux - XiZi's Blog

Fortran Makefile in Linux

Xizi posted @ 2013年2月24日 21:44 in Develop with tags fortran linux makefile , 1410 阅读

 

FC = ifort
FFLAGS = -O2

ALL_SRCS = $(wildcard *.f *.for *.f90)
MODSRCS = $(filter mod_%,$(ALL_SRCS))
#MODSRCS = zmod.f
MODS := $(addsuffix .o, $(basename $(MODSRCS)))

SRCS = $(filter-out mod_%,$(ALL_SRCS))
#SRCS = sub1.f \
main.f90

OBJS := $(addsuffix .o, $(basename $(SRCS)))

TARGET = Program_N
#all:
#       @echo "ALL_SRCS=$(ALL_SRCS)"
#       @echo "OBJS=$(OBJS)"
#       @echo "MODS=$(MODS)"

$(TARGET): $(OBJS)
        $(FC) $(FFLAGS) -o $@ $(MODS) $(OBJS)

clean:
        rm -f $(TARGET) *.o *.mod

$(OBJS): $(MODS)

.SUFFIXES: .o .f .for .f90

.f.o:
        $(FC) $(FFLAGS) -c $<
.for.o:
        $(FC) $(FFLAGS) -c $<
.f90.o:
        $(FC) $(FFLAGS) -c $<

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee