0

I have a fortran main program called solidsolver.f90, and a module called read_mesh.f90. The module contains two subroutines and is used in the main program. I can compile them manually but not with a makefile. My makefile is named makefile.makefile, and it gives me an error:

make: *** No targets specified and no makefile found. Stop.

I do need a makefile written in a concise way because in the future my code will grow exponentially. Here is the makefile:

  OBJECTS = read_file.o solidsolver.o

  MODULES = read_file.mod

  .PHONY: clean

  main.exe: $(MODULES) $(OBJECTS)
      gfortran $(OBJECTS) -o main.exe

  %.o: %.f90
      gfortran -c $<

  %.mod: %.f90
      gfortran -c $<

  clean:
      rm -f $(OBJECTS) $(MODULES) main.exe

2 Answers 2

1

GNU make is looking for makefiles in the following order (from the man page):

[...] GNUmakefile, makefile, and Makefile, in that order.

To use a file called makefile.makefile, you need to tell make to use that (non-standard) file explicitely:

make -f makefile.makefile
1
  • Thanks for your answer and editing this question. But actually that is not the only bug.
    – Jie Cheng
    Jun 18, 2015 at 0:41
0

Alex is right. But actually the content of the makefile is wrong. I changed it as following and it works:

   OBJECTS = read_file.o solidsolver.o
   MODULES = read_file.mod 
   FC = gfortran
   main.exe: $(OBJECTS)
        $(FC) -o main $(OBJECTS)

   solidsolver.o: $(MODULES) solidsolver.f90
        $(FC) -c solidsolver.f90

   %.mod: %.f90
        $(FC) -c $<

   %.o: %.f90
        $(FC) -c $<

  clean:
       rm -f *.o *.mod main
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.