-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
39 lines (30 loc) · 975 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
UNAME := $(shell uname -s)
SRCDIR = src
PRVDIR = priv
ifeq ($(UNAME),Linux)
CFLAGS = -fPIC -std=c99 -D_GNU_SOURCE -pedantic-errors -Wall -Wextra -I$(ERTS_INCLUDE_DIR)
LFLAGS = -shared -dynamiclib -undefined,dynamic_lookup
SOURCES = src/sniff_linux.c src/sniff_posix.c src/sniff.c
TARGET = $(PRVDIR)/sniff_linux.so
OBJDIR = obj/sniff_linux
endif
ifeq ($(UNAME),Darwin)
CFLAGS = -fPIC -std=c99 -D_GNU_SOURCE -pedantic-errors -Wall -Wextra -I$(ERTS_INCLUDE_DIR)
LFLAGS = -shared -dynamiclib -undefined dynamic_lookup
SOURCES = src/sniff_darwin.c src/sniff_posix.c src/sniff.c
TARGET = $(PRVDIR)/sniff_darwin.so
OBJDIR = obj/sniff_darwin
endif
HEADERS = $(SRCDIR)/sniff.h
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
.PHONY: all clean
all: $(TARGET)
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c $(HEADERS)
mkdir -p $(OBJDIR)
$(CC) $(CFLAGS) -o $@ -c $<
$(TARGET): $(OBJECTS)
mkdir -p $(PRVDIR)
$(CC) $(LFLAGS) -o $@ $^
clean:
rm -fr $(OBJDIR)
rm -f $(TARGET)