-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (61 loc) · 1.89 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
65
66
67
68
69
70
71
72
73
74
75
STRICT_COMPILE = 0
CFLAGS = -Wall
LDFLAGS = -lpthread -lrt -lcap -lnet
OUTDIR = build
TESTDIR = tests
SRCDIR = library
INCLDIR = include
# Use VERBOSE=1 to echo all Makefile commands when running
VERBOSE ?= 0
ifneq ($(VERBOSE), 1)
Q=@
endif
# Use DEBUG_ENABLE=1 for a debug build
DEBUG_ENABLE ?= 0
ifeq ($(DEBUG_ENABLE), 1)
CFLAGS += -DDEBUG_ENABLE -g
endif
ifeq ($(STRICT_COMPILE),1)
CFLAGS += -O2 -W -Werror -Wstrict-prototypes -Wmissing-prototypes
CFLAGS += -Wmissing-declarations -Wold-style-definition -Wpointer-arith
CFLAGS += -Wcast-align -Wnested-externs -Wcast-qual
CFLAGS += -Wformat-security -Wundef -Wwrite-strings
CFLAGS += -Wbad-function-cast -Wformat-nonliteral -Wsuggest-attribute=format -Winline
CFLAGS += -std=gnu99
endif
VERSION = $(shell grep LIBNETBFD_VERSION $(INCLDIR)/libnetbfd.h | cut -d " " -f 3)
# Use SDK environment if available
CC = $(shell echo $$CC)
ifeq ($(CC),)
CC = $(shell which gcc)
endif
ifeq ($(PREFIX),)
PREFIX := /usr/local
endif
# Pass on vars to submakes
export
libs:
$(Q)rm -rf $(OUTDIR) 2> /dev/null ||:
$(Q)mkdir $(OUTDIR)
$(Q)$(CC) -c $(CFLAGS) -fpic $(SRCDIR)/libnetbfd.c $(SRCDIR)/bfd_session.c $(SRCDIR)/bfd_packet.c
$(Q)$(CC) -shared -Wl,-soname,libnetbfd.so.$(VERSION) -o $(OUTDIR)/libnetbfd.so.$(VERSION) libnetbfd.o bfd_session.o bfd_packet.o $(LDFLAGS)
$(Q)rm *.o
install:
$(Q)mkdir -p $(PREFIX)/include/libnetbfd
$(Q)if [ ! -d $(PREFIX)/lib ] ; then \
mkdir -p $(PREFIX)/lib ; \
fi
$(Q)cp -d $(OUTDIR)/libnetbfd.so* $(PREFIX)/lib
$(Q)cp $(INCLDIR)/*.h $(PREFIX)/include/libnetbfd
$(Q)ln -sf $(PREFIX)/lib/libnetbfd.so.$(VERSION) $(PREFIX)/lib/libnetbfd.so
uninstall:
$(Q)rm -rf $(PREFIX)/include/libnetbfd 2> /dev/null ||:
$(Q)rm -rf $(PREFIX)/lib/libnetbfd.so* 2> /dev/null ||:
test:
$(Q)$(MAKE) -C $(TESTDIR) bins
test-run: test
$(Q)cd $(TESTDIR) ; \
./run.sh
clean:
$(Q)rm -rf $(OUTDIR) 2> /dev/null ||:
$(Q)$(MAKE) -C $(TESTDIR) clean