-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (52 loc) · 1.6 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
# simple Makefile
# create dependency rules in hidden directory in $DEPDIR
# include them
# -*- mode: makefile;-*-
# simple Makefile with dependency rules
DOCTITLE = "A Simple Ringbuffer In C"
CC = gcc
CFLAGS = -O2 -g -Wall -DDEBUG_LOGGING
RM = rm -f
# use the /usr/bin/time program and not bash time reserved word
# -p: time conforms with POSIX 1003.2
# add timestamp to ringbuffer code, remove this
# TIME = /usr/bin/time -p
TESTLOG = ./rb.log
LIBS = -pthread
OBJS := ringbuffer.o logevt.o
BINS := ringbuffer
all: $(BINS)
# executable: object dependencies
ringbuffer: $(OBJS)
$(CC) $(CFLAGS) $^ -o $@ $(LIBS)
# compile object file and create dependency file
%.o: %.c
$(CC) $(CFLAGS) -c $<
$(CC) -MM $(CFLAGS) $< > $*.d
# https://www.gnu.org/software/make/manual/html_node/Include.html
# include all the dependency rule files, ignore if none exist
-include $(OBJS:.o=.d)
test:
@echo "start tests" > $(TESTLOG)
@echo validation test
@$(TIME) ./ringbuffer -t 1 >> $(TESTLOG)
@echo simple stress
@$(TIME) ./ringbuffer -t 2 >> /tmp/rb.logs
@echo large stress using spinlock for critical section
@$(TIME) ./ringbuffer -t 3 -c 10000000 >> $(TESTLOG)
@echo large stress using pthread mutex for critical section
@$(TIME) ./ringbuffer -t 3 -c 10000000 -m >> $(TESTLOG)
@echo See stdout results in $(TESTLOG)
# rule to convert a markdown doc to html
# be sure html files are in .gitignore
%.html :: %.md
@echo "view with firefox $@"
pandoc --metadata pagetitle=${DOCTITLE} -f markdown -s $< -o $@
# remove all generated files
clean:
$(RM) *.o
$(RM) *.d
$(RM) *.html
$(RM) $(BINS)
$(RM) $(TESTLOG)
.PHONY: clean