Tag Archives: make

Make

Make it’s a great Unix utility when you are compiling big programs, because automatically builds executable programs and libraries from source code by reading a file called makefile.

The text file named makefile must be in the source folder and it’s runs by the command make in the terminal.

Here a generic makefile:

F90 = gfortran
CFLAGS := -g -fbounds-check
NETCDF := -I/usr/include -L/usr/lib -lnetcdff -lnetcdf
OBJECTS = main.o subrutine.o function.o
.PHONY : clean

all : program1 program2

program1 : $(OBJECTS)
	$(F90) $(CFLAGS) -o Program1 $(OBJECTS) 

main.o : main.f90
	$(F90) $(CFLAGS) $(NETCDF) -c main.f90 

subrutine.o : subrutine.f90
	$(F90) $(CFLAGS) -c subrutine.f90

function.o : function.f90
	$(F90) $(CFLAGS) -c function.f90

program2 : prog2.o
	$(F90) $(CFLAGS) -o Program2 prog2.o

prog2.o : prog2.f90
	$(F90) $(CFLAGS) -c prog2.f90

Install:
	cp Program1 /Home/JP/
	cp Program2 /Home/JP/sub/
clean:
	rm –f *.o *.mod