具有不同源类型的 Makefile [英] Makefile with different source types

查看:12
本文介绍了具有不同源类型的 Makefile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个生成文件来编译带有 .f.f90 扩展名的源文件的程序.我有编译对象的规则:

I am trying to write a makefile for compiling a program with source files with both .f and .f90 extensions. I have the rule to compile the objects:

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

如何扩展它以使其也适用于 .f 文件?

How can I extend this to work with the .f files as well?

推荐答案

您需要有两条单独的规则:一条用于 .f 文件,一条用于 .f90文件.例如:

You will need to have two separate rules: one for the .f files and one for the .f90 files. For example:

TARGET := a.out
OBJFILES := foo.f bar.f90
OBJ := ./obj

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

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

%(TARGET): $(OBJFILES)
    $(FC) $(FFLAGS) -o $@ $(addprefix $(OBJ)/,$(OBJFILES))

或类似的东西应该可以解决问题.

or something similar should do the trick.

这篇关于具有不同源类型的 Makefile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆