]> git.saurik.com Git - wxWidgets.git/blame - wx-config.in
quite ugly workaround, but even the engineers at WWDC couldn't give me a better alter...
[wxWidgets.git] / wx-config.in
CommitLineData
9a98a854 1#!/bin/sh
ceec2216
RL
2#
3# Name: wx-config{.in,}
4# Purpose: wx configuration search and query tool {template,}
5# Author: Ron <ron@debian.org>
6# Modified by:
7# Created: 8/9/2004
8# RCS-ID: $Id$
9# Copyright: (c) 2004 Ron <ron@debian.org>
10# Essentially a fresh start this time around, but for maximum
11# compatibility basic code was taken from, and heavy reference
12# made to, the previously unattributed wx-config from cvs.
13# All the usual suspects contributed to the dicussion that led
14# to this new work and likewise to the ideas and content in the
15# original (which was probably influenced by gtk), among them:
16# Robert Roebling, Vadim Zeitlin, Vaclav Slavik, Robin Dunn
17# Licence: wxWindows licence
18############################################################################
19
6758d3d3 20# Extra^2 debug mode, for if things ever get really weird.
8ec45325
RL
21[ -z "$WXDEBUG_X" ] || set -x
22
68ca6f52
RL
23
24# On with some basic stuff, like the ability to die gracefully,
ceec2216
RL
25# and to tell people what we are about.
26# ------------------------------------------------------------------
27
28# decho _message
29# Output a message to stderr.
30decho() { echo "$*" 1>&2; }
31
32# usage _exitcode
33# Outputs a usage message to stderr and exits with _exitcode.
63f018eb
RL
34# Try to keep this to a single page (ie. < 25 lines). We can add
35# alternate or interactive help targets if people want more detail.
36#
37# Exit codes are now subject to a more strict interpretation.
38# wx-config should return 0 upon successful operation, 1 if the
39# reqested operation could not be completed successfully, and 2
40# if the requested operation is not supported by this version of
41# wx-config.
ceec2216
RL
42usage()
43{
44 cat 1>&2 <<EOF
45
46 wx-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--release] [--version-full]
16837dc3 47 [--list] [--selected-config] [--host=HOST] [--toolkit=TOOLKIT]
89b1afb4 48 [--universal[=yes|no]] [--unicode[=yes|no]] [--static[=yes|no]]
c06957da 49 [--debug[=yes|no]] [--version[=VERSION]] [--basename] [--cc] [--cxx]
89b1afb4 50 [--cppflags [base]] [--cxxflags [base]] [--cflags]
6bddfdbf 51 [--rescomp] [--linkdeps] [--ld] [--utility=UTIL]
bd630206 52 [--libs [LIBS...]] [--optional-libs [LIBS...]]
16837dc3
VZ
53
54 wx-config returns information about the wxWidgets libraries available on
55 your system. It may be used to retrieve the information required to build
6bddfdbf 56 applications using these libraries using --cppflags, --cxxflags, --cflags,
e5405b6b 57 and --libs options. And you may query the properties of this configuration
c06957da
VZ
58 using --query-{host,toolkit,widgetset,chartype,debugtype,version,linkage}.
59
60 NOTE: Usage of --debug and --query-debugtype are only relevant if you
61 have any versions prior to 2.9 installed and use the --version option to
62 select an earlier version.
16837dc3
VZ
63
64 If multiple builds of wxWidgets are available, you can use the options
89b1afb4
VZ
65 --prefix, --host, --toolkit, --unicode, --static, --universal or --version
66 to select from them. The --selected-config option shows the name of the
67 current configuration and --list shows available alternatives which match
68 specified criteria. The --utility option returns the correct version of
69 UTIL to use with the selected build. The --linkdeps option returns only
16837dc3 70 static libraries for your makefile link rule dependencies.
ceec2216 71
bd630206
VZ
72 The LIBS arguments (comma or space separated) may be used to specify the
73 wxWidgets libraries that you wish to use. The "std" label may be used to
74 import all libraries that would be used by default if none were specified
75 explicitly, e.g. wx-config --libs core,base. The "all" label may be used
76 to import all libraries that have been compiled which are shown in the
77 list below. The --optional-libs parameter should be followed by a list
78 of libs that should be linked to, but only if they are available.
79
de0573da
FM
80 Available libraries in this build are:
81 @BUILT_WX_LIBS@
9a98a854 82
ceec2216 83EOF
33380099 84
ceec2216
RL
85 exit $1
86}
33380099 87
ceec2216
RL
88# Unfussy people are the easiest to deal with, get them out of the way now.
89[ $# -gt 0 ] || usage 1
33380099 90
33380099 91
8ec45325
RL
92# Contentious tools determined by configure.
93EGREP="@EGREP@"
94
cf615ebb 95
ceec2216
RL
96# For the people who know what they want, or think they do:
97# Divide the valid arguments into functional groups for later examination,
98# then parse all command line arguments completely, deferring action on
99# output options until all significant input has been processed and any
100# decision about delegation has been taken.
cf615ebb 101
ceec2216
RL
102# Note early, that '-' is a complete no-no for use in option names below.
103# It totally falls apart as soon as it becomes part of a variable name.
104# Use '_' instead, and by the magic of it all just being bits, you'll
105# be able to use --my-option or --my_option from the command line at
106# your discretion. They are synonymous as user input, but _ALWAYS_ use
107# underscores for compound names in the code here, never a dash.
108
109
110# The list of all options we recognise. If it is not in here, then
111# it is not something we want to handle.
112# ------------------------------------------------------------------
113
114# Options that specify a distinct library build.
115#
116# Note also that order in this list is significant later on, as this sets
117# the precedence with which we will try to gauge the similarity of other
118# configs to this one. Options earlier in the list should be more crucial
119# to match well than those that follow. Options specified by the user will
120# always take precedence and are not subject to any partial ordering here.
c06957da 121wxconfig_schema="host toolkit widgetset chartype debugtype flavour version linkage"
ceec2216
RL
122
123# Options that are expected to generate some output.
92ea30ce
RL
124wxconfig_output_options="prefix exec_prefix
125 list
126 release version version_full
127 basename
128 cppflags cflags cxxflags
370d2fd7 129 rescomp
891ace05 130 rezflags
92ea30ce 131 libs
bd630206 132 optional_libs
92ea30ce
RL
133 linkdeps
134 cc cxx ld
ceec2216
RL
135 gl_libs"
136
137# Options that permit the user to supply hints that may affect the output.
138# These options all accept arbitrary values, to interpret as they please.
63f018eb 139wxconfig_input_options="prefix exec_prefix utility $wxconfig_schema"
cf615ebb 140
ceec2216 141# Input options that accept only a yes or no argument.
89b1afb4
VZ
142#
143# Notice that this includes "debug" but it is done only for compatibility, this
144# options (i.e. --debug[=yes] or --debug=no) is completely ignored as there is
145# no distinction between debug and release builds in wx any more
ceec2216 146wxconfig_yesno_options="universal unicode debug static"
cf615ebb 147
ceec2216 148# Boolean options that do something or not.
6758d3d3 149wxconfig_flag_options="$wxconfig_yesno_options selected_config no_rpath inplace"
33380099 150
33380099 151
33380099 152
ceec2216
RL
153# Some simple sugar coating to keep things more readable below.
154# --------------------------------------------------------------
155
156# option_name _string
157# Returns NAME if _string is of the form: --NAME[=...]
158option_name()
159{
b2f55c8b 160 echo "$1" | sed 's/^--//;s/=.*//' | tr '-' '_'
ceec2216
RL
161}
162
163# option_value _string
164# Returns FOO if _string is of the form: --option=FOO
165option_value()
166{
b2f55c8b 167 echo "$1" | sed 's/^[^=]*=//'
ceec2216
RL
168}
169
170# match_field _value _list
171# Returns true if _value is a field in _list
172match_field()
173{
174 _match_field_match="$1"
175 shift
b2f55c8b 176 for _match_field_i do
ceec2216
RL
177 [ "x$_match_field_i" != "x$_match_field_match" ] || return 0
178 done
179 false
180}
181
182# remove_field _value _list
183# Returns _list minus any field(s) that match _value.
184remove_field()
cf615ebb 185{
ceec2216
RL
186 _remf_value="$1"
187 _remf_list=''
cf615ebb 188 shift
3950ea80 189 if [ -n "$_remf_value" ]; then
b2f55c8b 190 for _remf_item do
92ea30ce 191 [ "x$_remf_item" = "x$_remf_value" ] ||
3950ea80
RL
192 _remf_list="${_remf_list:+$_remf_list }$_remf_item"
193 done
194 echo "$_remf_list"
195 else
196 echo $*
197 fi
cf615ebb
VS
198}
199
ceec2216 200# validate_arg _domain _set _name _value
cf63f3d3 201# Boilerplate to validate an argument and initialise a pseudo-hash.
ceec2216
RL
202# This one is almost reduction into absurdity, and perhaps makes the
203# precise action of the argument parser below just a little more
204# obscure, but oh so neat and compact to use for multiple option
205# groups. It expands to replace repetitive clauses of the form:
206#
207# i="$(option_name $arg)"
208# if match_field "$i" $wxconfig_input_options; then
209# input_options="${input_options:+$input_options }$i"
210# eval "input_option_$i=$(option_value $arg)"
211# continue
212# fi
213#
214# with the one liners you see on the page below.
215validate_arg()
cf615ebb 216{
b2f55c8b 217 if match_field "$3" `eval echo \"\\\$$1_$2_options\"`; then
ceec2216
RL
218 eval "$2_options=\"\${$2_options:+\$$2_options }$3\""
219 eval "$2_option_$3=\"$4\""
220 return
67c13b6c 221 fi
ceec2216
RL
222 false
223}
224
225# check_yesno_option _ynoption _option _yesval _noval
226# This one might be made more generic and/or incorporated into
227# validate_arg above at some later stage, but right now we just
228# condition any specialist options into a generic one for later
229# handling. Once they are sanity checked there is no difference
230# in any case.
231check_yesno_option()
232{
92ea30ce
RL
233 eval "case \${yesno_option_$1-\${flag_option_$1-unset}} in
234 unset) ;;
235 y*|Y*) input_option_$2=\"$3\" ;;
236 n*|N*) input_option_$2=\"$4\" ;;
237 *)
238 decho
239 decho \" *** Error: Invalid request '--$1=\$yesno_option_$1'\"
240 decho \" Valid arguments for --$1 are: [ yes, no ]\"
241 decho
242 exit 1
243 ;;
ceec2216
RL
244 esac"
245}
67c13b6c 246
67c13b6c 247
b4f28d1e
RD
248MAC_FRAMEWORK=
249MAC_FRAMEWORK_PREFIX=
250
ceec2216
RL
251
252# Now we are ready to find out what the user wants from us.
253# --------------------------------------------------------------
254
255# With just a little more complexity here we could have shortest
256# unique string matching for options, but that is probably overkill
4c51a665 257# today, so let's just get the job done.
ceec2216
RL
258#
259# The important thing now then is that we simply read all input from
260# the user and don't try to act prematurely on partial information.
261# --help or an illegal argument are the only shortcuts out of here
262# at this point, otherwise, it's time to just shut up and listen for
263# a moment.
264
b2f55c8b 265for arg do
ceec2216
RL
266 case "$arg" in
267 --help|-h)
268 usage
269 ;;
270
271 --*=*)
b2f55c8b
MW
272 _name=`option_name $arg`
273 _value=`option_value $arg`
92ea30ce
RL
274 if validate_arg wxconfig input "$_name" "$_value" ||
275 validate_arg wxconfig yesno "$_name" "$_value"
ceec2216
RL
276 then
277 continue
cf615ebb 278 fi
ceec2216
RL
279 ;;
280
e5405b6b
VZ
281 --query-*)
282 _name=`echo $arg | sed 's/^--query-//'`
283 if match_field "$_name" $wxconfig_schema
284 then
285 query_options="${query_options:+$query_options }$_name"
286 continue
287 fi
288 ;;
289
ceec2216 290 --*)
b2f55c8b 291 _name=`option_name $arg`
92ea30ce
RL
292 if validate_arg wxconfig flag "$_name" yes ||
293 validate_arg wxconfig output "$_name" yes
ceec2216
RL
294 then
295 continue
fef23dd4 296 fi
ceec2216 297 ;;
cf615ebb 298
ceec2216 299 *)
bd630206 300 # We validate the parameters later ...
6bddfdbf 301
ccde7008 302 if [ "$_name" = "cxxflags" ] || [ "$_name" = "cppflags" ] || [ "$_name" = "cflags" ]; then
6bddfdbf
VZ
303 cxx_parameters="${cxx_parameters:+$cxx_parameters }$arg"
304 elif [ "$_name" = "libs" ]; then
bd630206 305 libs_parameters="${libs_parameters:+$libs_parameters }$arg"
6bddfdbf 306 elif [ "$_name" = "optional_libs" ]; then
bd630206
VZ
307 optional_libs_parameters="${optional_libs_parameters:+$optional_libs_parameters }$arg"
308 else
1342e47c
VZ
309 # normally anything here are unattached arguments and signify an
310 # error but for compatibility with the 2.8 wx-config and,
311 # especially, configure scripts generated using 2.8 wxwin.m4 and
312 # hence doing `wx-config --version base,std`, we ignore anything
313 # following this option, just as 2.8 version used to do
314 if [ "$_name" != "version" ]; then
315 input_parameters="${input_parameters:+$input_parameters }$arg"
316 fi
bd630206 317 fi
ceec2216
RL
318 continue
319 ;;
320 esac
321 decho " *** Error: Unrecognised option: '$arg'"
322 decho "Use wx-config --help for information on command line options."
63f018eb 323 exit 2
ceec2216
RL
324done
325
326# validate_arg only checks and decomposes form. Sanity check the yes/no
327# options now too and push their respective mask values into place.
328
329check_yesno_option universal widgetset univ
330check_yesno_option unicode chartype unicode ansi
e5405b6b 331check_yesno_option static linkage static
c06957da 332check_yesno_option debug debugtype debug release
ceec2216 333
ceec2216
RL
334# Dump everything we just read in debug mode.
335if [ -n "$WXDEBUG" ]; then
336
337 decho
bd630206
VZ
338 decho " input parameters = $input_parameters"
339 decho " libs parameters = $libs_parameters"
340 decho " optional-libs parameters = $optional_libs_parameters"
ceec2216
RL
341 decho " input options = $input_options"
342 for i in $input_options; do
b2f55c8b 343 decho " $i = `eval echo \"\\\$input_option_$i\"`"
ceec2216
RL
344 done
345 decho " yes/no options = $yesno_options"
346 for y in $yesno_options; do
b2f55c8b 347 decho " $y = `eval echo \"\\\$yesno_option_$y\"`"
ceec2216
RL
348 done
349 decho " flag options = $flag_options"
350 for f in $flag_options; do
b2f55c8b 351 decho " $f = `eval echo \"\\\$flag_option_$f\"`"
cf615ebb 352 done
ceec2216
RL
353 decho " output options = $output_options"
354 for o in $output_options; do
b2f55c8b 355 decho " $o = `eval echo \"\\\$output_option_$o\"`"
ceec2216 356 done
e5405b6b 357 decho " query options = $query_options"
ceec2216
RL
358
359fi
360
cf615ebb 361
ceec2216 362
4c51a665 363# Everything came in as a legal argument then, let's put some of
ceec2216
RL
364# the pieces together with a little self knowledge to see what
365# we should do next.
366# --------------------------------------------------------------
367
368# get_mask [ _hash ]
e5405b6b 369# Construct a config filename mask from a pseudo-hash of component variables.
ceec2216
RL
370# The optional argument is the prefix of the hash to use. If not specified
371# this will return a mask derived from the command line options that were used.
372get_mask()
373{
374 [ $# -gt 0 ] || set m
c06957da
VZ
375
376 case "$m_ourversion" in
377 2.9)
378 is29orlater=1
379 ;;
380 2.*)
381 # there is no 2.10 so currently everything else is <= 2.8
382 is29orlater=0
383 ;;
384 *)
385 # 3.x and later "is29orlater" too
386 is29orlater=1
387 ;;
388 esac
389
390 # use 2.8 or 2.9 version of the mask: the difference is the presence of
391 # debug type in pre-2.9
0df5d673 392 if [ $is29orlater = 1 ]; then
c06957da
VZ
393 eval echo "\${$1_host:+\$$1_host-}\${$1_toolkit}\${$1_widgetset}-\${$1_chartype}\${$1_linkage:+-\$$1_linkage}-\${$1_version}\${$1_flavour}"
394 else
395 eval echo "\${$1_host:+\$$1_host-}\${$1_toolkit}\${$1_widgetset}-\${$1_chartype}-\${$1_debugtype}\${$1_linkage:+-\$$1_linkage}-\${$1_version}\${$1_flavour}"
396 fi
cf615ebb 397}
9a98a854 398
d9809627
RL
399# Returns true if this script is for a cross compiled config.
400is_cross() { [ "x@cross_compiling@" = "xyes" ]; }
401
ceec2216
RL
402
403# Determine the base directories we require.
404prefix=${input_option_prefix-${this_prefix:-@prefix@}}
0506bbbf 405exec_prefix=${input_option_exec_prefix-${input_option_prefix-${this_exec_prefix:-@exec_prefix@}}}
ceec2216
RL
406wxconfdir="@libdir@/wx/config"
407
b2f55c8b 408installed_configs=`cd "$wxconfdir" 2> /dev/null && ls | grep -v "^inplace-"`
ceec2216 409
d9809627 410is_cross && target="@host_alias@"
ceec2216
RL
411
412# Define a pseudo-hash to contain the specification of this wx-config
413# instance and its associated library.
e5405b6b 414this_host="${target:+${target}}"
ceec2216
RL
415this_toolkit="@TOOLKIT_DIR@@TOOLKIT_VERSION@"
416this_widgetset="@WIDGET_SET@"
417this_chartype="@WX_CHARTYPE@"
c06957da 418this_debugtype="release"
ceec2216
RL
419this_flavour="@WX_FLAVOUR@"
420this_version="@WX_RELEASE@"
e5405b6b 421this_linkage=`[ "x@SHARED@" = "x1" ] || echo 'static'`
ceec2216 422
e5405b6b 423
ceec2216 424# Extract the user specification from the options parsed.
b2f55c8b 425m_host=${input_option_host:+"${input_option_host}-?"}
e5405b6b 426m_host=${m_host:-$this_host}
b2f55c8b
MW
427m_toolkit=${input_option_toolkit:-'[^-]+'}
428m_widgetset=${input_option_widgetset-'(univ)?'}
429m_chartype=${input_option_chartype:-'(unicode|ansi)'}
c06957da 430m_debugtype=${input_option_debugtype:-'(debug|release)'}
ceec2216 431m_flavour=${input_option_flavour:+-$input_option_flavour}
b2f55c8b
MW
432m_flavour=${m_flavour:-${input_option_flavour-'(-[^-]+)?'}}
433m_version=${input_option_version:-'[0-9]+\.[0-9]+'}
e5405b6b 434m_linkage=${input_option_linkage-'?(static)?'}
ceec2216 435
c06957da
VZ
436# Test whether or not --version has been specified
437#
438# This must be done after getting the input options so get_mask works correctly
439# since it is version-dependent
440
441if [ -z "$input_option_version" ]; then
442 m_ourversion="2.9"
443else
444 m_ourversion=$m_version
445fi
446
447this_config=`get_mask this`
448
b2f55c8b 449configmask="^`get_mask`$"
ceec2216
RL
450
451
452# Dump the user specification in debug mode.
453if [ -n "$WXDEBUG" ]; then
454
455 decho
456 decho " prefix = '$prefix'"
457 decho " exec_prefix = '$exec_prefix'"
458 decho " wxconfdir = '$wxconfdir'"
459
460 decho " m_host = '$m_host'"
461 decho " m_toolkit = '$m_toolkit'"
462 decho " m_widgetset = '$m_widgetset'"
463 decho " m_chartype = '$m_chartype'"
c06957da 464 decho " m_debugtype = '$m_debugtype'"
ceec2216
RL
465 decho " m_flavour = '$m_flavour'"
466 decho " m_version = '$m_version'"
467 decho " m_linkage = '$m_linkage'"
468
469 decho " configmask = '$configmask'"
470 decho " this config = '$this_config'"
471 decho
472
473fi
474
475
476
9a09819a
RL
477# From here on, we'll need to be able to figure out a delegation target.
478# -----------------------------------------------------------------------
ceec2216
RL
479
480# The rules for delegation are:
481#
482# 1. If the specification is so general that it matches the default config
483# (ie. this one on a first pass), then the default config will be used
484# even if other installed libs would also match the spec.
485#
486# 2. If the default config does not match, find a list of all installed
487# libraries that do match.
488# a. If that list is empty, the specification is incompatible
489# with any installed lib. Warn and abort.
490# b. If that list contains exactly one candidate. Delegate to
491# that candidate.
492# c. If the list contains multiple candidates, pass on to step 3.
493#
494# 3. Attempt to discriminate among rival candidates by their similarity
495# to the default configuration (ie. this one). If we can find a unique
496# candidate in this way, delegate to it. If not, present a list of
497# options to the user and request that they disambiguate it with one or
498# more additional fields.
499#
500# To refine the specified pattern, we specialise each unbound field
501# using the default value from this config file. If that results in
502# no matches, we unbind it again and try the next field. If it still
503# results in multiple matches we try binding the next field as well
504# until a unique or null result again occurs.
505#
506# A more general way to look at this, is the feature specifiers are all
507# modifiers of the wx-config you are calling. If you supply none, the
508# default for that build configuration will be used. If you supply one
509# or more that the default build cannot satisfy, it will try to find the
510# config most like itself with the desired feature(s) enabled.
511# The features configured into the first wx-config called will be taken
512# as implicitly specified if it is necessary to disambiguate likely
513# candidates from the information that was explicitly provided.
514
515
516# But first, more sugar to keep what follows clear and legible.
517# --------------------------------------------------------------
518
9a09819a
RL
519# find_eligible_delegates _mask
520# Outputs all the config files installed which match the
521# (extended regex) _mask passed as an argument.
8ec45325 522find_eligible_delegates() { echo "$installed_configs" | $EGREP "$1" 2> /dev/null; }
9a09819a
RL
523
524# user_mask_fits _config
525# Returns true if the string _config satisfies the user specified mask.
8ec45325 526user_mask_fits() { echo "$1" | $EGREP "$configmask" > /dev/null 2>&1; }
9a09819a 527
ceec2216
RL
528# count_fields _word
529# Returns the number of IFS split fields in _word
530count_fields() { return $#; }
531
532# count_delegates _mask
533# Return the number of eligible config files that match _mask
b2f55c8b 534count_delegates() { count_fields `find_eligible_delegates $1`; }
ceec2216
RL
535
536# is_set _variablename
537# Returns true if $_variablename is initialised.
b2f55c8b
MW
538is_set() { [ "x`eval echo \"\\\${$1-unset}\"`" != "xunset" ]; }
539
540# not _cmd _args...
541# true iff _cmd is false
ac2e7107 542not() { if "$@"; then false; else true; fi; }
ceec2216
RL
543
544# do_find_best_delegate _unbound-options
545# The real worker part of find_best_delegate below. Recurses though all
546# unbound options binding them one at a time to the default derived from
547# this file until a unique match is made or no alternatives remain that
548# may be sensibly guessed at. It will preferentially bind the unspecified
549# options in the order they are listed in wxconfig_schema. Using this
550# partial ordering it should find the first match with the most significant
551# similarity to this file that unambiguously meets the user specification.
552# If such a match exists it will be output to stdout.
553#
554# Be careful if you modify this function. If the pruning logic is rendered
555# inoperative it will simply recurse over every permutation in the search
556# space, which may still appear to work, but add a couple more options (or
557# explicitly specify a few less) and you may not live long enough to learn
558# the result. WXDEBUG=findprogress is your friend here, it will show you
559# how many nodes get searched before a result. If you start seeing
560# increases in that number for the same input, check your work.
561# Raising the number of discriminating options from 6 to 8 raised the worst
562# case time for this to run (without pruning) from 3 to nearly 15 seconds
563# and its downhill fast from here if we have to ride that boat.
564# Early pruning still gets that down to under half a second (up from about
565# .25), so we have some breathing space yet before a different search method
4c51a665 566# will be called for, but let's not squander it.
ceec2216 567do_find_best_delegate()
ffef10f6 568{
ceec2216
RL
569 (
570 if [ "x$WXDEBUG" = "xverbose" ]; then
571 _fbd_indent="${_fbd_indent}. "
572 decho " $_fbd_indent---> unbound options: $*"
573 fi
574
b2f55c8b 575 for i do
ceec2216
RL
576
577 if [ "x$WXDEBUG" = "xverbose" ]; then
b2f55c8b 578 decho " ${_fbd_indent}binding '$i' with '`remove_field $i $*`' still free"
ceec2216
RL
579 [ -z "$_pruned" ] || decho " ${_fbd_indent} --- pruned: $_pruned ---"
580 fi
581
582 if (
583 eval m_$i=\$this_$i
b2f55c8b 584 _mask="^`get_mask`$"
ceec2216
RL
585
586 if [ "x$WXDEBUG" = "xverbose" ]; then
587 decho " ${_fbd_indent} checking: $_mask"
588 count_delegates "$_mask"
589 decho " $_fbd_indent $? eligible delegates"
b2f55c8b 590 for d in `find_eligible_delegates "$_mask"`; do
ceec2216
RL
591 decho " ${_fbd_indent} $d"
592 done
bd630206 593 fi
ceec2216
RL
594
595 count_delegates "$_mask"
596 _still_eligible=$?
597
598 if [ $_still_eligible -eq 1 ]; then
b2f55c8b 599 echo `find_eligible_delegates "$_mask"`
ceec2216
RL
600 return
601 fi
602
603 [ "x$WXDEBUG" != "xfindprogress" ] || printf "." 1>&2
604
92ea30ce 605 [ $_still_eligible -gt 1 ] && [ $# -gt 1 ] &&
b2f55c8b 606 do_find_best_delegate `remove_field $i $*`
92ea30ce 607 )
ceec2216
RL
608 then
609
610 return
611
612 elif [ $# -gt 1 ]; then
613
614 if [ "x$WXDEBUG" = "xverbose" ]; then
615 decho " ${_fbd_indent}pruning: $i"
616 _pruned="${_pruned:+$_pruned }$i"
617 fi
b2f55c8b 618 set `remove_field $i $*`
ceec2216 619
ffef10f6 620 fi
ceec2216 621
ffef10f6 622 done
ceec2216
RL
623 false
624 )
ffef10f6
VS
625}
626
ceec2216
RL
627# find_best_delegate
628# A simple wrapper around do_find_best_delegate that first determines
629# the unbound options (ie. the ones that the user did not explicitly
630# declare a preference for on the command line)
631find_best_delegate()
75f4be8a 632{
ceec2216 633 for _fbdi in $wxconfig_schema; do
92ea30ce 634 is_set input_option_$_fbdi ||
ceec2216
RL
635 _unbound_options="${_unbound_options:+$_unbound_options }$_fbdi"
636 done
637 do_find_best_delegate $_unbound_options
638}
8708fa76 639
75f4be8a 640
a13a7f89
RL
641# Legacy wx-config helpers.
642# -------------------------
643
644# get_legacy_mask
645# Returns a mask in the format used by wx2.4.
646get_legacy_mask()
647{
648 [ $# -gt 0 ] || set m
649 eval [ "x\${$1_chartype}" != "xunicode" ] || _unicode_flag=u
89b1afb4 650 eval echo "wx\${$1_toolkit}${_unicode_flag}-\${$1_version}\${$1_host}-config"
a13a7f89
RL
651}
652
653# find_legacy_configs
654# Returns a list of configs installed by wx2.4 releases.
655find_legacy_configs()
656{
92ea30ce
RL
657 (
658 cd "$prefix/bin" &&
659 {
660 ls wx*-2.4-config | grep -v ^wxbase
661 ls wx*-2.4-config | grep ^wxbase
662 }
663 ) 2> /dev/null
a13a7f89
RL
664}
665
666# find_best_legacy_config
667# Returns the best legacy config for a given specification.
668# This assumes no matching new style config has been found.
669find_best_legacy_config()
670{
b2f55c8b 671 _legacy_configs=`find_legacy_configs`
a13a7f89 672 if [ -n "$_legacy_configs" ]; then
b2f55c8b 673 _legacy_mask=`get_legacy_mask`
a13a7f89 674 for d in $_legacy_configs; do
8ec45325 675 if echo $d | $EGREP $_legacy_mask > /dev/null 2>&1 ; then
a13a7f89
RL
676 echo "$d"
677 return
678 fi
679 done
680 fi
681 false
682}
683
684
685
9a09819a
RL
686# The only action we can perform authoritatively prior to delegation
687# is to list all the possible delegates.
688# --------------------------------------------------------------
689
690config_spec="$0 $*"
691[ -z "$WXDEBUG" ] || config_spec=$configmask
692
693# Next chance for another satisfied customer then
694#
695# If we want to get really polished here we can do plural checking,
696# but we should probably leave that until the day we gettextise it.
697if [ -n "$output_option_list" ]; then
698
699 _remains_in_prefix=$installed_configs
b2f55c8b
MW
700 _delegates=`find_eligible_delegates $configmask`
701 _best_delegate=`find_best_delegate`
9a09819a
RL
702
703 if [ "x$WXDEBUG" = "xverbose" ]; then
a13a7f89
RL
704 decho
705 decho " all = $_remains_in_prefix"
706 decho " matching = $_delegates"
707 decho " best = $_best_delegate"
708 decho " this = $this_config"
9a09819a
RL
709 fi
710
711 for d in $_delegates; do
b2f55c8b 712 _remains_in_prefix=`remove_field $d $_remains_in_prefix`
9a09819a
RL
713 done
714
715 echo
716 echo " Default config is $this_config"
717 echo
718
719 if user_mask_fits "$this_config" ; then
720
721 echo " Default config ${this_exec_prefix+in $this_exec_prefix }will be used for output"
722
723 if match_field "$this_config" $_delegates ; then
b2f55c8b 724 _delegates=`remove_field $this_config $_delegates`
9a09819a
RL
725 else
726 echo " though it is not installed in: $prefix"
727 if [ -n "$_best_delegate" ] && [ "x$_best_delegate" != "x$this_config" ]; then
728 echo
729 echo " Best alternate in $prefix:"
730 echo " $_best_delegate"
731 fi
732 fi
733
734 elif [ -n "$_best_delegate" ]; then
735
736 echo " Specification best match: $_best_delegate"
737
1320281c 738 elif [ -z "$_delegates" ]; then
9a09819a 739
b2f55c8b 740 _last_chance=`find_best_legacy_config`
a13a7f89
RL
741 if [ -n "$_last_chance" ]; then
742
743 echo " Specification matches legacy config: $_last_chance"
744
745 else
bd630206 746
a13a7f89 747 cat <<-EOF
bd630206
VZ
748 No config found to match: $config_spec
749 in $wxconfdir
9a09819a 750
bd630206
VZ
751 Please install the desired library build, or specify a different
752 prefix where it may be found. If the library is not installed
753 you may call its wx-config directly by specifying its full path.
9a09819a 754
bd630206 755EOF
9a09819a 756
a13a7f89
RL
757 fi
758
1320281c
RL
759 else
760 echo " Specification was ambiguous. Use additional feature options"
761 echo " to choose between alternate matches."
9a09819a
RL
762 fi
763
b2f55c8b 764 _delegates=`remove_field "$_best_delegate" $_delegates`
9a09819a
RL
765
766 if [ -n "$_delegates" ]; then
767 echo
768 echo " Alternate matches:"
769 for d in $_delegates; do
770 echo " $d"
771 done
772 fi
773 if [ -n "$_remains_in_prefix" ]; then
774 echo
775 echo " Also available in $prefix:"
776 for d in $_remains_in_prefix; do
777 echo " $d"
778 done
779 fi
780
b2f55c8b 781 _legacy_configs=`find_legacy_configs`
a13a7f89
RL
782 if [ -n "$_legacy_configs" ]; then
783 echo
784 echo " Legacy configs available in $prefix:"
785 for d in $_legacy_configs; do
b2f55c8b 786 echo " $d" | sed 's/-config$//'
a13a7f89
RL
787 done
788 fi
789
9a09819a
RL
790 echo
791 exit
792fi
793
794
75f4be8a 795
9a09819a
RL
796# ... so if that wasn't what they wanted, then we need to know for
797# certain, can this config satisfy the user specification?
ceec2216 798# --------------------------------------------------------------
00c81359 799
b2f55c8b 800if not user_mask_fits "$this_config" ; then
ceec2216 801
4c51a665 802 # No? Then let's see if it knows anybody who can.
ceec2216
RL
803 # But first, just be sure someone hasn't typo'd us into a loop.
804 # In present day wx, correct delegation should never need more
805 # than one hop so this is trivial to detect.
806
807 if [ -n "$WXCONFIG_DELEGATED" ]; then
808 decho
809 decho " *** Error: Bad config delegation"
810 decho
811 decho " to: $0"
812 decho " ($this_config) cannot satisfy:"
9a09819a 813 decho " $config_spec"
ceec2216
RL
814 decho " Someone has been terribly careless."
815 decho
816 exit 1
127e9080
VZ
817 fi
818
ceec2216
RL
819 count_delegates "$configmask"
820 _numdelegates=$?
821
822 if [ -n "$WXDEBUG" ]; then
823 decho " must delegate to an alternate config"
824 decho " potential delegates ($_numdelegates):"
b2f55c8b 825 for i in `find_eligible_delegates "$configmask"`; do
ceec2216
RL
826 decho " $i"
827 done
00c81359 828 fi
a43ed08a 829
ceec2216 830 if [ $_numdelegates -eq 0 ]; then
a13a7f89 831
b2f55c8b 832 _last_chance=`find_best_legacy_config`
a13a7f89
RL
833 if [ -n "$_last_chance" ]; then
834
b2f55c8b 835 for arg do
22642fb2
RL
836 case "$arg" in
837 --prefix*|--exec-prefix*| \
838 --version|--release|--basename| \
839 --static|--libs|--gl_libs| \
840 --cppflags|--cflags|--cxxflags| \
841 --cc|--cxx|--ld| \
842 --rezflags|--inplace)
843 _legacy_args="$_legacy_args $arg"
844 ;;
bd630206 845
22642fb2
RL
846 --static|--static=y*|--static=Y*)
847 _legacy_args="$_legacy_args --static"
848 ;;
849 esac
850 done
851
a13a7f89
RL
852 if [ -n "$WXDEBUG" ]; then
853 decho " found a suitable legacy delegate: $_last_chance"
22642fb2 854 decho "--> $prefix/bin/$_last_chance $_legacy_args"
a13a7f89
RL
855 fi
856
6ab7f778
SN
857 WXCONFIG_DELEGATED=yes
858 export WXCONFIG_DELEGATED
22642fb2 859 $prefix/bin/$_last_chance $_legacy_args
a13a7f89
RL
860 exit
861
862 else
d9809627
RL
863
864 cat 1>&2 <<-EOF
865
bd630206
VZ
866 Warning: No config found to match: $config_spec
867 in $wxconfdir
868 If you require this configuration, please install the desired
869 library build. If this is part of an automated configuration
870 test and no other errors occur, you may safely ignore it.
871 You may use wx-config --list to see all configs available in
872 the default prefix.
d9809627 873
bd630206 874EOF
d9809627
RL
875
876 # PIPEDREAM: from here we are actually just a teensy step
877 # from simply building the missing config for the user
878 # on the fly if this is an in tree wx-config.
879
a13a7f89
RL
880 exit 1
881 fi
a43ed08a
VZ
882 fi
883
ceec2216
RL
884 if [ $_numdelegates -gt 1 ]; then
885
886 [ -z "$WXDEBUG" ] || decho " must prune the list of eligible delegates"
887
b2f55c8b 888 best_delegate=`find_best_delegate`
ceec2216
RL
889
890 if [ -n "$best_delegate" ]; then
bd630206 891
ceec2216
RL
892 if [ -n "$WXDEBUG" ]; then
893 decho " found a suitable delegate: $best_delegate"
894 decho "--> $wxconfdir/$best_delegate $*"
895 fi
896
6ab7f778
SN
897 WXCONFIG_DELEGATED=yes
898 export WXCONFIG_DELEGATED
ceec2216
RL
899 $wxconfdir/$best_delegate $*
900 exit
901 fi
902
903 decho
3950ea80
RL
904 decho " *** Error: Specification is ambiguous"
905 decho " as $config_spec"
ceec2216 906 decho " Use additional feature options to choose between:"
b2f55c8b 907 for i in `find_eligible_delegates "$configmask"`; do
ceec2216
RL
908 decho " $i"
909 done
910 decho
9a98a854 911
ceec2216
RL
912 exit 1
913 fi
914
915 if [ -n "$WXDEBUG" ]; then
916 decho " using the only suitable delegate"
b2f55c8b 917 decho "--> $wxconfdir/`find_eligible_delegates $configmask` $*"
ceec2216
RL
918 fi
919
6ab7f778
SN
920 WXCONFIG_DELEGATED=yes
921 export WXCONFIG_DELEGATED
b2f55c8b 922 $wxconfdir/`find_eligible_delegates $configmask` $*
ceec2216 923 exit
9a98a854
VZ
924fi
925
251f47d1 926
251f47d1 927
ceec2216
RL
928# If we are still here, then from now on we are responsible for
929# all the user's needs. Time to rustle up some output for them.
930# --------------------------------------------------------------
931
932[ -z "$WXDEBUG" ] || decho " using this config"
933
9103d280
RL
934# If the user supplied a prefix, and the in tree config did not
935# delegate out to anything in that prefix, then reset the build
936# tree prefix to provide the correct output for using this
937# uninstalled wx build. Or put more simply:
938prefix=${this_prefix-$prefix}
0506bbbf 939exec_prefix=${this_exec_prefix-$exec_prefix}
ceec2216
RL
940
941includedir="@includedir@"
942libdir="@libdir@"
ffa0583f 943bindir="@bindir@"
ceec2216
RL
944
945# Trivial queries we can answer now.
6758d3d3
RL
946[ -z "$output_option_prefix" ] || echo $prefix
947[ -z "$output_option_exec_prefix" ] || echo $exec_prefix
948[ -z "$output_option_release" ] || echo "@WX_RELEASE@"
949[ -z "$output_option_version" ] || echo "@WX_VERSION@"
950[ -z "$output_option_version_full" ] || echo "@WX_SUBVERSION@"
951[ -z "$output_option_basename" ] || echo "@WX_LIBRARY_BASENAME_GUI@"
6758d3d3
RL
952[ -z "$output_option_cc" ] || echo "@CC@"
953[ -z "$output_option_cxx" ] || echo "@CXX@"
99d4fdfd 954[ -z "$output_option_ld" ] || echo "@CXX@ -o"
6758d3d3 955[ -z "$flag_option_selected_config" ] || echo "$this_config"
ceec2216 956
e5405b6b
VZ
957for q in $query_options; do
958 eval echo "\$this_$q"
959done
a55d039a
RL
960
961# --rezflags is deprecated and disabled (2005/11/29)
962if [ -n "$output_option_rezflags" ]; then
963 echo "@true"
964 decho "Warning: --rezflags, along with Mac OS classic resource building" \
965 "is deprecated. You should remove this from your Makefile and" \
bd630206 966 "build .app bundles instead."
a55d039a 967fi
004ee6da 968
ceec2216
RL
969
970# The rest are going to need a little more work.
971# --------------------------------------------------------------
972
ffa0583f
RL
973is_monolithic() { [ "x@MONOLITHIC@" = "x1" ]; }
974is_static() { [ -n "$this_linkage" ]; }
975is_installed() { [ -z "$this_prefix" ]; }
ceec2216
RL
976
977
ffa0583f
RL
978# Is the user after a support utility?
979# If this is a cross build, we need to find and return a suitable
980# native utility for the job, so we search:
981#
982# 1. local build dir (for native uninstalled builds only).
983# 2. (optional) user supplied prefix.
984# 3. configured install prefix.
985# 4. environment $PATH.
986#
987# and if such a thing still cannot be found, exit signalling an error.
988if [ -n "$input_option_utility" ]; then
989
990 # This is dumb, in tree binaries should be in a standard location
991 # like the libs, but work with what we've got for now.
992 is_cross || _util="$exec_prefix/utils/$input_option_utility/$input_option_utility"
993
b2f55c8b 994 if not is_installed && [ -x "$_util" ]; then
ffa0583f
RL
995 is_static || _preload="eval LD_LIBRARY_PATH=$exec_prefix/lib"
996 echo $_preload $_util
997 exit
998 fi
999
1000 IFS=':'
1001 _user_prefix=${input_option_exec_prefix:-$input_option_prefix}
1002
1003 for _util in "${input_option_utility}-@WX_RELEASE@@WX_FLAVOUR@" \
1004 "${input_option_utility}-@WX_RELEASE@" \
92ea30ce 1005 "${input_option_utility}"
ffa0583f
RL
1006 do
1007 for p in ${_user_prefix:+$_user_prefix/bin} $bindir $PATH; do
1008
1009 [ -z "$WXDEBUG" ] || decho " checking for: '$p/$_util'"
1010
1011 if [ -x "$p/$_util" ]; then
1012 echo "$p/$_util"
1013 exit
1014 fi
1015
1016 done
1017 done
1018 exit 1
1019
1020fi
1021
1022
1023# Still here? Then get the options together for building an app.
1024# ----------------------------------------------------------------
1025
ceec2216
RL
1026# Additional configuration for individual library components.
1027ldflags_gl="@LDFLAGS_GL@"
1028
5ff751d6 1029ldlibs_base="@WXCONFIG_LIBS@"
ceec2216
RL
1030ldlibs_core="@EXTRALIBS_GUI@"
1031ldlibs_gl="@OPENGL_LIBS@"
1032ldlibs_html="@EXTRALIBS_HTML@"
1033ldlibs_xml="@EXTRALIBS_XML@"
ceec2216 1034ldlibs_adv="@EXTRALIBS_SDL@"
cf63f3d3 1035ldlibs_stc="@EXTRALIBS_STC@"
ceec2216 1036
ffa0583f 1037
e0e022b0
VZ
1038# Order the libraries passed to us correctly for static linking.
1039#
1040# While the libraries order doesn't matter when linking dynamically, we must
1041# put the libraries depending on other libraries in front of their dependencies
1042# when linking statically or the dependencies wouldn't be resolved by the
1043# standard UNIX linkers.
1044order_libs()
1045{
1046 if is_static; then
1047 for lib do
1048 # Distinguish between the libraries that may need to be moved to
1049 # the end of the list (because other ones may depend on them) and
1050 # those that can be output immediately because no other libraries
1051 # depend on them.
1052 case "$lib" in
1053 base|core|html|xml|adv) eval "use_$lib=1" ;;
1054 *) libs="$libs $lib" ;;
1055 esac
1056 done
1057
1058 # Add the libraries that we postponed adding above.
1059 # Order of the checks here is important.
e6d7f1ef
VZ
1060 [ -z "$use_html" ] || libs="$libs html"
1061 [ -z "$use_adv" ] || libs="$libs adv"
1062 [ -z "$use_core" ] || libs="$libs core"
1063 [ -z "$use_xml" ] || libs="$libs xml"
1064 [ -z "$use_base" ] || libs="$libs base"
e0e022b0
VZ
1065 else
1066 # No need to order them.
1067 libs="$@"
1068 fi
1069
1070 echo $libs
1071}
1072
ceec2216
RL
1073# lib_flags_for _liblist
1074# This function returns a list of flags suitable to return with the
1075# output of --libs for all of the libraries in _liblist. You can
1076# add support for a new library by adding an entry for it in the
1077# psuedo-hashes above if it requires additional linker options.
1078lib_flags_for()
1079{
1080 [ -z "$WXDEBUG" ] || decho " fetching lib flags for: '$*'"
1081
1082 _all_ldflags=''
1083 _all_libs=''
1084 _wxlibs=''
1085
92ea30ce 1086 is_cross && _target="-${target}"
ceec2216 1087
b2f55c8b 1088 for lib do
ceec2216
RL
1089
1090 # We evidently can't trust people not to duplicate things in
1091 # configure, or to keep them in any sort of sane order overall,
1092 # so only add unique new fields here even if it takes us a while.
1093 # In the case of libs, we bubble any duplicates to the end,
1094 # because if multiple libs require it, static linking at least
1095 # will require it to come after all of them. So long as local
1096 # order is ok in configure then we should always be able to
1097 # massage a correct result here like this.
1098 #
1099 # FIXME: ldlibs_core is totally bogus. Fix the duplication
1100 # there independently of this. This covers for it, but we
1101 # want to do this anyway because some libs may share common
1102 # deps without a common ancestor in wx. This is not a licence
1103 # for sloppy work elsewhere though and @GUI_TK_LIBRARY should
1104 # be fixed.
1105
b2f55c8b 1106 for f in `eval echo \"\\\$ldflags_$lib\"`; do
ceec2216
RL
1107 match_field "$f" $_all_ldflags || _all_ldflags="$_all_ldflags $f"
1108 done
1109
bd630206 1110 if match_field "$lib" @STD_BASE_LIBS@ ; then
ceec2216
RL
1111 _libname="@WX_LIBRARY_BASENAME_NOGUI@"
1112 else
1113 _libname="@WX_LIBRARY_BASENAME_GUI@"
1114 fi
1115 [ $lib = base ] || _libname="${_libname}_$lib"
1116 _libname="${_libname}-@WX_RELEASE@$_target"
1117
ffa0583f 1118 if is_static; then
ceec2216 1119 _wxlibs="$_wxlibs ${libdir}/lib${_libname}.a"
b2f55c8b 1120 for f in `eval echo \"\\\$ldlibs_$lib\"`; do
3838e2d3
RL
1121
1122 # Only propagate duplicate -libraries to their latest
1123 # possible position. Do not eliminate any other
1124 # duplicates that might occur. They should be fixed
1125 # in configure long before they get here.
1126 # This started as a workaround for Mac -framework,
1127 # but it seems like a better policy in general, which
1128 # will let the more heinous bugs in configure shake out.
1129 # We should maybe filter *.a here too, but not unless
1130 # we have to.
eb57b07a 1131 case "$f" in
b2f55c8b 1132 -l*) _all_libs="`remove_field $f $_all_libs` $f" ;;
eb57b07a
RL
1133 *) _all_libs="$_all_libs $f" ;;
1134 esac
3838e2d3 1135
ceec2216
RL
1136 done
1137 else
1138 _wxlibs="$_wxlibs -l${_libname}"
1139 fi
1140
1141 done
1142
1143 if [ -n "$WXDEBUG" ]; then
1144 decho " retrieved: ldflags = $_all_ldflags"
1145 decho " wxlibs = $_wxlibs"
1146 decho " alllibs = $_all_libs"
1147 fi
1148
1149 echo $_all_ldflags $_wxlibs $_all_libs
1150}
1151
fc2739d5
VZ
1152# this is the strict subset of the above function which returns only the
1153# (static) libraries themselves: this is used for linkdeps output which should
1154# output the list of libraries the main program should depend on
1155#
1156# of course, this duplication is bad but I'll leave to somebody else the care
3838e2d3
RL
1157# of refactoring this as I don't see any way to do it - VZ.
1158
1159# This (and the other cruft to support it) should be removed with
1160# reference to the FIXME above when configure stops piping us a slurry
1161# of options that need to be decomposed again for most practical uses - RL.
fc2739d5
VZ
1162link_deps_for()
1163{
1164 _wxlibs=''
1165
92ea30ce 1166 is_cross && _target="-${target}"
fc2739d5 1167
b2f55c8b 1168 for lib do
bd630206 1169 if match_field "$lib" @STD_BASE_LIBS@ ; then
fc2739d5
VZ
1170 _libname="@WX_LIBRARY_BASENAME_NOGUI@"
1171 else
1172 _libname="@WX_LIBRARY_BASENAME_GUI@"
1173 fi
1174 [ $lib = base ] || _libname="${_libname}_$lib"
1175 _libname="${_libname}-@WX_RELEASE@$_target"
1176
1177 _wxlibs="$_wxlibs ${libdir}/lib${_libname}.a"
1178 done
1179
1180 echo $_wxlibs
1181}
ceec2216
RL
1182
1183# Sanity check the list of libs the user provided us, if any.
1184# --------------------------------------------------------------
1185
bd630206
VZ
1186wx_libs=`echo "$libs_parameters" | tr ',' ' '`
1187wx_optional_libs=`echo "$optional_libs_parameters" | tr ',' ' '`
1188
1189# Add the --optional-libs, if they've been compiled and aren't already added
1190for i in $wx_optional_libs; do
1191 if match_field $i @BUILT_WX_LIBS@; then
1192 if not match_field $i $wx_libs; then
1193 wx_libs="${wx_libs:+$wx_libs }$i"
1194 fi
1195 fi
1196done
ceec2216
RL
1197
1198[ -z "$WXDEBUG" ] || decho " user supplied libs: '$wx_libs'"
1199
6bddfdbf
VZ
1200# Assume we are using the GUI, unless --libs was specified with no GUI libs
1201using_gui=yes
1202
ceec2216
RL
1203if is_monolithic; then
1204
bd630206
VZ
1205 # Only add additional info if --libs was specified and not just --optional-libs
1206 if [ -n "$output_option_libs" ]; then
1207 # Core libs are already built into the blob.
1208 for i in std @STD_GUI_LIBS@ @STD_BASE_LIBS@; do
1209 wx_libs=`remove_field $i $wx_libs`
1210 done
ceec2216 1211
e0e022b0 1212 wx_libs=`order_libs $wx_libs`
bd630206 1213 wx_libs="@WXCONFIG_LDFLAGS_GUI@ `lib_flags_for $wx_libs`"
ceec2216 1214
bd630206
VZ
1215 # We still need the core lib deps for a static build though
1216 if is_static; then
1217 link_deps="${libdir}/libwx_@TOOLCHAIN_NAME@.a"
1218 wx_libs="$wx_libs $link_deps $ldlibs_core $ldlibs_base"
1219 else
1220 wx_libs="$wx_libs -lwx_@TOOLCHAIN_NAME@"
1221 fi
bd630206 1222 fi
ceec2216
RL
1223else # MONOLITHIC = 0
1224
bd630206
VZ
1225 # Import core libs by default, expand std if specified, or add base if omitted.
1226 if [ -n "$output_option_libs" ] && [ -z "$libs_parameters" ]; then
1227 wx_libs="@STD_GUI_LIBS@ @STD_BASE_LIBS@"
1228 elif match_field all $wx_libs; then
1229 wx_libs="@BUILT_WX_LIBS@"
6a9046db
RL
1230 elif match_field std $wx_libs; then
1231 # Bubble any libs that were already specified to the end
1232 # of the list and ensure static linking order is retained.
b2f55c8b 1233 wx_libs=`remove_field std $wx_libs`
bd630206 1234 for i in @STD_GUI_LIBS@ @STD_BASE_LIBS@; do
b2f55c8b 1235 wx_libs="`remove_field $i $wx_libs` $i"
ceec2216 1236 done
b2f55c8b 1237 elif not match_field base $wx_libs ; then
bd630206
VZ
1238 # Only add base if --libs was specified and not just --optional-libs
1239 if [ -n "$output_option_libs" ]; then
1240 wx_libs="$wx_libs base"
1241 fi
ceec2216
RL
1242 fi
1243
6bddfdbf
VZ
1244 if [ -n "$output_option_libs" ]; then
1245 using_gui=no
1246 for i in $wx_libs ; do
1247 if match_field "$i" @STD_GUI_LIBS@; then
1248 _guildflags="@WXCONFIG_LDFLAGS_GUI@"
1249 using_gui=yes
1250 break
1251 fi
1252 match_field "$i" @STD_BASE_LIBS@ || using_gui=yes
1253 done
1254 fi
ceec2216 1255
ffa0583f 1256 if is_static; then
b2f55c8b 1257 link_deps=`link_deps_for $wx_libs`
fc2739d5 1258 fi
e0e022b0 1259 wx_libs=`order_libs $wx_libs`
b2f55c8b 1260 wx_libs="$_guildflags `lib_flags_for $wx_libs`"
251f47d1
VS
1261fi
1262
ceec2216 1263
6bddfdbf
VZ
1264# If they explicitly set "--cxx(pp)flags base" then they don't want the GUI
1265if [ "$cxx_parameters" = "base" ]; then
1266 using_gui=no
1267fi
1268
1269
ceec2216
RL
1270if [ -n "$WXDEBUG" ]; then
1271 decho
1272 decho " using libs: '$wx_libs'"
1273 decho " using_gui = $using_gui"
1274 decho
c39ee0ad 1275fi
251f47d1
VS
1276
1277
ceec2216
RL
1278# Endgame. Nothing left to discover now.
1279# --------------------------------------------------------------
251f47d1 1280
9103d280 1281[ "$using_gui" = "yes" ] || _gui_cppflags="-DwxUSE_GUI=0"
ceec2216 1282
ffa0583f 1283if is_installed; then
0506bbbf 1284 _include_cppflags="-I${includedir}/wx-@WX_RELEASE@@WX_FLAVOUR@"
ffa0583f 1285else
aa1c09fe 1286 _include_cppflags="-I${includedir}"
0506bbbf
RL
1287fi
1288
b2f55c8b 1289_cppflags=`echo "-I${libdir}/wx/include/@TOOLCHAIN_FULLNAME@" $_include_cppflags "@WXCONFIG_CPPFLAGS@" $_gui_cppflags`
ceec2216
RL
1290
1291# now without further ado, we can answer these too.
9103d280 1292[ -z "$output_option_cppflags" ] || echo $_cppflags
5ff751d6
VZ
1293[ -z "$output_option_cflags" ] || echo $_cppflags "@WXCONFIG_CFLAGS@"
1294[ -z "$output_option_cxxflags" ] || echo $_cppflags "@WXCONFIG_CXXFLAGS@"
b2f55c8b 1295[ -z "$output_option_gl_libs" ] || echo `lib_flags_for gl`
fc2739d5 1296[ -z "$output_option_linkdeps" ] || echo $link_deps
ceec2216
RL
1297
1298if [ -n "$output_option_libs" ]; then
bd630206 1299 # if --libs [--optional-libs] then output the full linker information
ceec2216 1300
92ea30ce
RL
1301 is_cross &&
1302 [ "x$libdir" = "x/usr/${target}/lib" ] ||
1303 [ "x$libdir" = "x/usr/lib" ] ||
1304 _ldflags="-L$libdir"
ceec2216 1305
b4f28d1e
RD
1306 if [ -n "$MAC_FRAMEWORK" ]; then
1307 wx_libs="-framework $MAC_FRAMEWORK"
1308 if [ -n "$MAC_FRAMEWORK_PREFIX" ]; then
1309 _ldflags="-F$MAC_FRAMEWORK_PREFIX"
1310 else
1311 _ldflags=""
1312 fi
1313 fi
1314
ffa0583f
RL
1315 is_installed || [ -n "$flag_option_no_rpath" ] || _rpath="@WXCONFIG_RPATH@"
1316
d4fbe1d8 1317 echo $_ldflags "@WXCONFIG_LDFLAGS@" $_rpath $wx_libs "@DMALLOC_LIBS@"
bd630206
VZ
1318
1319elif [ -n "$output_option_optional_libs" ]; then
1320 # if only --optional-libs then output just the libs
1321
1322 echo $wx_libs
ceec2216
RL
1323fi
1324
004ee6da 1325
a55d039a
RL
1326# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1327#
1328# Beyond here reside only machine or tool specific workarounds
1329# that require knowlege not obtainable prior to this comment.
1330#
1331# Please. Avoid addding things here, wx-config should avoid
1332# hard coding tool specific details. Do not use things here
1333# as an example of other things that should be here, These
1334# shouldn't be here either. This is a place of last resort
1335# for interim workarounds. I can but stress as strongly as
1336# the censor will allow, there are only bad examples of things
1337# that belong at this level of abstraction to follow. It is
1338# a limbo for glitches awaiting the Next Design Repair. Ok.
1339#
1340# With that firmly in mind, our debut dilemma is:
3f97aec5 1341
a55d039a 1342# Resource compilers. An elusive term that covers some pretty
004ee6da
RL
1343# dissimilar concepts on various platforms. The good news is,
1344# each platform has only one definition of 'resource', compiled
1345# or not, and so we can abstract that neatly to return a platform
1346# specific invocation of the appropriate tool. The bad news is,
1347# windres (at least) requires knowledge of the wx header files
1348# location(s) that cannot be predicted reliably before the call to
1349# wx-config is made. Currently for all known resource compilers,
1350# we can simply return a command and some salient configuration
1351# options in response to a request for --rescomp. So here we
1352# top up the options for any tools that may require information
1353# that was only just determined in the last few machine cycles,
1354# then output the necessary incantation for the platform.
1355#
1356# Most things should already be constant by the time configure
1357# has run. Do not add anything here that is already known there.
1358
1359if [ -n "$output_option_rescomp" ]; then
1360
1361 case "@RESCOMP@" in
1362 *windres|wrc)
1363 # Note that with late model windres, we could just insert
bd630206
VZ
1364 # _include_cppflags here, but use the old notation for now
1365 # as it is more universally accepted.
004ee6da
RL
1366 if is_installed; then
1367 echo "@RESCOMP@ --include-dir" \
1368 "${includedir}/wx-@WX_RELEASE@@WX_FLAVOUR@" \
1369 "@WXCONFIG_RESFLAGS@"
1370 else
1371 echo "@RESCOMP@ --include-dir ${includedir}" \
bd630206 1372 "@WXCONFIG_RESFLAGS@"
004ee6da
RL
1373 fi
1374 ;;
1375
1376 # neither rez not emxbind have any specific needs from
1377 # us, so just output what was determined by configure.
1378 *)
1379 echo @RESCOMP@ @WXCONFIG_RESFLAGS@
1380 ;;
1381 esac
1382
1383fi
1384
a55d039a
RL
1385#
1386# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
004ee6da 1387
ceec2216
RL
1388# And so that's it, we're done. Have a nice build.
1389
1390exit 0
9a98a854 1391
9a98a854 1392