forked from raoulmillais/linux-system-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
40 lines (33 loc) · 1.21 KB
/
Makefile
File metadata and controls
40 lines (33 loc) · 1.21 KB
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
CC=gcc
CFLAGS?=-Wall -Werror -g
AWK?=awk
SORT?=sort
PR?=pr
VPATH?=src
# daemon not included yet due to undefined NR_COUNT compiler error
SOURCES=atexit-example block-count custom-pidof fake-system filesize filetype
SOURCES+=getaffinity getscheduler getsid-example map-example naive_writev
SOURCES+=poll-example print-inode readv rlim schedulerpriorities select-example
SOURCES+=setaffinity setscheduler wait-example writev daemon find-file-in-dir
SOURCES+=eject inotify-q-size calloc sigint more-signals harakiri malloc-usable
SOURCES+=how-many-hz
all: $(SOURCES) thread
$(SOURCES): %: %.c
$(CC) $(CFLAGS) $< -o out/$@
thread: thread-example.c
$(CC) $(CFLAGS) -pthread $< -o out/$@
# The book says that linking to librt is required for this example although I
# encountered no compiler, linker warnings, and the program output remains the
# same
stop-all-the-clocks: stop-all-the-clocks.c
$(CC) $(CFLAGS) -lrt $< -o out/$@
.PHONY: clean
clean:
rm -f out/*
.PHONY: help
help:
@$(MAKE) --print-data-base --question | \
$(AWK) '/^[^.%][-A-Za-z0-9_]*:/ \
{ print substr($$1,1,length($$1)-1) }' | \
$(SORT) | \
$(PR) --omit-pagination --width=80 --columns=4