blob: 2d47c8e8edd1df234666d700bc905e4e6a045b69 (
plain)
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
|
#!/bin/sh
# All variables are prefixed with pc_ so that there is low likelyhood of
# conflicts with the .pc files.
IFS=":$IFS"
prefix=@prefix@
exec_prefix=@exec_prefix@
pc_default_path=@libexecdir@/pkgconfig
if [ ! -d ${pc_default_path} ]; then
echo "${pc_default_path} doesn't exist. Make sure you've installed pkgconfig correctly."
exit 1;
fi
if [ ! -f "${pc_default_path}/gnomeconfig.pce" ]; then
echo "Can't find gnomeconfig.pce. Make sure you've installed pkgconfig correctly."
exit 1;
fi
cleanup() {
pc_prepend=$1
shift
pc_keep=$1
shift
pc_cleanup_var=$1
shift
pc_temp=""
while [ $# -ne 0 ]; do
pc_var=$1 # iterate over $1 ...
shift
if test "x$pc_keep" = "xkeepfirst"; then
case " $pc_temp " in
*\ $pc_var\ *) ;;
*) if test "x$pc_prepend" = "xprepend"; then
pc_temp="$pc_var $pc_temp"
else
pc_temp="$pc_temp $pc_var"
fi
;;
esac
else
# use : as seperator because that's what we prepended to IFS
case ":$*:" in
*\:$pc_var\:*) ;;
*) if test "x$pc_prepend" = "xprepend"; then
pc_temp="$pc_var $pc_temp"
else
pc_temp="$pc_temp $pc_var"
fi
;;
esac
fi
done
eval $pc_cleanup_var='$pc_temp'
}
find_configfile() {
for pc_dir in $pc_path XXX; do
if [ -f "${pc_dir}/${pc_pkg}.pc" ]; then
. ${pc_dir}/${pc_pkg}.pc
break
fi
done
if [ "$pc_dir" = XXX ]; then
pc_extns=`ls ${pc_default_path}/*.pce`
for pc_ext in $pc_extns XXX; do
if [ -f "${pc_ext}" ]; then
. ${pc_ext} $pc_pkg
# sh on Tru64 (OSF1??) doesn't like return in sourced
# files, so we set $result
if [ "$result" = "0" ]; then
break;
fi
fi
done
if [ "$pc_ext" = XXX ]; then
echo "couldn't find information for package $pc_pkg." 1>&2
exit 1
fi
fi
}
# make sure we give a non-zero return value if we get interrupted
# signals HUP, INT and TERM
trap 'echo; echo "Interrupted."; exit 1' 1 2 15
pc_help_msg="Usage: $0 [-I DIR] [GENERIC_OPTION | FLAGSOPTION...] [LIBRARY...]
-I DIR Add a directory to the .pc file search path
Generic options:
--version Output the pkg-config version and exit
--modversion Output the version of the first library and exit
--help Show this help and exit
--expand Show expanded list of packages to link with
--print-pc-dir Print the default .pc search dir and exit
--extra-flags Print the extra flags the selected modules support
--get-flag FLAGNAME Print the content of the extra flag specified
Output link information for a combination of libraries
Options to control which compile/link flags to output
--cflags Show cflags to compile with
--libs-only-L Output only -L/-R flags needed for the libraries listed
--libs-onlu-l-self Output the -l flags for the libraries listed
--libs-only-l-system Output the -l flags for system libraries the
listed libraries depend on.
--libs Output a combination of all the --libs-only-* flags above
LIBRARIES Packages that your program needs to compile
"
pc_want_ldflags=no
pc_want_libs_self=no
pc_want_libs_system=no
pc_want_cflags=no
pc_want_libs=no
pc_want_expand=no
pc_want_dir=no
pc_want_varlist=no
pc_want_extra_var=no
pc_prev=
pc_extra_var=
# show help and exit with an errorstatus when no arguments
if test $# -eq 0; then
echo "$pc_help_msg"
exit 1
fi
# add extra path to searched dirs
pc_path=
if [ -n "$PC_INCLUDEPATH" ]; then
pc_path="${PC_INCLUDEPATH}:${pc_path}"
fi
for pc_extra in `echo $GNOME_PATH | sed 's/:/ /g'`; do
pc_path="${extra}/libexec/pkgconfig:${pc_path}"
done
# only use default path if no other paths are given, to
# avoid ACLOCAL_CONFIG type problems
if [ -z "${GNOME_PATH}${PC_INCLUDEPATH}" ]; then
pc_path="${pc_default_path}"
fi
while [ $# -ne 0 ]; do
pc_arg="$1"
shift
case "$pc_arg" in
-*=*) pc_optarg=`echo $pc_arg | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) pc_optarg= ;;
esac
if [ -n "$pc_prev" ]; then
if [ "$pc_prev" = pcpath ]; then
pc_path="$pc_arg:$pc_path"
elif [ "$pc_prev" = "extravar" ]; then
pc_extra_var="$pc_arg"
else
eval "$pc_prev=\$pc_arg"
fi
pc_prev=
continue
fi
case "$pc_arg" in
--help)
echo "$pc_help_msg"
exit 0 ;;
--version)
echo "pkgconfig @VERSION@"
exit 0 ;;
-I*) pc_path="`echo $pc_arg | sed 's/^-I//'`:$pc_path" ;;
-I) pc_prev=pcpath ;;
--cflags) pc_want_cflags=yes ;;
--libs-only-L) pc_want_ldflags=yes ;;
--libs-only-l-self) pc_want_libs_self=yes ;;
--libs-only-l-system) pc_want_libs_system=yes ;;
--libs)
pc_want_ldflags=yes
pc_want_libs_self=yes
pc_want_libs_system=yes ;;
--expand) pc_want_expand=yes ;;
--modversion) pc_want_modversion=yes ;;
--print-pc-dir) pc_want_dir=yes ;;
--extra-flags) pc_want_varlist=yes ;;
--get-flag) pc_prev="extravar" pc_want_var=yes ;;
-*)
echo "Unknown option: $pc_arg"
echo "$pc_help_msg"
exit 1 ;;
*) pc_caps="$pc_caps $pc_arg" ;;
esac
done
# print the default pc_path only
if [ "$pc_want_dir" = yes ]; then
echo $pc_default_path
exit 0
fi
# expand the packages list, so to satisfy dependencies ...
set - $pc_caps
pc_pkgs=""
while [ $# -ne 0 ]; do
pc_pkg="$1"
shift
if [ -z "$pc_pkg" ]; then
# ash seems to count the space at the start of pc_caps as an extra
# argument. This catches that case.
continue
fi
pc_pkgs="$pc_pkgs $pc_pkg"
REQUIRES=""
find_configfile $pc_pkg
if [ "x$REQUIRES" != x ]; then
for pc_dep in $REQUIRES; do
case ":$*:" in
*\:$pc_dep\:*) ;;
*) set - $* $pc_dep;;
esac
done
fi
done
# now remove duplicate packages from the list (all but last duplicate) ...
cleanup prepend keepfirst pc_pkgs $pc_pkgs
#
# from this point on, the list of packages should all exist, and be ordered
#
# give the module version
if [ "$pc_want_modversion" = yes ]; then
echo $VERSION
exit 0
fi
# list the expanded list of packages if asked for ...
if [ "$pc_want_expand" = yes ]; then
echo $pc_pkgs
exit 0;
fi
# list the list of extra vars
if [ "$pc_want_varlist" = yes ]; then
cleanup prepend keepfirst pc_varlist $EXTRA_VARS
echo $pc_varlist
exit 0;
fi
if [ "$pc_want_var" = yes ]; then
eval echo \$`eval echo $pc_extra_var`
exit 0;
fi
#ignore what the previous runs of the scripts have set
CFLAGS=
LIBS_PATH=
LIBS_LINK_SELF=
LIBS_LINK_SYSTEM=
for pc_pkg in $pc_pkgs; do
find_configfile $pc_pkg
done
# clean up duplicate flags. Discard all but last occurence of -l* flags,
# and all but first occurence of other flags
if [ "$pc_want_cflags" = "yes" ]; then
pc_includepath=
for pc_flag in $CFLAGS; do
if [ "$pc_flag" != "-I/usr/include" ]; then
pc_includepath="$pc_includepath $pc_flag"
fi
done
cleanup append keepfirst CFLAGS $pc_includepath
echo -n $CFLAGS
fi
if [ "$pc_want_ldflags" = "yes" ]; then
pc_libpath=
for pc_flag in $LIBS_PATH; do
if [ "$pc_flag" != "-L/usr/lib" ]; then
pc_libpath="$pc_libpath $pc_flag"
fi
done
cleanup append keepfirst LIBS_PATH $pc_libpath
echo -n "$LIBS_PATH"
fi
if [ "$pc_want_libs_self" = "yes" ]; then
cleanup append keeplast LIBS_LINK_SELF $LIBS_LINK_SELF
echo -n "$LIBS_LINK_SELF"
fi
if [ "$pc_want_libs_system" = "yes" ];then
cleanup append keeplast LIBS_LINK_SYSTEM $LIBS_LINK_SYSTEM
echo -n "$LIBS_LINK_SYSTEM"
fi
#end the line
echo
#everything seems to have gone well
exit 0
|