2013-07-25 3 views
0

autotools로 코드를 만들 때 작은 문제에 직면하고 있습니다. fortran을 가진 automake : 파일의 순서

$ tree 
. 
|-- configure.ac 
|-- Makefile.am 
`-- src 
    |-- constants.f90 
    |-- environment.f90 
    |-- init.f90 
    |-- main.f90 
    `-- util.f90 

은 (아마도 불필요한 선을 삭제) 내 Makefile.am은 다음과 같습니다 : 내 파일 구조는

#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 제외입니다 모듈입니다. 나는 손으로 메이크를 작성해야 따라서, 만약, 내가 가진 것

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에있는 파일의 엄격한 주문을해야합니다. 즉 의 출처는 다음과 같습니다.

scasr_SOURCES = \ 
       src/constants.f90 src/environment.f90 src/util.f90 \ 
       src/init.f90 src/main.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 

가 메이크업/구성이 자체 종속성을 확인합니다, 그래서 밖으로 어떤 방법이 있나요 :

scasr_SOURCES = src/main.f90 \ 
       src/constants.f90 src/environment.f90 src/util.f90 \ 
       src/init.f90 

내가 오류가? 또는 으로 엄격하게 주문해야합니까?

+0

엄격한 주문에는 어떤 문제가 있습니까? –

+0

프로젝트가 아직 생산 중임을 나타냅니다. 따라서 파일 이름을 추가하고 파일 이름을 적절한 위치에 추가하는 것은 훨씬 다릅니다. – BaRud

+1

'Makefile.am'에 의존성을 직접 입력 할 수 있습니다. 그러므로 손으로 쓴 Makefile 규칙 (게시물의 세 번째 코드 부분)을'Makefile.am'에 넣기 만하면됩니다. 자동 종속성 추적은 내가 아는 한 (아직) 가능하지 않습니다. 이것은 포트란 2008에서 정의되었지만 아직 대중적인 컴파일러에서 구현되지 않은 서브 모듈의 추가로 변경 될 수 있습니다. – Stefan

답변

0

(. 코멘트에 답변 Question with no answers, but issue solved in the comments (or extended in chat)보기)

@Stefan 썼다 :

You could enter the dependencies directly to your Makefile.am . So simply put your handwritten Makefile rules (the third code part in your post) in the Makefile.am . Automatic dependency tracking is, as far as I know, not (yet) possible. This could change with the addition of submodules, which are defined in Fortran 2008 but not yet implemented in any popular compiler.

영업 이익은 쓴 :

As per @Stefan's comment, I have added the dependencies in make file, and that solved the problem. I have tested that the order of source code is not important anymore. Since, there is not many stuff in internet available, I am putting the complete procedure here:

  1. 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. Just copy-paste the output of step 1 after the 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: I have not tested if it will work if you place it some place else in the makefile. But this is working.