Whamcloud - gitweb
LU-1434 utils: Add build functionality for wireshark and Lustre/LNet plugins
[fs/lustre-release.git] / lustre / contrib / wireshark / Makefile
1 # Makefile to create the Lustre/LNet plugins for Wireshark.
2 # It is intended to be used by script `wsbuild´ that will buil
3 # a RPM for wireshark and a separate RPM for the Lustre/LNet plugins.
4 #
5 # All configuration should be performed with help of shell script
6 # `wsconfigs.sh' (see can-edit sections).
7 #
8 # When using as a stand-alone makefile, set the macros WS_HOME,
9 # PLUGIN_DIR and PLUGIN_COMPILE_FLAGS to the values associated with
10 # your wireshark installation.
11 # Alternatively modify `wsconfigs.sh´ accordingly to your wireshar
12 # installation, source wsconfigs.sh and build with help of:
13 #
14 #      make -e -f Makefile
15 #
16
17
18 # Installation directory of the Wireshark source code
19 #    Note: Leave the macro undefined when using the wsbuild script.
20 #
21 # WS_HOME =
22 WS_HOME = 
23
24 # Installation directory for the (compiled) Wireshark plugins
25 #    Change the value of the following macro to the installation directory
26 #    of the Wireshark plugins for your installation 
27 #
28 #    Note: When using the cbuild script leave the macro undefined
29 #    (default: /usr/lib/wireshark/plugins/$(WS_VERSION))
30 #
31 #    For non-root and  non-rpmbuilds you might want to set the value to ${HOME}/.wireshark/plugins
32 PLUGIN_DIR =
33
34 CFLAGS = -DINET6 -D_U_=__attribute__\(\(unused\)\) -Wall -Wpointer-arith -g -DXTHREADS -D_REENTRANT -DXUSE_MTSAFE_API -fPIC -DPIC
35
36 ifdef WS_HOME
37 #INCS = $(shell echo "-I${WS_HOME} `pkg-config --libs --cflags glib-2.0`")
38 INCS = $(shell echo "-I${WS_HOME} $(PLUGIN_COMPILE_FLAGS)") -DHAVE_CONFIG_H 
39 else
40 INCS = $(shell pkg-config --libs --cflags wireshark) $(shell echo "$(PLUGIN_COMPILE_FLAGS)")
41 endif
42
43 CFLAGS += $(INCS)
44
45 SRCS_LNET = packet-lnet.c
46 SRCS_LUSTRE = packet-lustre.c
47
48 CC   = gcc
49
50 OBJS_LNET = $(foreach src, $(SRCS_LNET), $(src:.c=.o))
51 OBJS_LUSTRE = $(foreach src, $(SRCS_LUSTRE), $(src:.c=.o))
52
53 PLUGINS=lnet.so lustre.so
54
55 ifneq ($(shell id -u), 0)
56   ifndef DESTDIR
57     PLUGIN_DIR = ${HOME}/.wireshark/plugins
58   endif
59 endif
60
61 ifndef PLUGIN_DIR
62   ifndef WS_VERSION
63     ifndef WS_HOME
64       $(error "WS_HOME not defined")
65     endif
66     WS_CONFIG=$(WS_HOME)/config.h
67     WS_VERSION:=$(shell sed "s/^.define[[:space:]]*VERSION[[:space:]]*\"\(.*\)\"/\1/p;d" ${WS_CONFIG})
68    endif
69    ifeq ($(shell if [ -r /etc/SuSE-release ] ; then echo 0; else echo 1; fi ), 0)
70      PLUGIN_DIR = $(DESTDIR)/usr/lib64/wireshark/plugins/$(WS_VERSION)
71    else
72      PLUGIN_DIR = $(DESTDIR)/usr/lib/wireshark/plugins/$(WS_VERSION)
73   endif 
74 endif
75
76
77 all: $(PLUGINS)
78
79 lustre.so: $(OBJS_LUSTRE)
80         @echo "Running $(INCS)"
81         $(CC) -shared $(OBJS_LUSTRE) -o $@
82
83 lnet.so: $(OBJS_LNET)
84         @echo $(INCS)
85         $(CC) -shared $(OBJS_LNET) -o $@
86
87 install: $(PLUGINS)
88         mkdir -p $(PLUGIN_DIR)
89         install $(PLUGINS) $(PLUGIN_DIR)/
90
91 clean:
92         rm -f $(PLUGINS) $(OBJS_LNET) $(OBJS_LUSTRE)
93
94 extraclean: clean
95         (cd $(PLUGIN_DIR)/; rm -f $(PLUGINS))