blob: bdce43dd3121fe831e34278acfed1790c4973530 [file] [log] [blame]
Stephane Barbarie14088962017-06-01 16:56:55 -04001PKGNAME = voltha
2TARGET = voltha.la
3
4# Various configurable paths (remember to edit Makefile.in, not Makefile)
5prefix = /usr/local
6exec_prefix = ${prefix}
7datarootdir = ${prefix}/share
8datadir = ${datarootdir}
9bindir = ${exec_prefix}/bin
10includedir = ${prefix}/include
11libdir = ${exec_prefix}/lib
12mandir = ${datarootdir}/man
13libtool = ./libtool
14
15CC = gcc
16INSTALL = /bin/install -c
17INSTALL_PROGRAM = ${INSTALL}
18INSTALL_DATA = ${INSTALL} -m 644
19LIBS = -lvoltha-netconf-model -lvoltha -lxml2 -lz -lm -ldl -lnetconf
20CFLAGS = -I/usr/include/libxml2 -O3
21CPPFLAGS =
22LDFLAGS =
23LIBTOOL = $(libtool) --tag=CC --quiet
24
25NETOPEER_MANAGER = /bin/netopeer-manager
26NETOPEER_DIR = ${prefix}/etc/netopeer
27
28MODEL = voltha.yin \
29 voltha-config.rng \
30 voltha-gdefs-config.rng \
31 voltha-schematron.xsl
32
33SRCS = voltha.c
34OBJDIR = .obj
35LOBJS = $(SRCS:%.c=$(OBJDIR)/%.lo)
36
37all: $(TARGET)
38
39$(TARGET): $(LOBJS)
40 $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(LIBS) -avoid-version -module -shared -export-dynamic --mode=link -o $@ $^ -rpath $(libdir)
41
42$(OBJDIR)/%.lo: %.c
43 @[ -d $$(dirname $@) ] || \
44 (mkdir -p $$(dirname $@))
45 $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(CPPFLAGS) -fPIC -shared -c $< -o $@
46
47.PHONY: install
48install: $(TARGET)
49 $(INSTALL) -m 775 -d $(DESTDIR)/$(libdir)
50 $(LIBTOOL) --mode=install cp $(TARGET) $(DESTDIR)/$(libdir)/;
51 $(INSTALL) -d $(NETOPEER_DIR)/voltha/
52 @for i in $(MODEL); do \
53 $(INSTALL_DATA) -m 600 $$i $(NETOPEER_DIR)/$(PKGNAME)/; \
54 done
55 if test -n "$(NETOPEER_MANAGER)"; then \
56 if test -n "`$(NETOPEER_MANAGER) list | grep "^$(PKGNAME) ("`"; then \
57 $(NETOPEER_MANAGER) rm --name $(PKGNAME); \
58 fi; \
59 $(NETOPEER_MANAGER) add --name $(PKGNAME) \
60 --model $(NETOPEER_DIR)/$(PKGNAME)/$(PKGNAME).yin \
61 --transapi $(DESTDIR)/$(libdir)/$(PKGNAME).so \
62 --datastore $(NETOPEER_DIR)/$(PKGNAME)/datastore.xml; \
63 fi
64
65.PHONY: uninstall
66uninstall:
67 $(LIBTOOL) --mode=uninstall rm -rf $(DESTDIR)/$(libdir)/$(TARGET);
68 rm -rf $(NETOPEER_DIR)/$(PKGNAME)/
69 if test -n "$(NETOPEER_MANAGER)"; then \
70 if test -n "`$(NETOPEER_MANAGER) list | grep "^$(PKGNAME) ("`"; then \
71 $(NETOPEER_MANAGER) rm --name $(PKGNAME); \
72 fi; \
73 fi
74
75.PHONY: clean
76clean:
77 $(LIBTOOL) --mode clean rm -f $(LOBJS)
78 $(LIBTOOL) --mode clean rm -f $(TARGET)
79 rm -rf $(TARGET) $(OBJDIR)