dbus: Rework the main loop
[vlc.git] / vlc-config.in.in
1 #!@SHELL@
2
3 prefix="@prefix@"
4 exec_prefix="@exec_prefix@"
5 exec_prefix_set=no
6 datarootdir="@datarootdir@"
7
8 debug="@debug@"
9 gprof="@gprof@"
10 cprof="@cprof@"
11 optim="@optim@"
12
13 plugins="@PLUGINS@ "
14 builtins="@BUILTINS@ "
15
16 cppflags=""
17 cflags=""
18 cxxflags=""
19 objcflags=""
20 ldflags=""
21 libs=""
22
23 cflags_tuning="@CFLAGS_TUNING@"
24 cflags_optim_size="@CFLAGS_OPTIM_SIZE@"
25 cflags_optim_speed="@CFLAGS_OPTIM_SPEED@"
26 cflags_optim_nodebug="@CFLAGS_OPTIM_NODEBUG@"
27 cflags_nooptim="@CFLAGS_NOOPTIM@"
28
29 #
30 #  Do not touch below this place unless you really know what you are doing
31 #
32 usage()
33 {
34         cat << BLAH
35 Usage: vlc-config OPTIONS MODULES
36 Options:
37         [--prefix[=DIR]]          set prefix
38         [--exec-prefix[=DIR]]     set exec prefix
39         [--version]               print version and exit
40         [--linkage]               print linkage mode (c, c++, objc)
41         [--list]                  print modules names and exit
42         [--libs]                  output linking flags
43         [--cflags]                output C compilation flags
44         [--cxxflags]              output C++ compilation flags
45         [--objcflags]             output Objective C compilation flags
46 Modules:
47         vlc                       the main VLC object
48         plugin                    flags for plugin modules
49         builtin                   flags for built-in modules
50         pic                       flags for PIC code
51         MODULE                    any available module (dummy, gtk, avi, etc.)
52         libs                      flags for external libs
53 BLAH
54         exit $1
55 }
56
57 register_flags()
58 {
59   case "$1" in
60     #@1@#
61     *)
62       ;;
63   esac
64 }
65
66 if test $# -eq 0; then
67         usage 1 1>&2
68 fi
69
70 if test "${top_builddir}" != ""; then
71   top_builddir="${top_builddir}/"
72 elif test "${TOP_BUILDDIR}" != ""; then
73   top_builddir="${TOP_BUILDDIR}/"
74 fi
75 includes="${includes}"
76 cppflags="${includes}"
77 module=""
78 linkage="c"
79
80 #
81 #  On Linux and Solaris, activate 64-bit off_t (by default under BSD)
82 #
83 cppflags="${cppflags} -D_FILE_OFFSET_BITS=64 -D__USE_UNIX98 -D_REENTRANT -D_THREAD_SAFE"
84
85 #
86 #  Various additional defines
87 #
88 if [ "${debug}" = yes ]; then
89   cflags="${cflags} -g"
90   cxxflags="${cxxflags} -g"
91   objcflags="${objcflags} -g"
92   ldflags="${ldflags} -g"
93 fi
94 if [ "${cprof}" = yes ]; then
95   cflags="${cflags} -finstrument-functions"
96   cxxflags="${cxxflags} -finstrument-functions"
97   objcflags="${objcflags} -finstrument-functions"
98 fi
99 if [ "${gprof}" = yes ]; then
100   cflags="${cflags} -pg"
101   cxxflags="${cxxflags} -pg"
102   objcflags="${objcflags} -pg"
103   ldflags="${ldflags} -pg"
104 fi
105 if [ "${optim}" = size ]; then
106   cflags="${cflags} ${cflags_optim_size} ${cflags_tuning}"
107   cxxflags="${cxxflags} ${cflags_optim_size} ${cflags_tuning}"
108   objcflags="${objcflags} ${cflags_optim_size} ${cflags_tuning}"
109   if [ "${debug}" != yes -a "${gprof}" != yes -a "${cprof}" != yes ]; then
110     cflags="${cflags} ${cflags_optim_nodebug}"
111     cxxflags="${cxxflags} ${cflags_optim_nodebug}"
112     objcflags="${objcflags} ${cflags_optim_nodebug}"
113   fi
114 elif [ "${optim}" = speed ]; then
115   cflags="${cflags} ${cflags_optim_speed} ${cflags_tuning}"
116   cxxflags="${cxxflags} ${cflags_optim_speed} ${cflags_tuning}"
117   objcflags="${objcflags} ${cflags_optim_speed} ${cflags_tuning}"
118   if [ "${debug}" != yes -a "${gprof}" != yes -a "${cprof}" != yes ]; then
119     cflags="${cflags} ${cflags_optim_nodebug}"
120     cxxflags="${cxxflags} ${cflags_optim_nodebug}"
121     objcflags="${objcflags} ${cflags_optim_nodebug}"
122   fi
123 else
124   cflags="${cflags} ${cflags_nooptim}"
125   cxxflags="${cxxflags} ${cflags_nooptim}"
126   objcflags="${objcflags} ${cflags_nooptim}"
127 fi
128
129 #
130 #  The main argument loop
131 #
132 while test $# -gt 0; do
133   case "$1" in
134   -*=*) optarg=`echo "$1" | sed 's/-[_a-zA-Z0-9\-]*=//'` ;;
135   *) optarg= ;;
136   esac
137
138   # Mangle plugin name, if applicable
139   # This is just a convenience hack for modules/common.am
140   tgt="$1"
141   tgt="${tgt##*/}"
142   case "$tgt" in
143     lib*_plugin_la-*.lo)
144       tgt="${tgt#*lib}"
145       tgt="${tgt%_plugin_la-*.lo}"
146       ;;
147     lib*_plugin.la)
148       tgt="${tgt#lib}"
149       tgt="${tgt%_plugin.la}"
150       ;;
151     *)
152       ;;
153   esac
154
155   case "$tgt" in
156     --prefix=*)
157       prefix="${optarg}"
158       if test "${exec_prefix_set}" = no ; then
159         exec_prefix="${optarg}"
160       fi
161       ;;
162     --prefix)
163       echo_prefix=yes
164       ;;
165     --exec-prefix=*)
166       exec_prefix="${optarg}"
167       exec_prefix_set=yes
168       ;;
169     --exec-prefix)
170       echo_exec_prefix=yes
171       ;;
172     --version)
173       echo "@VERSION@"
174       exit 0
175       ;;
176     --linkage)
177       echo_linkage=yes
178       ;;
179     --list)
180       echo_list=yes
181       ;;
182     --cflags)
183       echo_cflags=yes
184       ;;
185     --cppflags)
186       echo_cppflags=yes
187       ;;
188     --cxxflags)
189       echo_cxxflags=yes
190       ;;
191     --objcflags)
192       echo_objcflags=yes
193       ;;
194     --ldflags)
195       echo_ldflags=yes
196       ;;
197     --libs|-libs)
198       echo_libs=yes
199       ;;
200     -*)
201       usage 1 1>&1
202       ;;
203     libvlccore)
204       cppflags="${cppflags} -D__LIBVLC__ -I${top_builddir}src/misc"
205       ;;
206     plugin)
207       echo_plugin=yes
208       cppflags="${cppflags} -D__LIBVLC__ -D__PLUGIN__"
209       ;;
210     builtin)
211       echo_builtin=yes
212       cppflags="${cppflags} -D__LIBVLC__ -D__BUILTIN__"
213       ;;
214     pic)
215       ;;
216     *)
217       module="$tgt"
218       ;;
219   esac
220
221   # Register per-module *FLAGS
222   register_flags "$tgt"
223
224   shift
225 done
226
227 #
228 #  If a module was requested, use its name
229 #
230 if test -n "${module}"; then
231   cppflags="${cppflags} -DMODULE_NAME=${module} -DMODULE_NAME_IS_${module} -DMODULE_STRING=\"${module}\""
232 fi
233
234 #
235 #  Output what we were asked
236 #
237 if test "${echo_linkage}" = yes; then
238   echo "${linkage}"
239   exit 0
240 fi
241
242 if test "${echo_list}" = yes; then
243   if test "${echo_plugin}" = yes; then
244     echo "${plugins}"
245     printf '\n'
246   fi
247   if test "${echo_builtin}" = yes; then
248     echo "${builtins}"
249     printf '\n'
250   fi
251   exit 0
252 fi
253
254 if test "${echo_prefix}" = yes; then
255   echo "${prefix}"
256 fi
257 if test "${echo_exec_prefix}" = yes; then
258   echo "${exec_prefix}"
259 fi
260 if test "${echo_cppflags}" = yes; then
261   echo "${cppflags}"
262 fi
263 if test "${echo_cflags}" = yes; then
264   echo "${cppflags} ${cflags}"
265 fi
266 if test "${echo_cxxflags}" = yes; then
267   echo "${cppflags} ${cxxflags}"
268 fi
269 if test "${echo_objcflags}" = yes; then
270   echo "${cppflags} ${objcflags}"
271 fi
272 if test "${echo_ldflags}" = yes; then
273   echo "${ldflags}"
274 fi
275
276 # Libs
277 # There are 4 possibilities
278 #  - We are a plugin or a builtin
279 #  - We are building something from the inside (builtin)
280 #       - Link with builtins in place
281 #  If you want something shared from the inside (binding),
282 #  you need "builtin vlc"
283 if test "${echo_libs}" = yes; then
284   echo "${libs}"
285 fi