automake with fortran: order of file -
i facing small problem when trying build code autotools. file structure is:
$ tree . |-- configure.ac |-- makefile.am `-- src |-- constants.f90 |-- environment.f90 |-- init.f90 |-- main.f90 `-- util.f90
(deleted possibly unnecessary lines) , makefile.am is:
#subdirs= 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
the problem src/(*.f90)'s except main.f90 module. hence, if have write makefile hand, 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
so, makefile.am, have make strict order of files in scasr_sources. i.e. sources :
scasr_sources = \ src/constants.f90 src/environment.f90 src/util.f90 \ src/init.f90 src/main.f90
it compiles fine. if have as:
scasr_sources = src/main.f90 \ src/constants.f90 src/environment.f90 src/util.f90 \ src/init.f90
i error:
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' reading @ (1): no such file or directory make[1]: *** [src/main.o] error 1
is there way out make/configure check dependency itself? or must keep strict order?
(answers in comments. see question no answers, issue solved in comments (or extended in chat) )
@stefan wrote:
you enter dependencies directly
makefile.am
. put handwritten makefile rules (the third code part in post) inmakefile.am
. automatic dependency tracking is, far know, not (yet) possible. change addition of submodules, defined in fortran 2008 not yet implemented in popular compiler.
the op wrote:
as per @stefan's comment, have added dependencies in make file, , solved problem. have tested order of source code not important anymore. since, there not many stuff in internet available, putting complete procedure here:
- create dependency list (
makedepf90
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
- just copy-paste output of step 1 after 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
nb: have not tested if work if place place else in makefile. working.
Comments
Post a Comment