-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
53 lines (41 loc) · 1.3 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
CC =gcc
CFLAGS =-O3 -Wall
LDFLAGS =-lm -lpng -lz -lgsl -lgslcblas
MPFLAGS =-fopenmp
SRCDIR1 =maw_src
SRCDIR2 =com_src
OBJDIR =obj
TARGET1 =example1.out
TRGSRC1 =example1.c
TARGET2 =example2.out
TRGSRC2 =example2.c
TARGET3 =example3.out
TRGSRC3 =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)
TRGOBJ1=$(OBJS1) $(OBJS2) $(patsubst %.c,%.o,$(TRGSRC1))
TRGOBJ2=$(OBJS1) $(OBJS2) $(patsubst %.c,%.o,$(TRGSRC2))
TRGOBJ3=$(OBJS1) $(OBJS2) $(patsubst %.c,%.o,$(TRGSRC3))
all : directories $(TARGET1) $(TARGET2) $(TARGET3)
directories:
@mkdir -p $(OBJDIR)
$(TARGET1) : $(TRGOBJ1)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
$(TARGET2) : $(TRGOBJ2)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(MPFLAGS)
$(TARGET3) : $(TRGOBJ3)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(MPFLAGS)
$(OBJDIR)/%.o : $(SRCDIR1)/%.c
$(CC) $(CFLAGS) -I $(SRCDIR2) -c $< -o $@
$(OBJDIR)/%.o : $(SRCDIR2)/%.c
$(CC) $(CFLAGS) -c $< -o $@
.c.o :
$(CC) $(CFLAGS) -I $(SRCDIR1) -I $(SRCDIR2) -c $< $(MPFLAGS)
clean:
@rm -rf $(TARGET1) $(TARGET2) $(TARGET3) $(OBJDIR) *.o
$(OBJS1) : $(HEAD1)
$(OBJS1) $(OBJS2) : $(HEAD2)