From 4c5c87c1f392f4eb0c14906ee1b8e08e28d6ee99 Mon Sep 17 00:00:00 2001 From: Mohamed Boussaffa Date: Sun, 13 Mar 2016 06:38:59 +0800 Subject: [PATCH] Proper handling of versions of the library --- .gitignore | 2 +- MakeApp.mk | 4 ++++ MakeLib.mk | 35 ++++++++++++++++++++++++----------- Makefile | 4 ---- libnethogs.h | 2 +- refresh.h | 22 ---------------------- 6 files changed, 30 insertions(+), 39 deletions(-) delete mode 100644 refresh.h diff --git a/.gitignore b/.gitignore index 2cd66cd..881125f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,5 @@ TAGS *.o *~ nethogs.project -libnethogs.so +libnethogs.so.* libnethogs.a diff --git a/MakeApp.mk b/MakeApp.mk index 9a82ebd..411d6b7 100644 --- a/MakeApp.mk +++ b/MakeApp.mk @@ -1,3 +1,7 @@ +VERSION := 0 +SUBVERSION := 8 +MINORVERSION := 2-SNAPSHOT + #prefix := /usr prefix := /usr/local diff --git a/MakeLib.mk b/MakeLib.mk index ab71646..d90f89a 100644 --- a/MakeLib.mk +++ b/MakeLib.mk @@ -1,10 +1,18 @@ +LIBVERSION := 0 +LIBSUBVERSION := 1 +LIBMINORVERSION := 0 + +LIBRARY=libnethogs.so +LIBNAME=$(LIBRARY).$(LIBVERSION).$(LIBSUBVERSION).$(LIBMINORVERSION) +SO_NAME=$(LIBRARY).$(LIBVERSION) + prefix := /usr/local libdir := $(prefix)/lib incdir := $(prefix)/include -all: libnethogs.so libnethogs.a +all: $(LIBNAME) libnethogs.a -LDFLAGS:= -shared +LDFLAGS:= -shared -Wl,-soname,$(SO_NAME) CXXINCLUDES := VISIBILITY=-fvisibility=hidden ODIR_BASE := obj @@ -31,10 +39,14 @@ OBJS=$(addprefix $(ODIR)/,$(OBJ_NAMES)) .PHONY: uninstall -install: libnethogs.so +install: $(LIBNAME) install -d -m 755 $(DESTDIR)$(libdir) - install -m 755 libnethogs.so $(DESTDIR)$(libdir) - @echo "Installed libnethogs.so to $(DESTDIR)$(libdir)" + install -m 755 $(LIBNAME) $(DESTDIR)$(libdir) + @echo "Installed $(LIBNAME) to $(DESTDIR)$(libdir)" + ldconfig + +install_dev: install + @ln -s $(DESTDIR)$(libdir)/$(LIBNAME) $(DESTDIR)$(libdir)/$(LIBRARY) install -m 755 libnethogs.a $(DESTDIR)$(libdir) @echo "Installed libnethogs.a to $(DESTDIR)$(libdir)" install -d -m 755 $(DESTDIR)$(incdir) @@ -43,12 +55,13 @@ install: libnethogs.so ldconfig uninstall: - rm $(DESTDIR)$(libdir)/libnethogs.so - rm $(DESTDIR)$(libdir)/libnethogs.a - rm $(DESTDIR)$(incdir)/libnethogs.h + rm -f $(DESTDIR)$(libdir)/$(LIBNAME) + rm -f $(DESTDIR)$(libdir)/$(LIBRARY) + rm -f $(DESTDIR)$(libdir)/libnethogs.a + rm -f $(DESTDIR)$(incdir)/libnethogs.h ldconfig -libnethogs.so: $(OBJS) +$(LIBNAME): $(OBJS) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(OBJS) -o $@ -lpcap libnethogs.a: $(OBJS) @@ -86,12 +99,12 @@ $(ODIR)/devices.o: devices.cpp devices.h $(ODIR)/libnethogs.o: libnethogs.cpp libnethogs.h @mkdir -p $(ODIR) - $(CXX) $(CXXFLAGS) -o $@ -c libnethogs.cpp -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -DMINORVERSION=\"$(MINORVERSION)\" + $(CXX) $(CXXFLAGS) -o $@ -c libnethogs.cpp -DVERSION=\"$(LIBVERSION)\" -DSUBVERSION=\"$(LIBSUBVERSION)\" -DMINORVERSION=\"$(LIBMINORVERSION)\" .PHONY: clean clean: rm -f $(OBJS) - rm -f libnethogs.so + rm -f $(LIBNAME) rm -f libnethogs.a mkdir -p $(ODIR) rmdir -p --ignore-fail-on-non-empty $(ODIR) diff --git a/Makefile b/Makefile index e2974e0..f4c32a2 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,3 @@ -export VERSION := 0 -export SUBVERSION := 8 -export MINORVERSION := 2-SNAPSHOT - all: nethogs decpcap_test $(MAKE) -f MakeApp.mk $@ $(MAKE) -f MakeLib.mk $@ diff --git a/libnethogs.h b/libnethogs.h index 2eca2f1..3f6792d 100644 --- a/libnethogs.h +++ b/libnethogs.h @@ -37,7 +37,7 @@ typedef void(*NethogsMonitorCallback)(NethogsMonitorUpdate const*); /** * @brief Enter the process monitoring loop and reports updates using the * callback provided as parameter. - * This call will block until nethogsmonitor_stop is called or a failure occurs. + * This call will block until nethogsmonitor_breakloop is called or a failure occurs. * @param cb A pointer to a callback function following the NethogsMonitorCallback definition */ diff --git a/refresh.h b/refresh.h deleted file mode 100644 index d7c06ae..0000000 --- a/refresh.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * refresh.h - * - * Copyright (c) 2004 Arnout Engelen - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -void alarm_cb (int i);