improved Mac resource creation step in order to allow samples to provide
[wxWidgets.git] / wx-config.in
1 #!/bin/sh
2
3 prefix=@prefix@
4 exec_prefix=@exec_prefix@
5 exec_prefix_set=no
6 CC="@CC@"
7 GCC="@GCC@"
8 CXX="@CXX@"
9 LD="@SHARED_LD@"
10 srcdir=@top_srcdir@
11 builddir=@top_builddir@
12 cross_compiling=@cross_compiling@
13 target=@host_alias@
14 static_flag=@STATIC_FLAG@
15
16 # return the absolute path prepending builddir to it if needed
17 makeabs()
18 {
19     path=$1
20     # TODO: this only works under Unix and even there it could be
21     #       enhanced to remove ".." and "."
22     if [ `echo $path | sed 's/^\(.\).*/\1/'` != "/" ]; then
23         if [ $path = "." ]; then
24             path=$builddir
25         else
26             path="$builddir/$path"
27         fi
28     fi
29
30     echo $path
31 }
32
33 usage()
34 {
35     cat <<EOF
36 Usage: wx-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--static]
37                  [--libs] [--gl-libs]
38                  [--cppflags] [--cflags] [--cxxflags] [--ldflags] [--rezflags]
39                  [--cc] [--cxx] [--ld]
40
41 wx-config returns configuration information about the installed
42 version of wxWindows. It may be used to query its version and
43 installation directories and also retrieve the C and C++ compilers
44 and linker which were used for its building and the corresponding
45 flags.
46
47 Ordinarily it should be installed to the appropriate system location
48 along with the headers and library files, but it is also possible to
49 use it to enable builds with an uninstalled wxWindows version for
50 package building and bleeding edge developers.  To do so, use it like
51 this:
52
53 \${wx_builddir}/wx-config --prefix=\${wx_srcdir} --exec-prefix=\${wx_builddir}
54
55 Note that any other options supplied must come *after* the prefix
56 specification for it to take effect.
57
58 EOF
59
60     exit $1
61 }
62
63 cppflags()
64 {
65     # we should never specify -I/usr/include on the compiler command line: this
66     # is at best useless and at worst breaks compilation on the systems where
67     # the system headers are non-ANSI because gcc works around this by storing
68     # the ANSI-fied versions of them in its private directory which is searched
69     # after all the directories on the cmd line.
70     #
71     # the situation is a bit more complicated with -I/usr/local/include: again,
72     # it shouldn't be specified with gcc which looks there by default anyhow
73     # and gives warnings (at least 3.1 does) if it is specified explicitly --
74     # but this -I switch *is* needed for the other compilers
75     #
76     # note that we assume that if we use GNU cc we also use GNU c++ and vice
77     # versa, i.e. this won't work (either for --cflags or --cxxflags) if GNU C
78     # compiler and non-GNU C++ compiler are used or vice versa -- we'll fix
79     # this when/if anybody complains about it
80     if test "@includedir@" != "/usr/include" \
81             -a "@includedir@" != "/usr/include/c++" \
82             -a \( "${GCC}" != "yes" \
83                   -o "@includedir@" != "/usr/local/include" \) \
84             -a \( "${cross_compiling}" != "yes" \
85                   -o "@includedir@" != "/usr/${target}/include" \) ;
86     then
87         includes=" -I@includedir@"
88     fi
89
90     includes="-I@libdir@/wx/include/@TOOLCHAIN_NAME@$includes"
91
92     if test $static_flag = yes ; then
93         echo $includes @WXDEBUG_DEFINE@ @TOOLCHAIN_DEFS@ @WXCONFIG_INCLUDE@ @WX_LARGEFILE_FLAGS@
94     else
95         echo $includes @WXDEBUG_DEFINE@ @TOOLCHAIN_DEFS@ @TOOLCHAIN_DLL_DEFS@ @WXCONFIG_INCLUDE@ @WX_LARGEFILE_FLAGS@
96     fi
97 }
98
99 if test $# -eq 0; then
100     usage 1 1>&2
101 fi
102
103 while test $# -gt 0; do
104   case "$1" in
105   -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
106   *) optarg= ;;
107   esac
108
109   case $1 in
110     --inplace)
111       prefix=`makeabs $srcdir`
112       exec_prefix=`makeabs $builddir`
113       exec_prefix_set=yes
114       ;;
115     --prefix=*)
116       prefix=$optarg
117       if test $exec_prefix_set = no ; then
118         exec_prefix=$optarg
119       fi
120       ;;
121     --prefix)
122       echo $prefix
123       ;;
124     --exec-prefix=*)
125       exec_prefix=$optarg
126       exec_prefix_set=yes
127       ;;
128     --exec-prefix)
129       echo $exec_prefix
130       ;;
131     --version)
132       echo @WX_MAJOR_VERSION_NUMBER@.@WX_MINOR_VERSION_NUMBER@.@WX_RELEASE_NUMBER@
133       ;;
134     --static)
135       static_flag=yes
136       ;;
137     --cppflags)
138       cppflags
139       ;;
140     --cflags)
141       echo `cppflags` @CODE_GEN_FLAGS@
142       ;;
143     --cxxflags)
144       echo `cppflags` @CODE_GEN_FLAGS@ @CODE_GEN_FLAGS_CXX@
145       ;;
146     --ldflags)
147       echo @LDFLAGS_EXE@
148       ;;
149     --rezflags)
150       echo @MACRESWXCONFIG@
151       ;;
152     --libs)
153       if test "@libdir@" != "/usr/lib" \
154               -a \( "${cross_compiling}" != "yes" \
155                     -o "@libdir@" != "/usr/${target}/lib" \) ;
156       then
157           libs="-L@libdir@"
158       fi
159
160       if test $static_flag = yes ; then
161           echo "$libs @LDFLAGS@ @WXCONFIG_RPATH@ @libdir@/@WXCONFIG_LIBS_STATIC@ @LIBS@ @DMALLOC_LIBS@"
162       else
163           echo $libs @LDFLAGS@ @WXCONFIG_RPATH@ @WXCONFIG_LIBS@ @DMALLOC_LIBS@
164       fi
165
166       ;;
167     --gl-libs)
168       if test $static_flag = yes -a "x" != "x@WXCONFIG_LIBS_STATIC_GL@" ; then
169           gllibs="@libdir@/@WXCONFIG_LIBS_STATIC_GL@"
170       else
171           gllibs="@WXCONFIG_LIBS_GL@"
172       fi
173       echo @LDFLAGS_GL@ $gllibs
174       ;;
175     --cc)
176       echo $CC
177       ;;
178     --cxx)
179       echo $CXX
180       ;;
181     --ld)
182       echo $LD
183       ;;
184     *)
185       usage 1 1>&2
186       ;;
187   esac
188   shift
189 done
190