-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
executable file
·64 lines (42 loc) · 1.43 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
# prompt> make
# builds everything and links in test program test_rb
#
# prompt> make mem_check
# Rebuilds everything using dmalloc and does memory testing.
# Only works if you have dmalloc installed (see http://dmalloc.com).
SRCS = test_red_black_tree.c red_black_tree.c stack.c misc.c
HDRS = red_black_tree.h stack.h misc.h
OBJS = red_black_tree.o stack.o test_red_black_tree.o misc.o
CC = gcc
CFLAGS = -g -Wall -pedantic
PROGRAM = test_rb
.PHONY: mem_check clean
all: $(PROGRAM)
$(PROGRAM): $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $(PROGRAM) $(DMALLOC_LIB)
mem_check:
@if [ -e makefile ] ; then \
echo "Using makefile" ; \
$(MAKE) clean -f makefile ; \
$(MAKE) $(PROGRAM) "CFLAGS=$(CFLAGS) -DDMALLOC" "DMALLOC_LIB=-ldmalloc" -f makefile.txt ; \
else \
echo "Using default makefile (i.e. no -f flag)." ; \
$(MAKE) clean ; \
$(MAKE) $(PROGRAM) "CFLAGS=$(CFLAGS) -DDMALLOC" "DMALLOC_LIB=-ldmalloc" ; \
fi
./simple_test.sh
@if [ -s unfreed.txt ] ; then \
echo " " ; \
echo "Leaked some memory. See logfile for details." ;\
else \
echo " " ; \
echo "No memory leaks detected. " ;\
echo " " ; \
echo "Test passed. " ; \
echo " " ; \
fi
test_red_black_tree.o: test_red_black_tree.c red_black_tree.c stack.c stack.h red_black_tree.h misc.h
red_black_tree.o: red_black_tree.h stack.h red_black_tree.c stack.c misc.h misc.c
stack.o: stack.c stack.h misc.h misc.c
clean:
rm -f *.o *~ $(PROGRAM)