-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
76 lines (59 loc) · 2.17 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
76
# Makefile for gcc
CC =gcc
CFLAGS =-O3 -Wall
LDFLAGS =-lm -lgsl -lgslcblas -lpng -lz
MPFLAGS =-fopenmp
SRCDIR1 =msp_src
SRCDIR2 =maw_src
SRCDIR3 =com_src
OBJDIR =obj
TARGET1 =aw_msp_solver
TRGSRC1 =aw_msp_solver.c
TARGET2 =example1.out
TRGSRC2 =example1.c
TARGET3 =example2.out
TRGSRC3 =example2.c
TARGET4 =example3.out
TRGSRC4 =example3.c
TARGET5 =example4.out
TRGSRC5 =example4.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))
TRGOBJ5=$(filter-out $(OBJDIR)/$(TARGET1).o,$(OBJS1)) $(OBJS2) $(OBJS3) $(patsubst %.c,%.o,$(TRGSRC5))
all : directories $(TARGET1) $(TARGET2) $(TARGET3) $(TARGET4) $(TARGET5)
directories:
@mkdir -p $(OBJDIR)
$(TARGET1) : $(TRGOBJ1)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(MPFLAGS)
$(TARGET2) : $(TRGOBJ2)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(MPFLAGS)
$(TARGET3) : $(TRGOBJ3)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(MPFLAGS)
$(TARGET4) : $(TRGOBJ4)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(MPFLAGS)
$(TARGET5) : $(TRGOBJ5)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(MPFLAGS)
$(OBJDIR)/%.o : $(SRCDIR1)/%.c
$(CC) $(CFLAGS) -I$(SRCDIR2) -I$(SRCDIR3) -c $< -o $@ $(MPFLAGS)
$(OBJDIR)/%.o : $(SRCDIR2)/%.c
$(CC) $(CFLAGS) -I$(SRCDIR3) -c $< -o $@
$(OBJDIR)/%.o : $(SRCDIR3)/%.c
$(CC) $(CFLAGS) -c $< -o $@
.c.o :
$(CC) $(CFLAGS) -I$(SRCDIR1) -I$(SRCDIR2) -I$(SRCDIR3) -c $< $(MPFLAGS)
clean:
@rm -rf $(TARGET1) $(TARGET2) $(TARGET3) $(TARGET4) $(TARGET5) $(OBJDIR) ./*.o
$(OBJS1) : $(HEAD1) $(HEAD2) $(HEAD3)
$(OBJS2) : $(HEAD2) $(HEAD3)
$(OBJS3) : $(HEAD3)