-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (58 loc) · 2.31 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# makefile for GNU C compiler
CC =gcc
CFLAGS =-O3 -Wall
LDFLAGS=-lpng -lz
MPFLAGS=-fopenmp
# link mkl lapack library, static linking
LDF_MKL =-Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_ilp64.a ${MKLROOT}/lib/intel64/libmkl_gnu_thread.a ${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -lgomp -lpthread -lm -ldl#mkl lapack link library (static linking)
# mkl compile option
COP_MKL =-DMKL_ILP64 -m64 -I${MKLROOT}/include
SRCDIR1=d3qd2_src
SRCDIR2=com_src
SRCDIR3=qgf2_src
OBJDIR =obj
TARGET1=aw_d3qd2_bv_solver
TRGSRC1=aw_d3qd2_bv_solver.c
TARGET2=example1.out
TRGSRC2=example1.c
TARGET3=example2.out
TRGSRC3=example2.c
TARGET4=example3.out
TRGSRC4=example3.c
SRCS1=$(wildcard $(SRCDIR1)/*.c)
OBJS1=$(addprefix $(OBJDIR)/,$(patsubst %.c,%.o,$(notdir $(SRCS1)) ))
HEAD1=$(wildcard $(SRCDIR1)/*.h)
SRCS2=$(wildcard $(SRCDIR2)/*.c)
OBJS2=$(addprefix $(OBJDIR)/,$(patsubst %.c,%.o,$(notdir $(SRCS2)) ))
HEAD2=$(wildcard $(SRCDIR2)/*.h)
SRCS3=$(wildcard $(SRCDIR3)/*.c)
OBJS3=$(addprefix $(OBJDIR)/,$(patsubst %.c,%.o,$(notdir $(SRCS3)) ))
HEAD3=$(wildcard $(SRCDIR3)/*.h)
TRGOBJ1=$(OBJS1) $(OBJS2) $(OBJS3)
TRGOBJ2=$(filter-out $(OBJDIR)/$(TARGET1).o, $(OBJS1)) $(OBJS2) $(OBJS3) $(patsubst %.c,%.o,$(TRGSRC2))
TRGOBJ3=$(filter-out $(OBJDIR)/$(TARGET1).o, $(OBJS1)) $(OBJS2) $(OBJS3) $(patsubst %.c,%.o,$(TRGSRC3))
TRGOBJ4=$(filter-out $(OBJDIR)/$(TARGET1).o, $(OBJS1)) $(OBJS2) $(OBJS3) $(patsubst %.c,%.o,$(TRGSRC4))
all : directories $(TARGET1) $(TARGET2) $(TARGET3) $(TARGET4)
directories:
@mkdir -p $(OBJDIR)
$(TARGET1) : $(TRGOBJ1)
$(CC) $(CFLAGS) $^ -o $@ $(LDF_MKL) $(LDFLAGS) $(MPFLAGS)
$(TARGET2) : $(TRGOBJ2)
$(CC) $(CFLAGS) $^ -o $@ $(LDF_MKL) $(LDFLAGS) $(MPFLAGS)
$(TARGET3) : $(TRGOBJ3)
$(CC) $(CFLAGS) $^ -o $@ $(LDF_MKL) $(LDFLAGS) $(MPFLAGS)
$(TARGET4) : $(TRGOBJ4)
$(CC) $(CFLAGS) $^ -o $@ $(LDF_MKL) $(LDFLAGS) $(MPFLAGS)
$(OBJDIR)/%.o : $(SRCDIR1)/%.c
$(CC) $(CFLAGS) $(COP_MKL) -I$(SRCDIR2) -I$(SRCDIR3) -c $< -o $@ $(MPFLAGS)
$(OBJDIR)/%.o : $(SRCDIR2)/%.c
$(CC) $(CFLAGS) -c $< -o $@
$(OBJDIR)/%.o : $(SRCDIR3)/%.c
$(CC) $(CFLAGS) -c $< -o $@
.c.o :
$(CC) $(CFLAGS) $(COP_MKL) -I$(SRCDIR1) -I$(SRCDIR2) -I$(SRCDIR3) -c $< $(MPFLAGS)
clean:
@rm -rf $(TARGET1) $(TARGET2) $(TARGET3) $(TARGET4) $(OBJDIR) ./*.o
$(OBJS1) : $(HEAD1) $(HEAD2) $(HEAD3)
$(OBJS2) : $(HEAD2)
$(OBJS3) : $(HEAD3)