-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
52 lines (39 loc) · 1.29 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#Set the compilers and linker
FC=gfortran
CC=mpicc
LD=gfortran
#Set the objects
OBJS= constants.o \
diamondsolve.o \
diamond.o
#Set up the MODS so it contains the same as OBJS but with the .o replaced by .mod
MODS= $(OBJS:.o=.mod)
#Set the executable name
EXEC=main
#Set up a variable to represent the makefile
DEFAULT=makefile
# Compiler options
MY_OPTIONS = -fbounds-check -ffree-line-length-800 -g
#Set directories to look for source files, etc
VPATH = $(SCRIPTS_PATH)
#Default make command requires the executable to be up to date
all : $(EXEC)
#Objects required to be updated if the makefile has changed
%.o : $(DEFAULT)
#Object files required to be updated if corresponding .F90 files have changed
%.o : %.f90
$(FC) $(MY_OPTIONS) $(FFLAGS) -c -o $@ $<
#Object files required to be updated if corresponding .f files have changed
%.o : %.f
$(FC) $(FFLAGS) -c -o $@ $<
#Object files required to be updated if corresponding .c files have changed
%.o : %.c
$(CC) $(CFLAGS) -c -o $@ $<
#For the executable to be up to date the object files must be up to date. Then link the objects
$(EXEC): $(OBJS)
$(LD) $^ $(LFLAGS) -o $@
#Clean the directory and any directories searched
.PHONY : clean
clean :
rm -f $(OBJS) $(EXEC) $(MODS) *.o *.mod
rm -f $(VPATH)/$(OBJS) $(VPATH)/$(MODS)