I';我正在尝试将macOS的现有makefile转换为将在Windows10上的mingw-W64下运行的makefile

I';我正在尝试将macOS的现有makefile转换为将在Windows10上的mingw-W64下运行的makefile,makefile,windows-10,gfortran,Makefile,Windows 10,Gfortran,这是MacOS的makefile源目录包含源文件以及makefile和srclist.make文件 # makefile for molex on macOS OBJDIR = ../Objects SRCDIR = ./Source include srclist.make FC = gfortran FFLAGS = -x f77-cpp-input -ffixed-line-length-132 -fno-align-commons -I$(SRCDIR) -O3 OBJE

这是MacOS的makefile源目录包含源文件以及makefile和srclist.make文件

# makefile for molex on macOS

OBJDIR = ../Objects
SRCDIR = ./Source

include srclist.make

    FC = gfortran
FFLAGS = -x f77-cpp-input -ffixed-line-length-132 -fno-align-commons -I$(SRCDIR) -O3

OBJECTS  = $(addprefix $(OBJDIR)/, $(addsuffix .o, $(basename $(SRCLIST)) ))

SOURCES = $(addprefix $(SRCDIR)/, $(SRCLIST) )

vpath %.f $(SRCDIR)
vpath %.inc $(SRCDIR)

$(OBJDIR)/%.o : %.f
    $(FC) -c $(FFLAGS) $< -o $@ 

molex : $(OBJECTS)
    $(FC) -o molex $^

.PHONY : clean


clean:
    rm $(OBJDIR)/*.o
我尝试在macOS make文件中放置转义反斜杠,并使用mingw32 make在cmd prmpt中运行 环境路径设置为C:\msys2\mingw-w64\bin

下面是部分编辑的makefile

    # makefile for molex on macOS

OBJDIR = ..\\Objects
SRCDIR = .\\Source

include  srclist.make

    FC = gfortran
FFLAGS = -x f77-cpp-input -ffixed-line-length-132 -fno-align-commons -I$(SRCDIR) -O3

#OBJECTS  = $(addprefix $(OBJDIR)/, $(addsuffix .o, $(basename $(SRCLIST)) ))
OBJECTS  = $(addprefix $(OBJDIR)\\, $(addsuffix .o, $(basename $(SRCLIST)) ))

SOURCES = $(addprefix $(SRCDIR)/, $(SRCLIST) )

vpath %.f $(SRCDIR)
vpath %.inc $(SRCDIR)

$(OBJDIR)\%.o : %.f
    $(FC) -c $(FFLAGS) $< -o $@ 

molex : $(OBJECTS)
    $(FC) -o molex $^

.PHONY : clean



clean:
    del $(OBJDIR)/*.o


请给我一些指导

您应该始终在路径名中使用正斜杠,即使在Windows上也是如此。您应该始终在路径名中使用正斜杠,即使在Windows上也是如此。
    # makefile for molex on macOS

OBJDIR = ..\\Objects
SRCDIR = .\\Source

include  srclist.make

    FC = gfortran
FFLAGS = -x f77-cpp-input -ffixed-line-length-132 -fno-align-commons -I$(SRCDIR) -O3

#OBJECTS  = $(addprefix $(OBJDIR)/, $(addsuffix .o, $(basename $(SRCLIST)) ))
OBJECTS  = $(addprefix $(OBJDIR)\\, $(addsuffix .o, $(basename $(SRCLIST)) ))

SOURCES = $(addprefix $(SRCDIR)/, $(SRCLIST) )

vpath %.f $(SRCDIR)
vpath %.inc $(SRCDIR)

$(OBJDIR)\%.o : %.f
    $(FC) -c $(FFLAGS) $< -o $@ 

molex : $(OBJECTS)
    $(FC) -o molex $^

.PHONY : clean



clean:
    del $(OBJDIR)/*.o

     D:\test_molex_ian\Source>mingw32-make -f makefile molex
mingw32-make: *** No rule to make target '..\\Objects\\molex.o', needed by 'molex'.  Stop.