based on this question A Makefile with Multiple Executables I am trying to write a fortran version.
The source code is divided in several *.f90 files. So I tried to use the idea quoted before, here's an excerpt of my makefile:
PROGRAM := Mpois Mkvz
# Definitions
COMPILER := gfortran -O3 -ffast-math
LIBS := -fbounds-check -lm
# Directories of object code
OBJDIR = objects
SOURCES_pois := BORDERS.f90 CONVERGENCE.f90 FILESIO.f90 LBM.f90 Main_pois.f90
OBJECTS_pois := BORDERS.o CONVERGENCE.o FILESIO.o LBM.o Main_pois.o
SOURCES_kvz := BORDERS.f90 CONVERGENCE.f90 FILESIO.f90 LBM.f90 Main_KVZ.f90
OBJECTS_kvz := BORDERS.o CONVERGENCE.o FILESIO.o LBM.o Main_KVZ.o
# Linking
Mpois: $(OBJECTS_pois)
$(COMPILER) $^ -o $@ $(LIBS)
# Compiling
$(OBJECTS_pois): $(OBJDIR)/%.o: %.f90
$(COMPILER) -c $< -o $@
# Linking
Mkvz: $(OBJECTS_kvz)
$(COMPILER) $^ -o $@ $(LIBS)
# Compiling
$(OBJECTS_kvz): $(OBJDIR)/%.o: %.f90
$(COMPILER) -c $< -o $@
clean:
rm -f $(OBJDIR)/*.o
The idea was that when invoking
make
in a linux terminal the results should be two different executable files. Nevertheless I receive the following message:
makefile:21: target `BORDERS.o' doesn't match the target pattern
makefile:21: target `CONVERGENCE.o' doesn't match the target pattern
makefile:21: target `FILESIO.o' doesn't match the target pattern
makefile:21: target `LBM.o' doesn't match the target pattern
makefile:21: target `Main_pois.o' doesn't match the target pattern
makefile:29: target `BORDERS.o' doesn't match the target pattern
makefile:30: warning: overriding commands for target `BORDERS.o'
makefile:22: warning: ignoring old commands for target `BORDERS.o'
makefile:29: target `CONVERGENCE.o' doesn't match the target pattern
makefile:30: warning: overriding commands for target `CONVERGENCE.o'
makefile:22: warning: ignoring old commands for target `CONVERGENCE.o'
makefile:29: target `FILESIO.o' doesn't match the target pattern
makefile:30: warning: overriding commands for target `FILESIO.o'
makefile:22: warning: ignoring old commands for target `FILESIO.o'
makefile:29: target `LBM.o' doesn't match the target pattern
makefile:30: warning: overriding commands for target `LBM.o'
makefile:22: warning: ignoring old commands for target `LBM.o'
makefile:29: target `Main_KVZ.o' doesn't match the target pattern
gfortran -O3 -ffast-math -c -o BORDERS.o
gfortran: fatal error: no input files; unwilling to write output files
compilation terminated.
make: *** [BORDERS.o] Error 4
Looking after hints and advice I salute you.-