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

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

问题描述

我正在尝试编写一个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天全站免登陆