Whamcloud - gitweb
LU-2906 ldlm: use accessor macros for l_flags
[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 # Minimum Wireshark Version - This should match the README file.
19 #
20 MIN_WIRESHARK_VERSION=1.6.8
21
22 # Installation directory of the Wireshark source code
23 #    Note: Leave the macro undefined when using the wsbuild script.
24 #
25 # WS_HOME =
26 WS_HOME = 
27
28 # Installation directory for the (compiled) Wireshark plugins
29 #    Change the value of the following macro to the installation directory
30 #    of the Wireshark plugins for your installation 
31 #
32 #    Note: When using the cbuild script leave the macro undefined
33 #    (default: /usr/lib/wireshark/plugins/$(WS_VERSION))
34 #
35 #    For non-root and  non-rpmbuilds you might want to set the value to
36 #        ${HOME}/.wireshark/plugins
37 PLUGIN_DIR =
38
39 CFLAGS = -DINET6 -D_U_=__attribute__\(\(unused\)\) -Wall -Wpointer-arith -g \
40         -DXTHREADS -D_REENTRANT -DXUSE_MTSAFE_API -fPIC -DPIC
41
42 ifdef WS_HOME
43 #INCS = $(shell echo "-I${WS_HOME} `./wsconfig.sh --libs --cflags glib-2.0`")
44 INCS := $(shell echo "-I${WS_HOME} $(PLUGIN_COMPILE_FLAGS)") -DHAVE_CONFIG_H 
45
46 else
47 INCS := $(shell ./wsconfig.sh --libs --cflags wireshark) \
48         $(shell ./wsconfig.sh --libs --cflags glib-2.0) \
49         -I../../include \
50         $(shell echo "$(PLUGIN_COMPILE_FLAGS)") -DHAVE_CONFIG_H
51 WS_VERSION := $(shell ./wsconfig.sh --modversion wireshark)
52 LIBDIR := $(shell ./wsconfig.sh --variable=libdir wireshark)
53 CHECK=./wsconfig.sh --atleast-version=${MIN_WIRESHARK_VERSION} wireshark
54 endif
55
56 CFLAGS += $(INCS)
57
58 SRCS_LNET = packet-lnet.c
59 SRCS_LUSTRE = packet-lustre.c
60
61 CC   = gcc
62
63 OBJS_LNET := $(foreach src, $(SRCS_LNET), $(src:.c=.o))
64 OBJS_LUSTRE := $(foreach src, $(SRCS_LUSTRE), $(src:.c=.o))
65
66 PLUGINS=lnet.so lustre.so
67
68 ifeq (${CHECK},)
69        CHECK=true
70 endif
71
72 ifneq ($(shell id -u), 0)
73   ifndef DESTDIR
74     PLUGIN_DIR = ${HOME}/.wireshark/plugins
75   endif
76 endif
77
78 ifndef PLUGIN_DIR
79   ifndef WS_VERSION
80     ifndef WS_HOME
81       $(error "WS_HOME not defined")
82     endif
83     WS_CONFIG=$(WS_HOME)/config.h
84     WS_VERSION:=$(shell sed "s/^.define[[:space:]]*VERSION[[:space:]]*\"\(.*\)\"/\1/p;d" ${WS_CONFIG})
85   endif
86   ifeq (${LIBDIR},)
87     ifeq ($(shell if [ -r /etc/SuSE-release ] ; then echo 0; else echo 1; fi ), 0)
88       LIBDIR=/usr/lib64
89     else
90       LIBDIR=/usr/lib
91     endif
92   endif
93   PLUGIN_DIR = $(DESTDIR)$(LIBDIR)/wireshark/plugins/$(WS_VERSION)
94 endif
95
96
97 all: check $(PLUGINS) lustre_dlm_flags_wshark.c
98
99 lustre_dlm_flags_wshark.c :
100         cd ../../../contrib/bit-masks ; \
101         make
102         test -f lustre_dlm_flags_wshark.c
103
104 check:
105         @if ! ${CHECK}; then\
106                 echo "Wireshark must be at least version ${MIN_WIRESHARK_VERSION} (installed ${WS_VERSION})";\
107                 false; \
108         fi
109
110 lustre.so: $(OBJS_LUSTRE)
111         $(CC) -shared $(OBJS_LUSTRE) -o $@
112
113 lnet.so: $(OBJS_LNET)
114         $(CC) -shared $(OBJS_LNET) -o $@
115
116 install: all
117         mkdir -p $(PLUGIN_DIR)
118         install $(PLUGINS) $(PLUGIN_DIR)/
119
120 help:
121         @echo "Includes:    "$(INCS)
122         @echo "Install Dir: "$(PLUGIN_DIR)
123
124 clean:
125         rm -f $(PLUGINS) $(OBJS_LNET) $(OBJS_LUSTRE)
126
127 extraclean: clean
128         (cd $(PLUGIN_DIR)/; rm -f $(PLUGINS))
129
130 .PHONEY: check help install extraclean clean all