-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
56 lines (36 loc) · 1.29 KB
/
Copy pathMakefile
File metadata and controls
56 lines (36 loc) · 1.29 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
CC = gcc
CFLAGS = -Wall -Wformat=2 -Wshadow -Wconversion -std=gnu11 -pthread -Ofast
basedir = $(shell pwd)/
build_path = $(basedir)/build/
include_path = $(basedir)/include/
source_path = $(basedir)/src/
elf_name = slow
sources = $(shell ls $(source_path) 2>/dev/null)
modules = $(sources:%.c=%.c.o)
# -----------------------------------------------------------------------
MAKEFLAGS += --jobs=$(shell nproc)
MAKEFLAGS += --output-sync=target
vpath %.c $(source_path)
vpath %.h $(include_path)
vpath %.o $(build_path)
.PHONY: all cap clean
# -----------------------------------------------------------------------
all: $(elf_name)
clean:
rm -f $(elf_name)
rm -f $(build_path)/*.o
debug: CFLAGS += -g
debug: CXXFLAGS += -g
debug: all
# -----------------------------------------------------------------------
cap: $(elf_name)
sudo setcap "CAP_NET_RAW+ep" $(elf_name)
# -----------------------------------------------------------------------
semaphore.c.o: semaphore.c semaphore.h
bounded_buffer.c.o: bounded_buffer.c bounded_buffer.h semaphore.h
# -----------------------------------------------------------------------
$(elf_name): $(modules)
cd $(build_path) \
&& $(CC) $(CFLAGS) -o $(basedir)/$@ $^ $(libraries)
%.c.o: %.c
$(CC) $(CFLAGS) -c -I$(include_path) $< -o $(build_path)/$@