-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
executable file
·62 lines (44 loc) · 1.51 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
CC = gcc
# If you have a 64-bit computer, you may want to use this instead.
# CC = gcc -m32
CFLAGS = -std=c99 -pedantic -Wall -Werror -lm -m32
OPTFLAG = -O2
DEBUGFLAG = -g
# This is the name of the static archive to produce
# Don't change this line
LIBRARY = malloc
# The C and H files
# Your test file SHOULD NOT be in this line
CFILES = my_malloc.c my_sbrk.c
HFILES = my_malloc.h
PROGRAM = hw13
# Targets:
# test -- runs your test program
# debug -- runs a the supplied structure verifier. THIS IS NOT THE GRADER THE TAs USE!
# check -- runs a the supplied structure verifier. THIS IS NOT THE GRADER THE TAs USE!
# clean -- removes compiled code from the directory
test: CFLAGS += $(OPTFLAG)
test: $(PROGRAM)-test
./$(PROGRAM)-test
debug: CFLAGS += $(DEBUGFLAG)
debug: $(PROGRAM)-debug
gdb ./$(PROGRAM)-debug
check: CFLAGS += $(OPTFLAG)
check: $(PROGRAM)-verifier
@for i in 1 2 3 4; do \
echo "./$(PROGRAM)-verifier $$i" && ./$(PROGRAM)-verifier $$i && exit; \
done; \
echo "Passed all cases"
$(PROGRAM)-test: lib$(LIBRARY).a test.c
$(CC) $(CFLAGS) -g test.c -L . -l$(LIBRARY) -o $@
$(PROGRAM)-debug: lib$(LIBRARY).a test.c
$(CC) $(CFLAGS) -g test.c -L . -l$(LIBRARY) -o $@
$(PROGRAM)-verifier: student_verifier.o lib$(LIBRARY).a
$(CC) $(CFLAGS) $< -L . -g -l$(LIBRARY) -o $@
OFILES = $(patsubst %.c,%.o,$(CFILES))
lib$(LIBRARY).a: $(OFILES)
ar -cr lib$(LIBRARY).a $(OFILES)
%.o: %.c $(HFILES)
$(CC) $(CFLAGS) -c $<
clean:
rm -rf lib$(LIBRARY).a $(PROGRAM)-test $(PROGRAM)-debug $(PROGRAM)-verifier $(OFILES)