Stephane Barbarie | 1408896 | 2017-06-01 16:56:55 -0400 | [diff] [blame] | 1 | PKGNAME = @PROJECTNAME@ |
| 2 | TARGET = @PROJECTNAME@.la |
| 3 | |
| 4 | # Various configurable paths (remember to edit Makefile.in, not Makefile) |
| 5 | prefix = @prefix@ |
| 6 | exec_prefix = @exec_prefix@ |
| 7 | datarootdir = @datarootdir@ |
| 8 | datadir = @datadir@ |
| 9 | bindir = @bindir@ |
| 10 | includedir = @includedir@ |
| 11 | libdir = @libdir@ |
| 12 | mandir = @mandir@ |
| 13 | libtool = @libtool@ |
| 14 | |
| 15 | CC = @CC@ |
| 16 | INSTALL = @INSTALL@ |
| 17 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ |
| 18 | INSTALL_DATA = @INSTALL_DATA@ |
| 19 | LIBS = @LIBS@ |
| 20 | CFLAGS = @CFLAGS@ |
| 21 | CPPFLAGS = @CPPFLAGS@ |
| 22 | LDFLAGS = @LDFLAGS@ |
| 23 | LIBTOOL = $(libtool) --tag=CC --quiet |
| 24 | |
| 25 | NETOPEER_MANAGER = @NETOPEER_MANAGER@ |
| 26 | NETOPEER_DIR = @NETOPEER_DIR@ |
| 27 | |
| 28 | MODEL = voltha.yin \ |
| 29 | voltha-config.rng \ |
| 30 | voltha-gdefs-config.rng \ |
| 31 | voltha-schematron.xsl |
| 32 | |
| 33 | SRCS = @PROJECTNAME@.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) |