-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
67 lines (51 loc) · 1.36 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
CC=gcc
TARGET_LOWER=posix
TARGET_ALGO=normal
PWD=$(pwd)
CFLAGS +=\
-g\
-std=c99\
-lpthread\
-D$(TARGET_LOWER)\
-D$(TARGET_ALGO)\
-Wall\
-Wno-discarded-qualifiers\
SRCS +=\
./interface/queue.c\
./interface/interface.c\
TARGETOBJ =\
$(patsubst %.c,%.o,$(SRCS))\
MEMORYOBJ =\
$(patsubst %.c,%_mem.o,$(SRCS))\
LIBS +=\
-lpthread\
all: simulator
memory_leak: simulator_memory_check
simulator_memory_check: ./interface/main.c mem_libsimulator.a
$(CC) $(CFLAGS) -DLEAKCHECK -o $@ $^ $(LIBS)
simulator: ./interface/main.c libsimulator.a
$(CC) $(CFLAGS) -o $@ $^ -lpthread
libsimulator.a: $(TARGETOBJ)
mkdir -p object && mkdir -p data
cd ./algorithm/$(TARGET_ALGO) && make && cd ../../
cd ./lower/$(TARGET_LOWER) && make && cd ../../
mv ./interface/*.o ./object/
$(AR) r $(@) ./object/*.o
mem_libsimulator.a:$(MEMORYOBJ)
mkdir -p object && mkdir -p data
cd ./algorithm/$(TARGET_ALGO) && make && cd ../../
cd ./lower/$(TARGET_LOWER) && make && cd ../../
mv ./interface/*.o ./object/
$(AR) r $(@) ./object/*.o
%_mem.o: %.c
$(CC) $(CFLAGS) -DLEAKCHECK -c $< -o $@ $(LIBS)
.c.o :
$(CC) $(CFLAGS) -c $< -o $@ $(LIBS)
clean :
cd ./algorithm/$(TARGET_ALGO) && make clean && cd ../../
cd ./lower/$(TARGET_LOWER) && make clean && cd ../../
@$(RM) ./data/*
@$(RM) ./object/*.o
@$(RM) *.a
@$(RM) simulator
@$(RM) simulator_memory_check