]>
Commit | Line | Data |
---|---|---|
8708fa76 VS |
1 | #!/bin/sh |
2 | ||
3 | # ------------------------------------------------------------------------- | |
4 | # Location of wx: | |
5 | # ------------------------------------------------------------------------- | |
6 | ||
7 | update_prefixes() | |
8 | { | |
9 | includedir="@includedir@" | |
10 | libdir="@libdir@" | |
11 | } | |
12 | prefix="@prefix@" | |
13 | exec_prefix="@exec_prefix@" | |
14 | update_prefixes | |
15 | ||
16 | srcdir="@top_srcdir@" | |
17 | builddir="@top_builddir_wxconfig@" | |
18 | ||
19 | ||
20 | # ------------------------------------------------------------------------- | |
21 | # Wrapper script: | |
22 | # ------------------------------------------------------------------------- | |
23 | ||
24 | exec_prefix_set=no | |
25 | ||
26 | # return the absolute path prepending builddir to it if needed | |
27 | makeabs() | |
28 | { | |
29 | path=$1 | |
30 | # TODO: this only works under Unix and even there it could be | |
31 | # enhanced to remove ".." and "." | |
32 | if [ `echo $path | sed 's/^\(.\).*/\1/'` != "/" ]; then | |
33 | if [ $path = "." ]; then | |
34 | path=$builddir | |
35 | else | |
36 | path="$builddir/$path" | |
37 | fi | |
38 | fi | |
39 | ||
40 | echo $path | |
41 | } | |
42 | ||
43 | # these determine wx-config script to use: | |
44 | m_toolkit='*' | |
45 | m_univ='*' | |
46 | m_unicode='*' | |
47 | m_debug='*' | |
48 | m_version='*.*' | |
49 | ||
50 | # lists all wx-config scripts that match criteria specified above | |
51 | list_wx_config_scripts() | |
52 | { | |
53 | mask="${m_toolkit}${m_univ}${m_unicode}${m_debug}-${m_version}" | |
54 | ||
55 | # if wx-config was called via wx$TOOLCHAIN_NAME-config symlink, | |
56 | # try to extract the mask from it: | |
57 | myname=`basename $0` | |
58 | if test $myname != wx-config ; then | |
59 | toolchain=`echo $myname | sed 's/wx\(.*\)-config/\1/'` | |
60 | if test -f ${libdir}/wx/config/${toolchain} ; then | |
61 | mask=$toolchain | |
62 | fi | |
63 | fi | |
64 | ||
65 | if test -d ${libdir}/wx/config ; then | |
66 | (cd ${libdir}/wx/config/ && ls -1 $mask 2>/dev/null) | |
67 | fi | |
68 | } | |
69 | ||
70 | # find first wx-config script that matches criteria | |
71 | find_wx_config_script() | |
72 | { | |
73 | all_scripts=`list_wx_config_scripts` | |
74 | # unless wxBase was explicitly requested, try to find a GUI version: | |
75 | if test "$m_toolkit" != "base" ; then | |
76 | script=`echo $all_scripts | tr ' ' '\n' | grep -v '^base' | head -n 1` | |
77 | if test "x$script" != "x" ; then | |
78 | echo ${libdir}/wx/config/${script} | |
79 | fi | |
80 | fi | |
81 | ||
82 | # otherwise (or if no GUI script was found), use alphabetically 1st script: | |
83 | script=`echo $all_scripts | head -n 1` | |
84 | if test -z "$script" ; then | |
85 | echo "no suitable wx-config script found" >&2 | |
86 | exit 1 | |
87 | fi | |
88 | echo ${libdir}/wx/config/${script} | |
89 | } | |
90 | ||
91 | ||
92 | # handle options: | |
93 | ||
94 | # arguments to pass to the real wx-config script: | |
95 | args="" | |
96 | ||
97 | for i in $*; do | |
98 | case "$i" in | |
99 | -*=*) optarg=`echo "$i" | sed 's/[-_a-zA-Z0-9]*=//'` ;; | |
100 | *) optarg= ;; | |
101 | esac | |
102 | ||
103 | case $i in | |
104 | --inplace) | |
105 | prefix=`makeabs $srcdir` | |
106 | exec_prefix=`makeabs $builddir` | |
107 | exec_prefix_set=yes | |
108 | update_prefixes | |
109 | args="$args --inplace" | |
110 | ;; | |
111 | --prefix=*) | |
112 | prefix=$optarg | |
113 | if test $exec_prefix_set = no ; then | |
114 | exec_prefix=$optarg | |
115 | fi | |
116 | update_prefixes | |
117 | ;; | |
118 | --exec-prefix=*) | |
119 | exec_prefix=$optarg | |
120 | exec_prefix_set=yes | |
121 | update_prefixes | |
122 | ;; | |
123 | ||
124 | --list) | |
125 | # list available wx versions: | |
126 | list_wx_config_scripts | |
127 | exit | |
128 | ;; | |
129 | ||
130 | --toolkit=*) | |
131 | m_toolkit=$optarg | |
132 | ;; | |
133 | --version=*) | |
134 | m_version=$optarg | |
135 | ;; | |
136 | --unicode=*) | |
137 | if test "x$optarg" = "xyes" ; then | |
138 | m_unicode="u" | |
139 | else | |
140 | m_unicode="" | |
141 | fi | |
142 | ;; | |
143 | --unicode) | |
144 | m_unicode="u" | |
145 | ;; | |
146 | --debug=*) | |
147 | if test "x$optarg" = "xyes" ; then | |
148 | m_debug="d" | |
149 | else | |
150 | m_debug="" | |
151 | fi | |
152 | ;; | |
153 | --debug) | |
154 | m_debug="d" | |
155 | ;; | |
156 | --universal=*) | |
157 | if test "x$optarg" = "xyes" ; then | |
158 | m_univ="univ" | |
159 | else | |
160 | m_univ="" | |
161 | fi | |
162 | ;; | |
163 | --universal) | |
164 | m_univ="univ" | |
165 | ;; | |
166 | *) | |
167 | args="$args $i" | |
168 | ;; | |
169 | esac | |
170 | done | |
171 | ||
172 | args="$args --prefix=$prefix --exec-prefix=$exec_prefix" | |
173 | ||
174 | script=`find_wx_config_script`; | |
175 | if test "x$script" != "x" ; then | |
176 | $script $args | |
177 | exit $? | |
178 | else | |
179 | exit 1 | |
180 | fi |