build as lib
This commit is contained in:
86
MakeApp.mk
Normal file
86
MakeApp.mk
Normal file
@@ -0,0 +1,86 @@
|
||||
VERSION := 0
|
||||
SUBVERSION := 8
|
||||
MINORVERSION := 2-SNAPSHOT
|
||||
|
||||
#prefix := /usr
|
||||
prefix := /usr/local
|
||||
|
||||
sbin := $(prefix)/sbin
|
||||
man8 := $(prefix)/share/man/man8
|
||||
|
||||
all: nethogs decpcap_test
|
||||
|
||||
runtests: test
|
||||
./test
|
||||
|
||||
|
||||
# nethogs_testsum
|
||||
|
||||
CFLAGS?=-Wall -Wextra
|
||||
CXXFLAGS?=-Wall -Wextra
|
||||
|
||||
OBJS=packet.o connection.o process.o refresh.o decpcap.o cui.o inode2prog.o conninode.o devices.o
|
||||
|
||||
NCURSES_LIBS?=-lncurses
|
||||
|
||||
.PHONY: tgz
|
||||
|
||||
tgz: clean
|
||||
cd .. ; tar czvf nethogs-$(VERSION).$(SUBVERSION).$(MINORVERSION).tar.gz --exclude-vcs nethogs/*
|
||||
|
||||
.PHONY: check uninstall
|
||||
check:
|
||||
@echo "Not implemented"
|
||||
|
||||
install: nethogs nethogs.8
|
||||
install -d -m 755 $(DESTDIR)$(sbin)
|
||||
install -m 755 nethogs $(DESTDIR)$(sbin)
|
||||
install -d -m 755 $(DESTDIR)$(man8)
|
||||
install -m 644 nethogs.8 $(DESTDIR)$(man8)
|
||||
@echo
|
||||
@echo "Installed nethogs to $(DESTDIR)$(sbin)"
|
||||
@echo
|
||||
@echo "You might have to add this directory to your PATH and/or refresh your shells' path cache with a command like 'hash -r'."
|
||||
|
||||
uninstall:
|
||||
rm $(DESTDIR)$(sbin)/nethogs
|
||||
rm $(DESTDIR)$(man8)/nethogs.8
|
||||
|
||||
test: test.cpp
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) test.cpp -o test -lpcap -lm ${NCURSES_LIBS} -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -DMINORVERSION=\"$(MINORVERSION)\"
|
||||
|
||||
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)\"
|
||||
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)\"
|
||||
|
||||
decpcap_test: decpcap_test.cpp decpcap.o
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) decpcap_test.cpp decpcap.o -o decpcap_test -lpcap -lm
|
||||
|
||||
#-lefence
|
||||
|
||||
refresh.o: refresh.cpp refresh.h nethogs.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c refresh.cpp
|
||||
process.o: process.cpp process.h nethogs.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c process.cpp
|
||||
packet.o: packet.cpp packet.h nethogs.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c packet.cpp
|
||||
connection.o: connection.cpp connection.h nethogs.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c connection.cpp
|
||||
decpcap.o: decpcap.c decpcap.h
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c decpcap.c
|
||||
inode2prog.o: inode2prog.cpp inode2prog.h nethogs.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c inode2prog.cpp
|
||||
conninode.o: conninode.cpp nethogs.h conninode.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c conninode.cpp
|
||||
#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)\"
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f $(OBJS)
|
||||
rm -f nethogs
|
||||
rm -f test
|
||||
rm -f decpcap_test
|
||||
@@ -11,17 +11,17 @@ all: libnethogs
|
||||
LDFLAGS:= -shared
|
||||
CXXINCLUDES :=
|
||||
VISIBILITY=-fvisibility=hidden
|
||||
ODIR_BASE := objs/lib
|
||||
ODIR_BASE := obj
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
# Debug mode options
|
||||
$(info Bulding debug version)
|
||||
ODIR:=$(ODIR_BASE)/debug
|
||||
ODIR:=$(ODIR_BASE)/lib/debug
|
||||
CFLAGS?=-Wall -Wextra -O0 -g -fPIC $(VISIBILITY)
|
||||
CXXFLAGS?=--std=c++11 --std=c++11 -Wall -Wextra -O0 -g -fPIC $(VISIBILITY) $(CXXINCLUDES)
|
||||
else
|
||||
# Release mode options
|
||||
ODIR:=$(ODIR_BASE)/release
|
||||
ODIR:=$(ODIR_BASE)/lib/release
|
||||
CFLAGS?=-Wall -Wextra -O3 -fPIC $(VISIBILITY)
|
||||
CXXFLAGS?=-Wall --std=c++11 -Wextra -O3 -fPIC $(VISIBILITY) $(CXXINCLUDES)
|
||||
endif
|
||||
@@ -91,4 +91,6 @@ $(ODIR)/libnethogs.o: libnethogs.cpp libnethogs.h
|
||||
clean:
|
||||
rm -f $(OBJS)
|
||||
rm -f libnethogs.so
|
||||
mkdir -p $(ODIR)
|
||||
rmdir -p --ignore-fail-on-non-empty $(ODIR)
|
||||
|
||||
|
||||
75
Makefile
75
Makefile
@@ -1,86 +1,31 @@
|
||||
VERSION := 0
|
||||
SUBVERSION := 8
|
||||
MINORVERSION := 2-SNAPSHOT
|
||||
|
||||
#prefix := /usr
|
||||
prefix := /usr/local
|
||||
|
||||
sbin := $(prefix)/sbin
|
||||
man8 := $(prefix)/share/man/man8
|
||||
|
||||
all: nethogs decpcap_test
|
||||
$(MAKE) -f MakeApp.mk $@
|
||||
$(MAKE) -f MakeLib.mk $@
|
||||
|
||||
runtests: test
|
||||
./test
|
||||
|
||||
|
||||
# nethogs_testsum
|
||||
|
||||
CFLAGS?=-Wall -Wextra
|
||||
CXXFLAGS?=-Wall -Wextra
|
||||
|
||||
OBJS=packet.o connection.o process.o refresh.o decpcap.o cui.o inode2prog.o conninode.o devices.o
|
||||
|
||||
NCURSES_LIBS?=-lncurses
|
||||
|
||||
.PHONY: tgz
|
||||
|
||||
tgz: clean
|
||||
cd .. ; tar czvf nethogs-$(VERSION).$(SUBVERSION).$(MINORVERSION).tar.gz --exclude-vcs nethogs/*
|
||||
$(MAKE) -f MakeApp.mk $@
|
||||
|
||||
.PHONY: check uninstall
|
||||
check:
|
||||
@echo "Not implemented"
|
||||
$(MAKE) -f MakeApp.mk $@
|
||||
|
||||
install: nethogs nethogs.8
|
||||
install -d -m 755 $(DESTDIR)$(sbin)
|
||||
install -m 755 nethogs $(DESTDIR)$(sbin)
|
||||
install -d -m 755 $(DESTDIR)$(man8)
|
||||
install -m 644 nethogs.8 $(DESTDIR)$(man8)
|
||||
@echo
|
||||
@echo "Installed nethogs to $(DESTDIR)$(sbin)"
|
||||
@echo
|
||||
@echo "You might have to add this directory to your PATH and/or refresh your shells' path cache with a command like 'hash -r'."
|
||||
$(MAKE) -f MakeApp.mk $@
|
||||
|
||||
uninstall:
|
||||
rm $(DESTDIR)$(sbin)/nethogs
|
||||
rm $(DESTDIR)$(man8)/nethogs.8
|
||||
|
||||
test: test.cpp
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) test.cpp -o test -lpcap -lm ${NCURSES_LIBS} -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -DMINORVERSION=\"$(MINORVERSION)\"
|
||||
$(MAKE) -f MakeApp.mk $@
|
||||
|
||||
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)\"
|
||||
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)\"
|
||||
$(MAKE) -f MakeApp.mk $@
|
||||
|
||||
decpcap_test: decpcap_test.cpp decpcap.o
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) decpcap_test.cpp decpcap.o -o decpcap_test -lpcap -lm
|
||||
|
||||
#-lefence
|
||||
|
||||
refresh.o: refresh.cpp refresh.h nethogs.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c refresh.cpp
|
||||
process.o: process.cpp process.h nethogs.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c process.cpp
|
||||
packet.o: packet.cpp packet.h nethogs.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c packet.cpp
|
||||
connection.o: connection.cpp connection.h nethogs.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c connection.cpp
|
||||
decpcap.o: decpcap.c decpcap.h
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c decpcap.c
|
||||
inode2prog.o: inode2prog.cpp inode2prog.h nethogs.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c inode2prog.cpp
|
||||
conninode.o: conninode.cpp nethogs.h conninode.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c conninode.cpp
|
||||
#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)\"
|
||||
$(MAKE) -f MakeApp.mk $@
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f $(OBJS)
|
||||
rm -f nethogs
|
||||
rm -f test
|
||||
rm -f decpcap_test
|
||||
$(MAKE) -f MakeApp.mk $@
|
||||
$(MAKE) -f MakeLib.mk $@
|
||||
|
||||
Reference in New Issue
Block a user