Whamcloud - gitweb
LU-2906 ldlm: use accessor macros for l_flags
[fs/lustre-release.git] / lustre / contrib / wireshark / wsconfig.sh
1 # This file contain all configuration information to build
2 # `lustre-release/lustre/contrib/wireshark'
3
4 [[ $1 =~ --.* ]] || {
5     ###########################################################################
6     #                                                                         #
7     #    DOWNLOAD CONFIGURATION
8     #                                                                         #
9     ###########################################################################
10
11     ##   BEGIN: -can-edit   ##
12     # URL of directory containing all source tar balls
13     export WS_DOWNLOAD_BASE_URL='http://wiresharkdownloads.riverbed.com'
14     WS_DOWNLOAD_BASE_URL+='/wireshark/src/all-versions'
15
16     # wireshark verion to be used
17     export WS_VERSION='1.6.8'
18     ##   END  : -can-edit   ##
19
20     # URL of the wireshark source code tarball
21     # Implicit assumption: Wireshark release names follow the nameing
22     # convention coded in the content of the following varialble
23     export WS_SOURCE_URL="${WS_DOWNLOAD_BASE_URL}/wireshark-${WS_VERSION}.tar.bz2"
24
25
26     ###########################################################################
27     #                                                                         #
28     #                   BUILD ENVIRONMENT                                     #
29     #                                                                         #
30     ###########################################################################
31
32     ##   BEGIN: -can-edit   ##
33     # Space separate list of RPMs needed to be installed for 
34     # compilation of wireshark
35
36     # Package name(s) (can) vary between differnt distributions
37     # If distributions 'marked' by same release file, content has to
38     # parsed and variable PREREQUISITE_RPMS has to be set accoringly to
39     # package name(s) used for each distro.
40     if [ -r /etc/redhat-release ] ; then
41         export PREREQUISITE_RPMS='gtk2 gtk2-devel glib2 libpcap libpcap-devel perl'
42     elif [ -r /etc/SuSE-release ] ; then
43         export PREREQUISITE_RPMS='gtk2 gtk2-devel glib2 libpcap0 libpcap-devel perl'
44     fi
45
46     # Include and linker flags needed to Lustre/LNet
47     # Only version indepent information should be added here
48     # (Back ticked expression will be evaluated by make command)
49     export PLUGIN_COMPILE_FLAGS='`pkg-config --libs --cflags glib-2.0`'
50     ##   END  : -can-edit   ##
51
52     # Top-level directory to be used to unpack/compile/install
53     # wireshark/lustre-git-repo
54     export BUILD_DIR=`pwd`
55
56     # Directory location of wireshark source code
57     export WS_HOME="${BUILD_DIR}/wireshark-${WS_VERSION}"
58
59     # (Relative) path of the wireshark contribution directory
60     export LUSTRE_WS_DIR='lustre-release/lustre/contrib/wireshark'
61
62     # RPM internal name for the Lustre/LNet plugins
63     export PLUGIN_RPM_NAME='lustre-wireshark-plugins'
64
65     # TAR command + options to be used to create a bzip2 tarball
66     export TAR='/bin/tar jcpf '
67     # TAR command + options to be used to unpack a bzip2 tarball
68     export UNTAR='/bin/tar jxpf '
69     exit 0
70 }
71
72 die() {
73     echo "wsconfig error:  $*"
74     exit 1
75 } 1>&2
76
77 # arg1: complete package name, with version
78 # arg2: the minimum version
79 #
80 chk_ver() {
81     act_ver=${1#*-devel-} ; shift
82     act_ver=${act_ver%%-*}
83
84     declare low_ver=$(
85         printf "${act_ver}\n$1\n" | sort -V | head -n1 )
86     test "X$low_ver" = "X$1" || \
87         die "wireshark too old: $act_ver is before $1"
88 }
89
90 set_var() {
91     case "X$2" in
92     Xlibdir )
93         txt=$(echo $(rpm -q --list $1 | \
94             sed -n '\@/libwire@s@/libwire[^/]*$@@p' | \
95             sort -u) )
96         ;;
97     * )
98         die "unknown variable: $2"
99         ;;
100     esac
101 }
102
103 set_cflags() {
104     dlst=$(rpm -q --list $pkg | \
105         grep '/usr.*/include.*/wireshark$' | \
106         while read f ; do test -d $f && echo "$f" ; done)
107     rm -f config.h
108     for f in $dlst XX
109     do test -f $f/config.h && ln -s ${f}/config.h .
110         txt+=" -I$f"
111     done
112     test -f config.h || die "cannot find config header"
113 }
114
115 parse_wireshark() {
116     declare pkg=$(rpm -qa | sed -n '/wireshark-devel/{;p;q;}')
117     declare dlst=
118
119     while test $# -gt 1
120     do
121         txt=
122         case "$1" in
123         --libs )
124             txt=$(rpm -q --list $pkg | \
125                 sed -n 's@\.so$@@p' | \
126                 sed 's@.*/lib@-l@')
127             ;;
128
129         --cflags )
130             set_cflags
131             ;;
132
133         --modversion )
134             txt=${pkg#wireshark-devel-}
135             txt=${txt%%-*}
136             ;;
137
138         --atleast-version=* )
139             chk_ver ${pkg} ${1#*=}
140             ;;
141
142         --atleast-version )
143             shift
144             chk_ver ${pkg} ${1}
145             ;;
146
147         --variable=* )
148             set_var ${pkg} ${1#*=}
149             ;;
150
151         --variable )
152             shift
153             set_var ${pkg} ${1}
154             ;;
155
156         * )
157             die "unknown option: $1"
158             ;;
159         esac
160         test ${#txt} -gt 0 && \
161             printf "%s" "$(echo ' '$txt)"
162         shift
163     done
164     echo
165 }
166
167 pkg-config "$@" 2>/dev/null && exit 0
168
169 pkg=$#
170 case ${!pkg} in
171 glib* )
172     fullpkg=$(rpm -qa | grep -E '^glib[2-9].*-devel' | head -n1)
173     dirs=$(rpm -q --list $fullpkg | \
174         while read f ; do test -d $f && echo $f ; done | \
175         grep -F /include)
176     for f in $dirs ; do printf "-I$f " ; done
177     rpm -q --list $fullpkg | \
178         sed -n 's@^.*/libglib@-lglib@p' | \
179         sed -n 's/\.so$//p' | \
180         head -n 1
181     ;;
182
183 wireshark )
184     parse_wireshark "$@"
185     ;;
186
187 * )
188     echo huh?
189     exit 1
190     ;;
191 esac