moved DB classes into wxODBC library
[wxWidgets.git] / wx-config.in
1 #!/bin/sh
2
3 # -------------------------------------------------------------------------
4 #                              Configured settings:
5 # -------------------------------------------------------------------------
6
7 # Version and build type information:
8
9 WX_MAJOR_VERSION_NUMBER="@WX_MAJOR_VERSION_NUMBER@"
10 WX_MINOR_VERSION_NUMBER="@WX_MINOR_VERSION_NUMBER@"
11 WX_RELEASE_NUMBER="@WX_RELEASE_NUMBER@"
12 release="@WX_MAJOR_VERSION_NUMBER@.@WX_MINOR_VERSION_NUMBER@"
13 is_monolithic="@MONOLITHIC@"
14 cross_compiling="@cross_compiling@"
15 target="@host_alias@"
16 static_flag="@STATIC_FLAG@"
17
18
19 # Misc configuration variables:
20
21 prefix="@prefix@"
22 exec_prefix="@exec_prefix@"
23 includedir="@includedir@"
24 libdir="@libdir@"
25 CC="@CC@"
26 GCC="@GCC@"
27 CXX="@CXX@"
28 LD="@SHARED_LD@"
29 srcdir="@top_srcdir@"
30 builddir="@top_builddir_wxconfig@"
31 basename_nogui="@WX_LIBRARY_BASENAME_NOGUI@"
32 basename_gui="@WX_LIBRARY_BASENAME_GUI@"
33
34 TOOLCHAIN_NAME="@TOOLCHAIN_NAME@"
35 LDFLAGS="@LDFLAGS@"
36 WXCONFIG_RPATH="@WXCONFIG_RPATH@"
37 DMALLOC_LIBS="@DMALLOC_LIBS@"
38 WXCONFIG_LIBS="@WXCONFIG_LIBS@"
39 WXCONFIG_LIBS_STATIC="@WXCONFIG_LIBS_STATIC@"
40 WXDEBUG_DEFINE="@WXDEBUG_DEFINE@"
41 TOOLCHAIN_DEFS="@TOOLCHAIN_DEFS@"
42 TOOLCHAIN_DLL_DEFS="@TOOLCHAIN_DLL_DEFS@"
43 WXCONFIG_INCLUDE="@WXCONFIG_INCLUDE@"
44 WX_LARGEFILE_FLAGS="@WX_LARGEFILE_FLAGS@"
45 CODE_GEN_FLAGS="@CODE_GEN_FLAGS@"
46 CODE_GEN_FLAGS_CXX="@CODE_GEN_FLAGS_CXX@"
47 LDFLAGS_EXE="@LDFLAGS_EXE@"
48 MACRESWXCONFIG="@MACRESWXCONFIG@"
49 EXTRALIBS_GUI="@EXTRALIBS_GUI@"
50 LIBS="@LIBS@"
51
52
53 # Linker flags for sublibraries:
54
55 CORE_BASE_LIBS="xml net base"
56 CORE_GUI_LIBS="html odbc adv core"
57
58 ldlibs_base="@WXCONFIG_EXTRALIBS@"
59 ldlibs_core="@EXTRALIBS_GUI@"
60 ldlibs_xml="@EXTRALIBS_XML@"
61 ldlibs_odbc="@EXTRALIBS_ODBC@"
62
63 ldflags_gl="@LDFLAGS_GL@"
64 ldlibs_gl="@OPENGL_LIBS@"
65
66
67
68 # -------------------------------------------------------------------------
69 #                                Script code:
70 # -------------------------------------------------------------------------
71
72 exec_prefix_set=no
73
74 # is $1 among the rest of arguments?
75 isinlist()
76 {
77     value=$1
78     shift
79     isin=no
80     for iii in $* ; do
81         if test $iii = $value ; then isin=yes ; fi
82     done
83     test $isin = yes
84 }
85
86 # output linker commands needed to link against libraries passed as arguments
87 # (does not handle monolithic/multilib):
88 output_libs()
89 {
90     if test "$cross_compiling" = "yes" ; then
91         target_tag="-${target}"
92     fi
93
94     all_libs=""
95     all_ldflags=""
96     wxlibs=""
97
98     for lib in $* ; do
99         eval xlibs=\$ldlibs_$lib
100         eval xflags=\$ldflags_$lib
101         if isinlist $lib $CORE_BASE_LIBS ; then
102             basename=$basename_nogui
103         else
104             basename=$basename_gui
105         fi
106         if test $lib = "base" ; then
107             libname="$basename"
108         else
109             libname="${basename}_${lib}"
110         fi
111
112         all_ldflags="$all_ldflags $xflags"
113         if test $static_flag = yes ; then
114             wxlibs="$wxlibs ${libdir}/lib${libname}-${release}${target_tag}.a"
115             all_libs="$all_libs $xlibs"
116         else
117             wxlibs="$wxlibs -l${libname}-${release}${target_tag}"
118         fi
119     done
120
121     echo $all_ldflags $wxlibs $all_libs
122 }
123
124 # return the absolute path prepending builddir to it if needed
125 makeabs()
126 {
127     path=$1
128     # TODO: this only works under Unix and even there it could be
129     #       enhanced to remove ".." and "."
130     if [ `echo $path | sed 's/^\(.\).*/\1/'` != "/" ]; then
131         if [ $path = "." ]; then
132             path=$builddir
133         else
134             path="$builddir/$path"
135         fi
136     fi
137
138     echo $path
139 }
140
141 usage()
142 {
143     cat <<EOF
144 Usage: wx-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--release]
145                  [--basename] [--static] [--libs[=LIBS]] [--gl-libs]
146                  [--cppflags] [--cflags] [--cxxflags] [--ldflags] [--rezflags]
147                  [--cc] [--cxx] [--ld]
148
149 wx-config returns configuration information about the installed
150 version of wxWindows. It may be used to query its version and
151 installation directories and also retrieve the C and C++ compilers
152 and linker which were used for its building and the corresponding
153 flags.
154
155 Ordinarily it should be installed to the appropriate system location
156 along with the headers and library files, but it is also possible to
157 use it to enable builds with an uninstalled wxWindows version for
158 package building and bleeding edge developers.  To do so, use it like
159 this:
160
161 \${wx_builddir}/wx-config --prefix=\${wx_srcdir} --exec-prefix=\${wx_builddir}
162
163 Note that any other options supplied must come *after* the prefix
164 specification for it to take effect.
165
166 --static must come before --libs and --gl-libs.
167
168 --libs can take optional argument that contains comma-separated list of
169 wxWindows libraries to link against. This list can include both core
170 and contrib libraries.
171
172 --gl-libs option is deprecated, used --libs=gl instead.
173
174 EOF
175
176     exit $1
177 }
178
179 cppflags()
180 {
181     # we should never specify -I/usr/include on the compiler command line: this
182     # is at best useless and at worst breaks compilation on the systems where
183     # the system headers are non-ANSI because gcc works around this by storing
184     # the ANSI-fied versions of them in its private directory which is searched
185     # after all the directories on the cmd line.
186     #
187     # the situation is a bit more complicated with -I/usr/local/include: again,
188     # it shouldn't be specified with gcc which looks there by default anyhow
189     # and gives warnings (at least 3.1 does) if it is specified explicitly --
190     # but this -I switch *is* needed for the other compilers
191     #
192     # note that we assume that if we use GNU cc we also use GNU c++ and vice
193     # versa, i.e. this won't work (either for --cflags or --cxxflags) if GNU C
194     # compiler and non-GNU C++ compiler are used or vice versa -- we'll fix
195     # this when/if anybody complains about it
196     if test "${includedir}" != "/usr/include" \
197             -a "${includedir}" != "/usr/include/c++" \
198             -a \( "${GCC}" != "yes" \
199                   -o "${includedir}" != "/usr/local/include" \) \
200             -a \( "${cross_compiling}" != "yes" \
201                   -o "${includedir}" != "/usr/${target}/include" \) ;
202     then
203         includes=" -I${includedir}"
204     fi
205
206     includes="-I${libdir}/wx/include/${TOOLCHAIN_NAME}$includes"
207
208     if test $static_flag = yes ; then
209         echo $includes ${WXDEBUG_DEFINE} ${TOOLCHAIN_DEFS} ${WXCONFIG_INCLUDE} ${WX_LARGEFILE_FLAGS}
210     else
211         echo $includes ${WXDEBUG_DEFINE} ${TOOLCHAIN_DEFS} ${TOOLCHAIN_DLL_DEFS} ${WXCONFIG_INCLUDE} ${WX_LARGEFILE_FLAGS}
212     fi
213 }
214
215 if test $# -eq 0; then
216     usage 1 1>&2
217 fi
218
219 while test $# -gt 0; do
220   case "$1" in
221   -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
222   *) optarg= ;;
223   esac
224
225   case $1 in
226     --inplace)
227       prefix=`makeabs $srcdir`
228       exec_prefix=`makeabs $builddir`
229       exec_prefix_set=yes
230       ;;
231     --prefix=*)
232       prefix=$optarg
233       if test $exec_prefix_set = no ; then
234         exec_prefix=$optarg
235       fi
236       ;;
237     --prefix)
238       echo $prefix
239       ;;
240     --exec-prefix=*)
241       exec_prefix=$optarg
242       exec_prefix_set=yes
243       ;;
244     --exec-prefix)
245       echo $exec_prefix
246       ;;
247     --version)
248       echo ${WX_MAJOR_VERSION_NUMBER}.${WX_MINOR_VERSION_NUMBER}.${WX_RELEASE_NUMBER}
249       ;;
250     --release)
251       echo $release
252       ;;
253     --basename)
254       echo $basename_gui
255       ;;
256     --static)
257       static_flag=yes
258       ;;
259     --cppflags)
260       cppflags
261       ;;
262     --cflags)
263       echo `cppflags` ${CODE_GEN_FLAGS}
264       ;;
265     --cxxflags)
266       echo `cppflags` ${CODE_GEN_FLAGS} ${CODE_GEN_FLAGS_CXX}
267       ;;
268     --ldflags)
269       echo ${LDFLAGS_EXE}
270       ;;
271     --rezflags)
272       echo ${MACRESWXCONFIG}
273       ;;
274
275     --libs*)
276       # find if the argument was --libs=list,of,libs or --libs:
277       if test "x$optarg" = "x" ; then
278           if test "$is_monolithic" = "0" ; then
279               # link against all libs if none given explicitly:
280               libs_list="$CORE_GUI_LIBS $CORE_BASE_LIBS"
281           fi
282       else
283           libs_list=`echo "$optarg" | tr ',' ' '`
284           # always add wxBase, any wxApp needs it:
285           libs_list="$libs_list base"
286       fi
287
288       # include install directory only if it is not default:
289       if test "${libdir}" != "/usr/lib" \
290               -a \( "${cross_compiling}" != "yes" \
291                     -o "${libdir}" != "/usr/${target}/lib" \) ;
292       then
293           libs="-L${libdir}"
294       fi
295
296       # in monolithic build, link against the main library:
297       if test "$is_monolithic" = "1" ; then
298           # filter out core libs, leave only contrib in libs_list:
299           newlist=
300           for i in $libs_list ; do
301               if isinlist $i $CORE_BASE_LIBS $CORE_GUI_LIBS ; then
302                   libs_list="" # do nothing
303               else
304                   newlist="$newlist $i"
305               fi
306           done
307           libs_list="$newlist"
308
309           # output link flags:
310           contrib_libs=`output_libs $libs_list`
311           if test $static_flag = yes ; then
312               echo "$libs ${LDFLAGS} ${WXCONFIG_RPATH} $contrib_libs ${libdir}/${WXCONFIG_LIBS_STATIC} ${EXTRALIBS_GUI} ${LIBS} ${DMALLOC_LIBS}"
313           else
314               echo $libs ${LDFLAGS} ${WXCONFIG_RPATH} $contrib_libs ${WXCONFIG_LIBS} ${DMALLOC_LIBS}
315           fi
316       else
317           # in multilib mode, link against all sublibraries:
318           wxlibs=`output_libs $libs_list`
319           echo $libs ${LDFLAGS} ${WXCONFIG_RPATH} $wxlibs ${DMALLOC_LIBS}
320       fi
321
322       ;;
323     --gl-libs)
324       output_libs gl
325       ;;
326     --cc)
327       echo $CC
328       ;;
329     --cxx)
330       echo $CXX
331       ;;
332     --ld)
333       echo $LD
334       ;;
335     *)
336       usage 1 1>&2
337       ;;
338   esac
339   shift
340 done
341