Permalink
Browse files

Determine version based on git tag or pwd (fixes #92)

  • Loading branch information...
1 parent a1efe5b commit 9defe58674d8d1202b7b8e1c34b221e0e2edccd4 @raboof committed Jul 12, 2016
Showing with 13 additions and 15 deletions.
  1. +3 −5 Makefile
  2. +3 −0 determineVersion.sh
  3. +3 −5 src/MakeApp.mk
  4. +3 −4 src/MakeLib.mk
  5. +1 −1 src/nethogs.cpp
View
@@ -1,6 +1,4 @@
-export VERSION := 0
-export SUBVERSION := 8
-export MINORVERSION := 3-SNAPSHOT
+export VERSION := $(shell ./determineVersion.sh)
#export PREFIX := /usr
export PREFIX ?= /usr/local
@@ -9,9 +7,9 @@ all: nethogs decpcap_test test
$(MAKE) -C src -f MakeApp.mk $@
$(MAKE) -C src -f MakeLib.mk $@
-.PHONY:
+.PHONY: tgz
tgz: clean
- cd .. ; tar czvf nethogs-$(VERSION).$(SUBVERSION).$(MINORVERSION).tar.gz --exclude-vcs nethogs/*
+ git archive --prefix="nethogs-$(VERSION)/" -o "../nethogs-$(VERSION).tar.gz" HEAD
check:
$(MAKE) -C src -f MakeApp.mk $@
View
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+(git describe 2>/dev/null || pwd | sed -e "s/.*\\///" | sed -e "s/[^-]*//") | tail -c +2
View
@@ -11,8 +11,6 @@ OBJS=packet.o connection.o process.o decpcap.o cui.o inode2prog.o conninode.o de
NCURSES_LIBS?=-lncurses
-.PHONY: tgz
-
.PHONY: check uninstall
check:
@echo "Not implemented"
@@ -29,9 +27,9 @@ uninstall:
rm $(DESTDIR)$(sbin)/nethogs || true
nethogs: main.cpp nethogs.cpp $(OBJS)
- $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) main.cpp $(OBJS) -o nethogs -lpcap -lm ${NCURSES_LIBS} -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -DMINORVERSION=\"$(MINORVERSION)\"
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) main.cpp $(OBJS) -o nethogs -lpcap -lm ${NCURSES_LIBS} -DVERSION=\"$(VERSION)\"
nethogs_testsum: nethogs_testsum.cpp $(OBJS)
- $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) nethogs_testsum.cpp $(OBJS) -o nethogs_testsum -lpcap -lm ${NCURSES_LIBS} -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -DMINORVERSION=\"$(MINORVERSION)\"
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) nethogs_testsum.cpp $(OBJS) -o nethogs_testsum -lpcap -lm ${NCURSES_LIBS} -DVERSION=\"$(VERSION)\"
decpcap_test: decpcap_test.cpp decpcap.o
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) decpcap_test.cpp decpcap.o -o decpcap_test -lpcap -lm
@@ -53,7 +51,7 @@ conninode.o: conninode.cpp nethogs.h conninode.h
#devices.o: devices.cpp devices.h
# $(CXX) $(CXXFLAGS) -c devices.cpp
cui.o: cui.cpp cui.h nethogs.h
- $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c cui.cpp -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -DMINORVERSION=\"$(MINORVERSION)\"
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c cui.cpp -DVERSION=\"$(VERSION)\"
TESTS=conninode_test
View
@@ -1,5 +1,6 @@
LIBRARY=libnethogs.so
-LIBNAME=$(LIBRARY).$(LIBVERSION).$(LIBSUBVERSION).$(LIBMINORVERSION)
+LIBVERSION=$(VERSION)
+LIBNAME=$(LIBRARY).$(LIBVERSION)
SO_NAME=$(LIBRARY).$(LIBVERSION)
libdir := $(PREFIX)/lib
@@ -38,8 +39,6 @@ OBJS=$(addprefix $(ODIR)/,$(OBJ_NAMES))
#$(info $(OBJS))
-.PHONY: tgz
-
.PHONY: uninstall
install: $(LIBNAME)
@@ -102,7 +101,7 @@ $(ODIR)/devices.o: devices.cpp devices.h
$(ODIR)/libnethogs.o: libnethogs.cpp libnethogs.h
@mkdir -p $(ODIR)
- $(CXX) $(CXXFLAGS) -o $@ -c libnethogs.cpp -DVERSION=\"$(LIBVERSION)\" -DSUBVERSION=\"$(LIBSUBVERSION)\" -DMINORVERSION=\"$(LIBMINORVERSION)\"
+ $(CXX) $(CXXFLAGS) -o $@ -c libnethogs.cpp -DVERSION=\"$(LIBVERSION)\"
.PHONY: clean
clean:
View
@@ -61,7 +61,7 @@ bool bughuntmode = false;
bool sortRecv = true;
// viewMode: kb/s or total
int viewMode = VIEWMODE_KBPS;
-const char version[] = " version " VERSION "." SUBVERSION "." MINORVERSION;
+const char version[] = " version " VERSION;
timeval curtime;

0 comments on commit 9defe58

Please sign in to comment.