Makefile构建失败,`mv:No match

时间:2016-07-28 16:46:39

标签: makefile fortran

我正在用这个makefile编译代码

    SHELL = /bin/tcsh

include ../make.inc


FC = gfortran

#--------------------------------------------------------------------
# Compiler flags
#--------------------------------------------------------------------

#   none
#FFLAGS = 

#   Optimize
#FFLAGS = -O 

#   debug
#FFLAGS = -g

# Large memory needed (ifort)
FFLAGS = -O 


#--------------------------------------------------------------------
# Location of files
#--------------------------------------------------------------------

DIR     =   ./
PLSRC   =   ./src/

PLPROG  =   ./programs/


#--------------------------------------------------------------------
# Module flag
#--------------------------------------------------------------------

# Sun Compiler
#MFLAG = -M

# Nag Compiler
#MFLAG = -i
#MFLAG = -I

# Absoft Compiler
#MFLAG = -p

# Intel or g95 compiler
MFLAG = -I

MODULE = $(MFLAG)$(MOD)

#--------------------------------------------------------------------
# Fortran Files
#--------------------------------------------------------------------

PLFILES = gplot.f90 gnuplot.f90

PLPRFILES = xyplot.f90

#--------------------------------------------------------------------
# Objects Files
#--------------------------------------------------------------------

PLOBJS =  $(PLFILES:.f90=.o)

#--------------------------------------------------------------------
# Compile libraries
#--------------------------------------------------------------------

# $@ means the target name
# $? means all dependencies (OBJS) that are new.
# $< similar to $? but just on dependency rules (%.o : %.f90)


all : libgplot.a organize pl_progs 

libgplot.a : $(PLOBJS)
    ar cr $@ $(PLOBJS)
    ranlib $@
    rm *.o

%.o : $(PLSRC)%.f90
    $(FC) $(FFLAGS) -c $< -o $@

organize : libgplot.a 
    mv *.mod $(MOD)
    mv *.a $(LIB)

#--------------------------------------------------------------------
# Compile programs
#--------------------------------------------------------------------

pl_progs : xyplot test_plot

%:      $(PLPROG)%.f90 $(LIB)libgplot.a
    $(FC) $(FFLAGS) $(MODULE) $< $(LIB)libgplot.a -o $(PROG)$@
    mv *.mod $(MOD)

#--------------------------------------------------------------------
# Clean
#--------------------------------------------------------------------

clean:
    rm $(LIB)libgplot.a 

我得到了这个

root@milenko-HP-Compaq-6830s:/home/milenko/gprieto/gplot# make
gfortran -O  -c src/gplot.f90 -o gplot.o
gfortran -O  -c src/gnuplot.f90 -o gnuplot.o
ar cr libgplot.a gplot.o gnuplot.o
ranlib libgplot.a
rm *.o
mv *.mod /usr/local/
mv *.a /usr/local/lib/
gfortran -O  -I/usr/local/ programs/xyplot.f90 /usr/local/lib/libgplot.a -o /usr/local/bin/xyplot
mv *.mod /usr/local/
gfortran -O  -I/usr/local/ programs/test_plot.f90 /usr/local/lib/libgplot.a -o /usr/local/bin/test_plot
mv *.mod /usr/local/
mv: No match.
Makefile:123: recipe for target 'test_plot' failed
make: *** [test_plot] Error 1

我不明白为什么配方在这种情况下失败并使用xyplot。

1 个答案:

答案 0 :(得分:1)

失败发生在

mv *.mod /usr/local/
mv: No match.

没有*.mod个文件mv可以移动,因此会触发错误。

最可能的原因是test_plot.f90只包含主程序而没有模块。那么mv *.mod /usr/local/命令就没有地方可用于此文件。