问题描述
尝试使用自动工具构建代码时,我遇到了一个小问题.我的文件结构是:
I am facing a small problem when trying to build my code with autotools.My file structure is:
$ tree
.
|-- configure.ac
|-- Makefile.am
`-- src
|-- constants.f90
|-- environment.f90
|-- init.f90
|-- main.f90
`-- util.f90
(删除了可能不必要的行)而我的Makefile.am是:
(deleted possibly unnecessary lines)and my Makefile.am is:
#SUBDIRS= help
bin_PROGRAMS = scasr
scasr_SOURCES = \
src/constants.f90 src/environment.f90 src/util.f90 \
src/init.f90 src/main.f90
scasr_LDADD =
EXTRA_DIST= autogen.sh
CLEANFILES =*.mod
问题是src/(*.f90)的,除了main.f90是模块.因此,如果我必须手动编写makefile,我将拥有:
The problem is src/(*.f90)'s except main.f90 are module. Hence, if Ihave to write the makefile by hand, I will have:
constants.o : constants.f90
environment.o : environment.f90
init.o : init.f90 util.o constants.o
main.o : main.f90 init.o constants.o environment.o
util.o : util.f90 constants.o
因此,对于Makefile.am,我必须对文件进行严格排序scasr_SOURCES. IE.来源为:
so, for Makefile.am, I have to make a strict order of files inscasr_SOURCES. i.e.with the sources as :
scasr_SOURCES = \
src/constants.f90 src/environment.f90 src/util.f90 \
src/init.f90 src/main.f90
它可以编译.但是如果我有:
It compiles fine.But if I have as:
scasr_SOURCES = src/main.f90 \
src/constants.f90 src/environment.f90 src/util.f90 \
src/init.f90
我收到错误消息:
make all-am
make[1]: Entering directory `/home/rudra/Programs/ScASR/trunk'
gfortran -g -O2 -c -o src/main.o src/main.f90
src/main.f90:7.4:
use mget_env
1
Fatal Error: Can't open module file 'mget_env.mod' for reading at (1):
No such file or directory
make[1]: *** [src/main.o] Error 1
是否有任何出路,以便make/configure通过以下方式检查依赖关系:本身?还是我必须保持严格的秩序?
Is there any way out so that make/configure will check the dependency byitself? Or I must keep a strict order?
推荐答案
(评论中的答案.请参见)
(Answers in the comments. See Question with no answers, but issue solved in the comments (or extended in chat) )
@Stefan写道:
@Stefan wrote:
OP写道:
- 创建一个依赖项列表(
makedepf90
是一个不错的选择)
- create a dependency list (
makedepf90
is a good option)
$ makedepf90 src/*.f90 src/constants.o : src/constants.f90 src/environment.o : src/environment.f90 src/init.o : src/init.f90 src/util.o src/constants.o src/main.o : src/main.f90 src/init.o src/constants.o src/environment.o src/util.o : src/util.f90 src/constants.o
- 只需将步骤1的输出复制并粘贴到scasr_SOURCES之后:
scasr_SOURCES = src/main.f90\ src/constants.f90 src/environment.f90 rc/util.f90 src/init.f90 src/constants.o : src/constants.f90 src/environment.o : src/environment.f90 src/init.o : src/init.f90 src/util.o src/constants.o src/main.o : src/main.f90 src/init.o src/constants.o src/environment.o src/util.o : src/util.f90 src/constants.o
这篇关于使用fortran自动制作:文件顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!