-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathMakefile
44 lines (33 loc) · 793 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
CC ?= gcc
CFLAGS := -O -g -Wall
include mk/common.mk
EXEC = x unx
OBJS := libx.o x.o
deps := $(OBJS:%.o=%.o.d)
all: $(EXEC)
x: $(OBJS)
$(VECHO) " LD\t$@\n"
$(Q)$(CC) $(OBJS) -o $@
unx: x
$(VECHO) " LN\t$@\n"
$(Q)ln -s $< $@
%.o: %.c
$(VECHO) " CC\t$@\n"
$(Q)$(CC) -o $@ $(CFLAGS) -c -MMD -MF [email protected] $<
TESTDATA = 74-0.txt
74-0.txt:
$(VECHO) " Downloading The Adventures of Tom Sawyer by Mark Twain... "
$(Q)wget -q https://www.gutenberg.org/files/74/74-0.txt
$(Q)$(call pass,$@)
check: $(TESTDATA) $(EXEC)
$(Q)./x < $< > $<.compressed
$(Q)./unx < $<.compressed > $<.restore
$(Q)diff $< $<.restore
$(Q)$(RM) $<.compressed $<.restore
$(Q)$(call pass,$(EXEC))
.PHONY: clean
clean:
-$(RM) $(OBJS) $(EXEC) $(deps)
distclean: clean
-$(RM) $(TESTDATA)
-include $(deps)