From 8d187572d40847d4e55473acd5396901e302f980 Mon Sep 17 00:00:00 2001 From: Nathaniel Clark Date: Mon, 17 Dec 2012 12:21:29 -0500 Subject: [PATCH] LU-1434 utils: Update Makefile to work out of the box Add ability to install plugins into user's home directory if not root. Build using pkg-config for wireshark. Signed-off-by: Nathaniel Clark Change-Id: I5b3f5d6df7e5f1de9681645f7f2f4d01800b40cd Reviewed-on: http://review.whamcloud.com/4851 Tested-by: Hudson Reviewed-by: Doug Oucharek Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/contrib/wireshark/Makefile | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/lustre/contrib/wireshark/Makefile b/lustre/contrib/wireshark/Makefile index a8fca9d..9caa4f0 100644 --- a/lustre/contrib/wireshark/Makefile +++ b/lustre/contrib/wireshark/Makefile @@ -1,5 +1,6 @@ # Modify to point to your Wireshark and glib include directories -INCS = -I$(HOME)/wireshark-1.6.8 `pkg-config --libs --cflags glib-2.0` +#INCS = -I$(HOME)/wireshark-1.6.8 `pkg-config --libs --cflags glib-2.0` +INCS = `pkg-config --libs --cflags wireshark` SRCS_LNET = packet-lnet.c SRCS_LUSTRE = packet-lustre.c @@ -9,26 +10,32 @@ CC = gcc OBJS_LNET = $(foreach src, $(SRCS_LNET), $(src:.c=.o)) OBJS_LUSTRE = $(foreach src, $(SRCS_LUSTRE), $(src:.c=.o)) -PLUGIN_NAME1 = lnet -PLUGIN_NAME2 = lustre -PLUGIN_DIR = /usr/local/lib/wireshark/plugins/1.6.8 -PLUGIN1 = $(PLUGIN_DIR)/$(PLUGIN_NAME1).so -PLUGIN2 = $(PLUGIN_DIR)/$(PLUGIN_NAME2).so +PLUGINS=lnet.so lustre.so + +ifeq ($(shell id -u), 0) +WS_CONFIG=$(shell pkg-config --variable=includedir wireshark)/wireshark/config.h +WS_VERSION:=$(shell sed "s/^.define VERSION //p;d" ${WS_CONFIG}) +PLUGIN_DIR = /usr/local/lib/wireshark/plugins/$(WS_VERSION) +else +PLUGIN_DIR = ${HOME}/.wireshark/plugins +endif CFLAGS = -DHAVE_CONFIG_H $(INCS) -DINET6 -D_U_=__attribute__\(\(unused\)\) -Wall -Wpointer-arith -g -DXTHREADS -D_REENTRANT -DXUSE_MTSAFE_API -fPIC -DPIC -$(PLUGIN1) : $(OBJS_LNET) $(OBJS_LUSTRE) - mkdir -p $(PLUGIN_DIR) - $(CC) -shared $(OBJS_LNET) -o $@ - $(CC) -shared $(OBJS_LUSTRE) -o $(PLUGIN2) +all: $(PLUGINS) -$(PLUGIN2) : $(OBJS_LUSTRE) - mkdir -p $(PLUGIN_DIR) +lustre.so: $(OBJS_LUSTRE) $(CC) -shared $(OBJS_LUSTRE) -o $@ -%.o : %.c - $(CC) -c $(CFLAGS) $< -o $@ +lnet.so: $(OBJS_LNET) + $(CC) -shared $(OBJS_LNET) -o $@ + +install: $(PLUGINS) + mkdir -p $(PLUGIN_DIR) + install $(PLUGINS) $(PLUGIN_DIR)/ clean: - rm -f $(PLUGIN1) $(OBJS_LNET) - rm -f $(PLUGIN2) $(OBJS_LUSTRE) + rm -f $(PLUGINS) $(OBJS_LNET) $(OBJS_LUSTRE) + +extraclean: clean + (cd $(PLUGIN_DIR)/; rm -f $(PLUGINS)) -- 1.8.3.1