netmon: Build netmon from the master Makefile

This commit modifies the Makefile at the root of this repository
so that the binary kata-netmon can be built from there.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2018-07-31 15:21:06 -07:00
parent fca74356da
commit f1315908c7
2 changed files with 24 additions and 6 deletions

View File

@ -39,6 +39,7 @@ SCRIPTS :=
# list of binaries to install
BINLIST :=
BINLIBEXECLIST :=
BIN_PREFIX = $(PROJECT_TYPE)
PROJECT_DIR = $(PROJECT_TAG)
@ -49,6 +50,11 @@ TARGET = $(BIN_PREFIX)-runtime
TARGET_OUTPUT = $(CURDIR)/$(TARGET)
BINLIST += $(TARGET)
NETMON_DIR = netmon
NETMON_TARGET = $(PROJECT_TYPE)-netmon
NETMON_TARGET_OUTPUT = $(CURDIR)/$(NETMON_TARGET)
BINLIBEXECLIST += $(NETMON_TARGET)
DESTDIR := /
installing = $(findstring install,$(MAKECMDGOALS))
@ -225,7 +231,12 @@ define SHOW_ARCH
$(shell printf "\\t%s%s\\\n" "$(1)" $(if $(filter $(ARCH),$(1))," (default)",""))
endef
all: runtime
all: runtime netmon
netmon: $(NETMON_TARGET_OUTPUT)
$(NETMON_TARGET_OUTPUT): $(SOURCES)
$(QUIET_BUILD)(cd $(NETMON_DIR) && go build -i -o $@ -ldflags "-X main.version=$(VERSION)")
runtime: $(TARGET_OUTPUT) $(CONFIG)
.DEFAULT: default
@ -405,11 +416,14 @@ check-go-static:
coverage:
$(QUIET_TEST).ci/go-test.sh html-coverage
install: default runtime install-scripts install-completions install-config install-bin
install: default runtime install-scripts install-completions install-config install-bin install-bin-libexec
install-bin: $(BINLIST)
$(foreach f,$(BINLIST),$(call INSTALL_EXEC,$f,$(BINDIR)))
install-bin-libexec: $(BINLIBEXECLIST)
$(foreach f,$(BINLIBEXECLIST),$(call INSTALL_EXEC,$f,$(PKGLIBEXECDIR)))
install-config: $(CONFIG)
$(QUIET_INST)install --mode 0644 -D $(CONFIG) $(DESTDIR)/$(CONFIG_PATH)
@ -420,7 +434,7 @@ install-completions:
$(QUIET_INST)install --mode 0644 -D $(BASH_COMPLETIONS) $(DESTDIR)/$(BASH_COMPLETIONSDIR)/$(notdir $(BASH_COMPLETIONS));
clean:
$(QUIET_CLEAN)rm -f $(TARGET) $(CONFIG) $(GENERATED_GO_FILES) $(GENERATED_FILES) $(COLLECT_SCRIPT)
$(QUIET_CLEAN)rm -f $(TARGET) $(NETMON_TARGET) $(CONFIG) $(GENERATED_GO_FILES) $(GENERATED_FILES) $(COLLECT_SCRIPT)
show-usage: show-header
@printf "• Overview:\n"
@ -483,6 +497,8 @@ show-summary: show-header
@printf "\tbinaries to install :\n"
@printf \
"$(foreach b,$(sort $(BINLIST)),$(shell printf "\\t - $(shell readlink -m $(DESTDIR)/$(BINDIR)/$(b))\\\n"))"
@printf \
"$(foreach b,$(sort $(BINLIBEXECLIST)),$(shell printf "\\t - $(shell readlink -m $(DESTDIR)/$(PKGLIBEXECDIR)/$(b))\\\n"))"
@printf \
"$(foreach s,$(sort $(SCRIPTS)),$(shell printf "\\t - $(shell readlink -m $(DESTDIR)/$(BINDIR)/$(s))\\\n"))"
@printf "\tconfig to install (CONFIG) : %s\n" $(CONFIG)

View File

@ -61,7 +61,6 @@ type Route struct {
const (
netmonName = "kata-netmon"
netmonVersion = "0.0.1"
kataCmd = "kata-network"
kataCLIAddIfaceCmd = "add-iface"
@ -83,6 +82,9 @@ const (
storageFilePerm = os.FileMode(0640)
)
// version is the netmon version. This variable is populated at build time.
var version = "unknown"
type netmonParams struct {
sandboxID string
runtimePath string
@ -110,7 +112,7 @@ type netmon struct {
var netmonLog = logrus.New()
func printVersion() {
fmt.Printf("%s version %s\n", netmonName, netmonVersion)
fmt.Printf("%s version %s\n", netmonName, version)
}
const componentDescription = `is a network monitoring process that is intended to be started in the