Whamcloud - gitweb
LU-1434 utils: Update Makefile to work out of the box
authorNathaniel Clark <nathaniel.l.clark@intel.com>
Mon, 17 Dec 2012 17:21:29 +0000 (12:21 -0500)
committerOleg Drokin <green@whamcloud.com>
Fri, 21 Dec 2012 18:07:47 +0000 (13:07 -0500)
Add ability to install plugins into user's home directory if not root.
Build using pkg-config for wireshark.

Signed-off-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Change-Id: I5b3f5d6df7e5f1de9681645f7f2f4d01800b40cd
Reviewed-on: http://review.whamcloud.com/4851
Tested-by: Hudson
Reviewed-by: Doug Oucharek <doug.s.oucharek@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/contrib/wireshark/Makefile

index a8fca9d..9caa4f0 100644 (file)
@@ -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))