merge an avl list implementation (imported from PacketBB)
[project/libubox.git] / Makefile
1 CC?=gcc
2 CFLAGS?=-O2
3 CFLAGS+=-std=gnu99 -Wall -Werror -pedantic -fpic
4 LDFLAGS?=
5 LIBNL=-lnl-tiny
6 PREFIX=/usr
7 INCLUDE_DIR=$(PREFIX)/include/libubox
8 LIBDIR=$(PREFIX)/lib
9 CPPFLAGS=
10
11 OS=$(shell uname)
12 FILES=blob.c blobmsg.c hash.c uhtbl.c usock.c uloop.c avl.c
13 ifeq ($(OS),Linux)
14 FILES += unl.c
15 LIBS += $(LIBNL)
16 LDFLAGS_SHARED=-shared -Wl,-soname,$@
17 SHLIB_EXT=so
18 endif
19 ifeq ($(OS),Darwin)
20 LDFLAGS_SHARED=-dynamiclib
21 SHLIB_EXT=dylib
22 endif
23
24 all: libubox.$(SHLIB_EXT)
25
26 libubox.$(SHLIB_EXT): $(FILES)
27 $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(LDFLAGS_SHARED)
28
29 install-headers:
30 mkdir -p $(INCLUDE_DIR)
31 cp *.h $(INCLUDE_DIR)/
32
33 install-lib:
34 mkdir -p $(LIBDIR)
35 cp libubox.$(SHLIB_EXT) $(LIBDIR)/
36
37 install: install-lib install-headers
38
39 clean:
40 rm -f *.$(SHLIB_EXT)
41