]> git.saurik.com Git - wxWidgets.git/blob - wx-config-wrapper.in
documented DoPrepareDC()
[wxWidgets.git] / wx-config-wrapper.in
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='.*[^u][^d]'
45 m_univ='\(univ\)\?'
46 m_unicode='u\?'
47 m_debug='d\?'
48 m_version='[0-9]\+\.[0-9]\+'
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 | grep "$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 exit 0
80 fi
81 fi
82
83 # otherwise (or if no GUI script was found), use alphabetically 1st script:
84 script=`echo $all_scripts | head -n 1`
85 if test -z "$script" ; then
86 echo "no suitable wx-config script found" >&2
87 exit 1
88 fi
89 echo ${libdir}/wx/config/${script}
90 }
91
92
93 # handle options:
94
95 # arguments to pass to the real wx-config script:
96 args=""
97
98 for i in $*; do
99 case "$i" in
100 -*=*) optarg=`echo "$i" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
101 *) optarg= ;;
102 esac
103
104 case $i in
105 --inplace)
106 prefix=`makeabs $srcdir`
107 exec_prefix=`makeabs $builddir`
108 exec_prefix_set=yes
109 update_prefixes
110 args="$args --inplace"
111 ;;
112 --prefix=*)
113 prefix=$optarg
114 if test $exec_prefix_set = no ; then
115 exec_prefix=$optarg
116 fi
117 update_prefixes
118 ;;
119 --exec-prefix=*)
120 exec_prefix=$optarg
121 exec_prefix_set=yes
122 update_prefixes
123 ;;
124
125 --list)
126 # list available wx versions:
127 list_wx_config_scripts
128 exit
129 ;;
130
131 --toolkit=*)
132 m_toolkit=$optarg
133 ;;
134 --version=*)
135 m_version=$optarg
136 ;;
137 --unicode=*)
138 if test "x$optarg" = "xyes" ; then
139 m_unicode="u"
140 else
141 m_unicode=""
142 fi
143 ;;
144 --unicode)
145 m_unicode="u"
146 ;;
147 --debug=*)
148 if test "x$optarg" = "xyes" ; then
149 m_debug="d"
150 else
151 m_debug=""
152 fi
153 ;;
154 --debug)
155 m_debug="d"
156 ;;
157 --universal=*)
158 if test "x$optarg" = "xyes" ; then
159 m_univ="univ"
160 else
161 m_univ=""
162 fi
163 ;;
164 --universal)
165 m_univ="univ"
166 ;;
167 *)
168 args="$args $i"
169 ;;
170 esac
171 done
172
173 args="$args --prefix=$prefix --exec-prefix=$exec_prefix"
174
175 script=`find_wx_config_script`;
176 if test "x$script" != "x" ; then
177 $script $args
178 exit $?
179 else
180 exit 1
181 fi