-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
48 lines (33 loc) · 873 Bytes
/
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
vpath %.h include
vpath %.o objects
flags := -g -O2 -Wall
outdir := out
incdir := include
objdir := objects
target ?= avltree
assert ?= false
assert_suf = _assert
objs = $(addprefix $(objdir)/, treeio.o $(target).o)
ifeq ($(assert), true)
objs += $(addprefix $(objdir)/, $(target)$(assert_suf).o)
endif
$(outdir)/treeio: $(objs) | $(outdir)
cc $(flags) $^ -o $@
$(objs): | $(objdir)
$(objdir):
mkdir $(objdir)
$(outdir):
mkdir $(outdir)
$(objdir)/treeio.o: treeio.c treeio.h
cc $(flags) -c $< -o $@
$(objdir)/$(target).o: $(target)/$(target).c $(target).h
cc $(flags) -c $< -o $@
$(objdir)/$(target)$(assert_suf).o: $(objdir)/$(target).o $(target)/$(target)$(assert_suf).c $(target)$(assert_suf).h
cc $(flags) -c $(target)/$(target)$(assert_suf).c -o $@
.PHONY: clean
clean:
rm -f -r $(objdir)
rm -f -r $(outdir)
print: *.c
lpr -p $?
touch print