|
From: 孔涛 <ka...@ye...> - 2014-12-24 13:15:54
|
Hello,everyone
How to set different prerequisites for the same target when it belong to a different target. For example,
target t1 depends on file main.o and t1.o where main.o depend on t1.o (it's a module file in fortran, similar as a head file .h in C) besides its source, while
target t2 depends on file main.o and t2.o where at this time main.o depends on t2.o together with it's souce file. i.e
--------------------------
t1 : main.o t1.o
main.o: t1.o
-------
t2:main.o t2.o
main.o: t2.o
-------------------------
I wrote them together in one makefile, but unforturanatly, the dependece of main.o does not take effect. why?
--
1 .SECONDEXPANSION:
2
3 FC=gfortran
4 PRJ = t1 t2
5
6 all: $(PRJ)
7
8 %.o:%.f90 ; $(FC) -c $<
9
10
11 t1: tname = t1.o
12 t2: tname = t2.o
13
14 $(PRJ) : main.o $$(tname) ; $(FC) $^ -o $@
15 main.o : $$(tname)
16
17 clean:
18 rm -rf $(PRJ) *.o *.mod
----
line 15 doesnot make any sense. why?
here are the source file:
------------------------
--main.f90--
use eqn
print *,nam
end
--t1.f90--
module eqn
character(10):: nam = 't1'
end module
--t2.f90---
module eqn
character(10):: nam = 't2'
end module
Kong Tao
----
School of Maths, Shandong Univ. P.R.C.
|