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