Stephane Barbarie | 1408896 | 2017-06-01 16:56:55 -0400 | [diff] [blame] | 1 | PKGNAME = voltha |
| 2 | TARGET = voltha.la |
| 3 | |
| 4 | # Various configurable paths (remember to edit Makefile.in, not Makefile) |
| 5 | prefix = /usr/local |
| 6 | exec_prefix = ${prefix} |
| 7 | datarootdir = ${prefix}/share |
| 8 | datadir = ${datarootdir} |
| 9 | bindir = ${exec_prefix}/bin |
| 10 | includedir = ${prefix}/include |
| 11 | libdir = ${exec_prefix}/lib |
| 12 | mandir = ${datarootdir}/man |
| 13 | libtool = ./libtool |
| 14 | |
| 15 | CC = gcc |
| 16 | INSTALL = /bin/install -c |
| 17 | INSTALL_PROGRAM = ${INSTALL} |
| 18 | INSTALL_DATA = ${INSTALL} -m 644 |
| 19 | LIBS = -lvoltha-netconf-model -lvoltha -lxml2 -lz -lm -ldl -lnetconf |
| 20 | CFLAGS = -I/usr/include/libxml2 -O3 |
| 21 | CPPFLAGS = |
| 22 | LDFLAGS = |
| 23 | LIBTOOL = $(libtool) --tag=CC --quiet |
| 24 | |
| 25 | NETOPEER_MANAGER = /bin/netopeer-manager |
| 26 | NETOPEER_DIR = ${prefix}/etc/netopeer |
| 27 | |
| 28 | MODEL = voltha.yin \ |
| 29 | voltha-config.rng \ |
| 30 | voltha-gdefs-config.rng \ |
| 31 | voltha-schematron.xsl |
| 32 | |
| 33 | SRCS = voltha.c |
| 34 | OBJDIR = .obj |
| 35 | LOBJS = $(SRCS:%.c=$(OBJDIR)/%.lo) |
| 36 | |
| 37 | all: $(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 |
| 48 | install: $(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 |
| 66 | uninstall: |
| 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 |
| 76 | clean: |
| 77 | $(LIBTOOL) --mode clean rm -f $(LOBJS) |
| 78 | $(LIBTOOL) --mode clean rm -f $(TARGET) |
| 79 | rm -rf $(TARGET) $(OBJDIR) |