makefile - 如何使用多个可执行文件为 fortran 编写 makefile
问题描述
基于这个问题A Makefile with Multiple Executables我正在尝试编写一个 fortran 版本。
源代码分为几个 *.f90 文件。所以我尝试使用之前引用的想法,这是我的makefile的摘录:
PROGRAM := Mpois Mkvz
# Definitions
COMPILER := gfortran -O3 -ffast-math
LIBS := -fbounds-check -lm
# Directories of object code
OBJDIR = objects
SOURCES_pois := BORDERS.f90 CONVERGENCE.f90 FILESIO.f90 LBM.f90 Main_pois.f90
OBJECTS_pois := BORDERS.o CONVERGENCE.o FILESIO.o LBM.o Main_pois.o
SOURCES_kvz := BORDERS.f90 CONVERGENCE.f90 FILESIO.f90 LBM.f90 Main_KVZ.f90
OBJECTS_kvz := BORDERS.o CONVERGENCE.o FILESIO.o LBM.o Main_KVZ.o
# Linking
Mpois: $(OBJECTS_pois)
$(COMPILER) $^ -o $@ $(LIBS)
# Compiling
$(OBJECTS_pois): $(OBJDIR)/%.o: %.f90
$(COMPILER) -c $< -o $@
# Linking
Mkvz: $(OBJECTS_kvz)
$(COMPILER) $^ -o $@ $(LIBS)
# Compiling
$(OBJECTS_kvz): $(OBJDIR)/%.o: %.f90
$(COMPILER) -c $< -o $@
clean:
rm -f $(OBJDIR)/*.o
这个想法是,当调用
make
在 linux 终端中,结果应该是两个不同的可执行文件。尽管如此,我收到以下消息:
makefile:21: target `BORDERS.o' doesn't match the target pattern
makefile:21: target `CONVERGENCE.o' doesn't match the target pattern
makefile:21: target `FILESIO.o' doesn't match the target pattern
makefile:21: target `LBM.o' doesn't match the target pattern
makefile:21: target `Main_pois.o' doesn't match the target pattern
makefile:29: target `BORDERS.o' doesn't match the target pattern
makefile:30: warning: overriding commands for target `BORDERS.o'
makefile:22: warning: ignoring old commands for target `BORDERS.o'
makefile:29: target `CONVERGENCE.o' doesn't match the target pattern
makefile:30: warning: overriding commands for target `CONVERGENCE.o'
makefile:22: warning: ignoring old commands for target `CONVERGENCE.o'
makefile:29: target `FILESIO.o' doesn't match the target pattern
makefile:30: warning: overriding commands for target `FILESIO.o'
makefile:22: warning: ignoring old commands for target `FILESIO.o'
makefile:29: target `LBM.o' doesn't match the target pattern
makefile:30: warning: overriding commands for target `LBM.o'
makefile:22: warning: ignoring old commands for target `LBM.o'
makefile:29: target `Main_KVZ.o' doesn't match the target pattern
gfortran -O3 -ffast-math -c -o BORDERS.o
gfortran: fatal error: no input files; unwilling to write output files
compilation terminated.
make: *** [BORDERS.o] Error 4
照顾提示和建议,我向你致敬。-
解决方案
推荐阅读
- git - 使用 git log 在存储库中查找分支创建日期
- python - 方法仅在命名为“update()”时有效
- php - 测试失败并显示“在调用“...\WebTestCase::createClient()”之前启动内核不受支持
- android-studio - 设备中缺少 Vulkan 1.1 API - Android Studio 模拟器
- python - 我的python程序在中间冻结,没有任何异常或错误,同一个屏幕保持数小时不变
- javascript - 谷歌脚本循环覆盖所有行
- vim - 如何创建使用 vim 功能的命令?
- ios - Swift:使用 SCNText 正确显示顶点标签
- reactjs - 在使用无头 Wordpress 时,我可以在 React 前端的帖子中嵌入推文吗?
- windows - 在 Inno Setup 中卸载期间从所有用户配置文件中删除日志文件