Thank you for the link.
After several days efforts, I got a solution, however, I don't know if
it is the optimal ones.
In the top directory project/, there is a Makefile like this:
LDR = gfortran
LDOPTS =
obj = $(wildcard module/*.o)
obj += $(wildcard interface/*.o)
obj += $(wildcard subroutine/*.o)
all: app
$(LDR) $(LDOPTS) -o $< $(obj)
app:
cd module; make
cd interface; make
cd subroutine; make
mod:
cd module; make
if:
cd interface; make
sub:
cd subroutine; make
clean:
cd module; make clean
cd interface; make clean
cd subroutine; make clean
-rm MODULES/*.mod
In the subdirectory, e.g., interface, there is a Makefile like this:
FC = gfortran
FFLAGS = -g -pedantic -Wall -Wextra -fcheck=all -O0
MODULES = -J../MODULES
obj = $(patsubst %.f90, %.o, $(wildcard *.f90))
#all: libinterface.a
#
#libinterfaces.a: $(obj)
# ar ruvs $@ $^
all: $(obj)
%.o: %.f90
$(FC) $(FFLAGS) $(MODULES) -c $<
clean:
-rm *.o
Any suggestions for improvement? Thanks in advance.
Regards,
Jinsong