-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
58 lines (43 loc) · 1.45 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
CROSS_COMPILE ?=
PREFIX ?=
CC := $(CROSS_COMPILE)-gcc
AR := $(CROSS_COMPILE)-ar
LD := $(CROSS_COMPILE)-gcc
CFLAGS := -g -Os -Wall -Werror -Iinc
LDFLAGS := -lrt -lpthread
ifeq ($(SANITIZER), 1)
CFLAGS += -fsanitize=address -fno-omit-frame-pointer -fno-common
LDFLAGS += -fsanitize=address
endif
LIB := ufifo
TARGET := pressure bytestream nolock record record-tag record-tag-cb
all: $(LIB) $(TARGET)
clean:
@rm -vrf $(TARGET) obj
install:
@mkdir -p $(PREFIX)/usr/local/include/$(LIB)/
@cp -av inc/ufifo.h $(PREFIX)/usr/local/include/$(LIB)/
@mkdir -p ${PREFIX}/usr/local/lib/
@cp -av obj/libufifo.so $(PREFIX)/usr/local/lib/
test: $(TARGET)
@for bin in $(TARGET); do ./$$bin || exit 1; done
SRC := src/mutex.c src/fdlock.c src/kfifo.c src/ufifo.c src/dict.c
OBJ := $(addprefix obj/,$(notdir $(patsubst %.c, %.o, $(SRC))))
obj/%.o: src/%.c
@mkdir -p obj
$(CC) -c $(CFLAGS) -fPIC -o $@ $<
$(LIB): $(OBJ)
$(AR) -src obj/lib$@.a $^
$(LD) -shared -fPIC -o obj/lib$@.so $^
pressure: example/pressure.c obj/libufifo.a
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
bytestream: example/bytestream.c obj/libufifo.a
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
nolock: example/nolock.c obj/libufifo.a
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
record: example/record.c obj/libufifo.a
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
record-tag: example/record-tag.c obj/libufifo.a
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
record-tag-cb: example/record-tag-cb.c obj/libufifo.a
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)