Add version check in Geneve dissector.
[metze/wireshark/wip.git] / aclocal-flags
1 #!/bin/sh
2 #
3 # This script returns the flags to be fed to "aclocal" to ensure that
4 # it finds GLib's aclocal macros (we assume GTK+ is installed in the
5 # same place as GLib) and pkg-config's aclocal macros.
6 #
7 # aclocal will search, by default, only in a directory in the same
8 # tree where it was installed - e.g., if installed in "/usr/bin", it'll
9 # search only in "/usr/share/aclocal", and if installed in "/usr/local/bin",
10 # it'll search only in "/usr/local/share/aclocal".
11 #
12 # However, there is no guarantee that GLib, or pkg-config has been installed
13 # there; if either of them hasn't been installed there, aclocal won't find
14 # the autoconf macros for whichever of them wan't, and will complain
15 # bitterly.
16 #
17 # So:
18 #
19 #       if pkg-config is found with a path that ends with "bin/pkg-config",
20 #       and the "share/local" directory under the directory at the path
21 #       that's the part of the pkg-config path preceding "bin/pkg-config"
22 #       isn't the same directory as the directory reported by "aclocal
23 #       --print-ac-dir", we include in our output a "-I" flag with that
24 #       directory as its argument;
25 #
26 #       if the "share/local" directory under the directory reported by
27 #       "pkg-config --variable=prefix glib-2.0" isn't the same directory
28 #       as the directory reported by "aclocal --print-ac-dir", we include
29 #       in our output a "-I" flag with the first of those directories as
30 #       the argument.
31 #
32 # If either of them *is* the same directory as the directory reported by
33 # "aclocal --print-ac-dir", and we supply that "-I" flag, "aclocal" will
34 # look in that directory twice, and get well and truly confused, reporting
35 # a ton of duplicate macro definitions.  This also means that if pkg-config
36 # and Glib are installed with the same prefix, we should only supply one
37 # "-I" flag for both of them.
38 #
39
40 #
41 # OK, where will aclocal look by default?
42 #
43 aclocal_dir=`aclocal --print-ac-dir`
44
45 #
46 # And where do we want to make sure it looks?
47 # Look for pkg-config first.
48 #
49 pkg_config_path=`command -v pkg-config 2>/dev/null`
50 if [ -z "$pkg_config_path" ]
51 then
52         #
53         # Either we don't have "command" (which is required by recent
54         # POSIX) or it didn't find pkg-config.
55         #
56         pkg_config_aclocal_dir=""
57 else
58         #
59         # OK, we found pkg-config; attempt to find the prefix for it, by
60         # stripping off "bin/pkg-config".
61         #
62         pkg_config_prefix=`expr "$pkg_config_path" : '\(.*\)/bin/pkg-config'`
63         if [ -z "$pkg_config_prefix" ]
64         then
65                 #
66                 # Well, we couldn't strip it off, for whatever reason.
67                 #
68                 pkg_config_aclocal_dir=""
69         else
70                 #
71                 # Solaris 11's default pkg-config installation puts
72                 # it in /usr/ccs/bin, but there's no /usr/ccs/share.
73                 # Map /usr/ccs to /usr.
74                 #
75                 # Ubuntu 7.10 has /usr/X11R6/bin as a symbolic link
76                 # to /usr/bin, but there's no /usr/X11R6/share.  If
77                 # /usr/X11R6/bin is a symlink to /usr/bin, map
78                 # /usr/X11R6 to /usr.
79                 #
80                 if [ "$pkg_config_prefix" = /usr/ccs ]
81                 then
82                         pkg_config_prefix=/usr
83                 elif [ "$pkg_config_prefix" = /usr/X11R6 ]
84                 then
85                         if expr "`ls -ld /usr/X11R6/bin`" : '.*/usr/X11R6/bin -> .*/bin$' >/dev/null
86                         then
87                                 pkg_config_prefix=/usr
88                         fi
89                 fi
90
91                 #
92                 # Now get the path of its aclocal directory.
93                 #
94                 pkg_config_aclocal_dir=$pkg_config_prefix/share/aclocal
95         fi
96 fi
97
98 #
99 # Now see where glib is installed.
100 #
101 glib_prefix=`pkg-config --variable=prefix glib-2.0 2>/dev/null`
102
103 #
104 # Now get the path of its aclocal directory.
105 #
106 if [ -z "$glib_prefix" ]
107 then
108         glib_aclocal_dir=""
109 else
110         glib_aclocal_dir=$glib_prefix/share/aclocal
111 fi
112
113 #
114 # Add our aclocal-fallback to the path.
115 # We write out the -I flag for it, and strip off CR and LF, as we may
116 # be writing more -I options, and we want all the options to be on
117 # one line.
118 #
119 ac_missing_dir=`dirname $0`
120 echo "-I $ac_missing_dir/aclocal-fallback" | tr -d '\012' | tr -d '\015'
121
122 #
123 # If there's no aclocal, aclocal_dir, which is the path where aclocal
124 # searches, will be empty; if we didn't find pkg-config,
125 # pkg_config_aclocal_dir, which is the path where it should search
126 # for pkg-config's macros, will be empty.  Add pkg_config_aclocal_dir only
127 # if both it and aclocal_dir are non-empty and different from each other.
128 #
129 if [ ! -z "$aclocal_dir" -a ! -z "$pkg_config_aclocal_dir" \
130     -a "$aclocal_dir" != "$pkg_config_aclocal_dir" ]
131 then
132         echo " -I $pkg_config_aclocal_dir" | tr -d '\012' | tr -d '\015'
133 fi
134
135 #
136 # If pkg-config doesn't know about glib-2.0, glib_aclocal_dir will be
137 # empty.  (Should we just fail in that case?  Does that mean we don't
138 # have GLib installed?)
139 #
140 # Add glib_aclocal_dir only if both it and aclocal_dir are non-empty and
141 # different from each other *and* pkg_config_aclocal_dir is different from
142 # glib_aclocal_dir.  (We don't need to check whether pkg_config_aclocal_dir
143 # is empty; if it is, then either glib_aclocal_dir is also empty, in which
144 # case we'll bail out before even looking at pkg_config_aclocal_dir, or
145 # it's non-empty, in which case it obviously won't be equal to
146 # pkg_config_aclocal_dir.)
147 #
148 if [ ! -z "$aclocal_dir" -a ! -z "$glib_aclocal_dir" \
149     -a "$aclocal_dir" != "$glib_aclocal_dir" \
150     -a "$pkg_config_aclocal_dir" != "$glib_aclocal_dir" ]
151 then
152         echo " -I $glib_aclocal_dir" | tr -d '\012' | tr -d '\015'
153 fi
154
155 #
156 # Put out the final line ending.
157 #
158 echo
159 exit 0