]> git.sesse.net Git - vlc/blob - vlc-config.in.in
Accept libtool archives and libtool objects as well as plugin names
[vlc] / vlc-config.in.in
1 #!/bin/sh
2
3 prefix="@prefix@"
4 exec_prefix="@exec_prefix@"
5 exec_prefix_set=no
6 datarootdir="@datarootdir@"
7
8 release="@release@"
9 debug="@debug@"
10 gprof="@gprof@"
11 cprof="@cprof@"
12 optim="@optim@"
13
14 plugins="@PLUGINS@ "
15 builtins="@BUILTINS@ "
16
17 cppflags=""
18 cflags=""
19 cxxflags=""
20 objcflags=""
21 ldflags=""
22 libs=""
23
24 cflags_tuning="@CFLAGS_TUNING@"
25 cflags_optim_size="@CFLAGS_OPTIM_SIZE@"
26 cflags_optim_speed="@CFLAGS_OPTIM_SPEED@"
27 cflags_optim_nodebug="@CFLAGS_OPTIM_NODEBUG@"
28 cflags_nooptim="@CFLAGS_NOOPTIM@"
29
30 #
31 #  Do not touch below this place unless you really know what you are doing
32 #
33 usage()
34 {
35         cat << BLAH
36 Usage: vlc-config OPTIONS MODULES
37 Options:
38         [--prefix[=DIR]]          set prefix
39         [--exec-prefix[=DIR]]     set exec prefix
40         [--version]               print version and exit
41         [--linkage]               print linkage mode (c, c++, objc)
42         [--target]                print targets and exit
43         [--list]                  print modules names and exit
44         [--libs]                  output linking flags
45         [--cflags]                output C compilation flags
46         [--cxxflags]              output C++ compilation flags
47         [--objcflags]             output Objective C compilation flags
48 Modules:
49         vlc                       the main VLC object
50         plugin                    flags for plugin modules
51         builtin                   flags for built-in modules
52         pic                       flags for PIC code
53         MODULE                    any available module (dummy, gtk, avi, etc.)
54 BLAH
55         exit $1
56 }
57
58 register_flags()
59 {
60   case "$1" in
61     #@1@#
62     *)
63       ;;
64   esac
65 }
66
67 register_targets()
68 {
69   case "$1" in
70     #@2@#
71     *)
72       ;;
73   esac
74 }
75
76 if test $# -eq 0; then
77         usage 1 1>&2
78 fi
79
80 #
81 #  No need to include the default @*FLAGS@ values here because they are
82 #  automatically added when using $(COMPILE), $(CXXCOMPILE) or $(OBJCCOMPILE)
83 #
84 if test "@includedir@" != "/usr/include"; then
85   includes="-I@includedir@"
86 fi
87 if test "${top_builddir}" != ""; then
88   top_builddir="${top_builddir}/"
89 elif test "${TOP_BUILDDIR}" != ""; then
90   top_builddir="${TOP_BUILDDIR}/"
91 fi
92 includes="${includes}"
93 cppflags="${includes}"
94 module=""
95 linkage="c"
96
97 #
98 #  On Linux and Solaris, activate 64-bit off_t (by default under BSD)
99 #
100 cppflags="${cppflags} -D_FILE_OFFSET_BITS=64 -D__USE_UNIX98 -D_LARGEFILE64_SOURCE -D_REENTRANT -D_THREAD_SAFE"
101
102 #
103 #  Various additional defines
104 #
105 if [ "${debug}" = yes ]; then
106   cppflags="${cppflags} -DDEBUG"
107   cflags="${cflags} -g"
108   cxxflags="${cxxflags} -g"
109   objcflags="${objcflags} -g"
110   ldflags="${ldflags} -g"
111 fi
112 if [ "${cprof}" = yes ]; then
113   cppflags="${cppflags} -DCPROF"
114   cflags="${cflags} -finstrument-functions"
115   cxxflags="${cxxflags} -finstrument-functions"
116   objcflags="${objcflags} -finstrument-functions"
117 fi
118 if [ "${gprof}" = yes ]; then
119   cppflags="${cppflags} -DGPROF"
120   cflags="${cflags} -pg"
121   cxxflags="${cxxflags} -pg"
122   objcflags="${objcflags} -pg"
123   ldflags="${ldflags} -pg"
124 fi
125 if [ "${release}" = yes ]; then
126   cppflags="${cppflags} -DHAVE_RELEASE"
127 fi
128 if [ "${optim}" = size ]; then
129   cflags="${cflags} ${cflags_optim_size} ${cflags_tuning}"
130   cxxflags="${cxxflags} ${cflags_optim_size} ${cflags_tuning}"
131   objcflags="${objcflags} ${cflags_optim_size} ${cflags_tuning}"
132   if [ "${debug}" != yes -a "${gprof}" != yes -a "${cprof}" != yes ]; then
133     cflags="${cflags} ${cflags_optim_nodebug}"
134     cxxflags="${cxxflags} ${cflags_optim_nodebug}"
135     objcflags="${objcflags} ${cflags_optim_nodebug}"
136   fi
137 elif [ "${optim}" = speed ]; then
138   cflags="${cflags} ${cflags_optim_speed} ${cflags_tuning}"
139   cxxflags="${cxxflags} ${cflags_optim_speed} ${cflags_tuning}"
140   objcflags="${objcflags} ${cflags_optim_speed} ${cflags_tuning}"
141   if [ "${debug}" != yes -a "${gprof}" != yes -a "${cprof}" != yes ]; then
142     cflags="${cflags} ${cflags_optim_nodebug}"
143     cxxflags="${cxxflags} ${cflags_optim_nodebug}"
144     objcflags="${objcflags} ${cflags_optim_nodebug}"
145   fi
146 else
147   cflags="${cflags} ${cflags_nooptim}"
148   cxxflags="${cxxflags} ${cflags_nooptim}"
149   objcflags="${objcflags} ${cflags_nooptim}"
150 fi
151
152 #
153 #  The main argument loop
154 #
155 while test $# -gt 0; do
156   case "$1" in
157   -*=*) optarg=`echo "$1" | sed 's/-[_a-zA-Z0-9\-]*=//'` ;;
158   *) optarg= ;;
159   esac
160
161   # Mangle plugin name, if applicable
162   # This is just a convenience hack for modules/common.am
163   tgt="$1"
164   case "$tgt" in
165     lib*_plugin_la-*.lo)
166       tgt="${tgt#lib}"
167       tgt="${tgt%_plugin_la-*.lo}"
168       ;;
169     lib*_plugin.la)
170       tgt="${tgt#lib}"
171       tgt="${tgt%_plugin.la}"
172       ;;
173     *)
174       ;;
175   esac
176
177   case "$tgt" in
178     --prefix=*)
179       prefix="${optarg}"
180       if test "${exec_prefix_set}" = no ; then
181         exec_prefix="${optarg}"
182       fi
183       ;;
184     --prefix)
185       echo_prefix=yes
186       ;;
187     --exec-prefix=*)
188       exec_prefix="${optarg}"
189       exec_prefix_set=yes
190       ;;
191     --exec-prefix)
192       echo_exec_prefix=yes
193       ;;
194     --version)
195       echo "@VERSION@"
196       exit 0
197       ;;
198     --linkage)
199       echo_linkage=yes
200       ;;
201     --target)
202       echo_target=yes
203       ;;
204     --list)
205       echo_list=yes
206       ;;
207     --cflags)
208       echo_cflags=yes
209       ;;
210     --cppflags)
211       echo_cppflags=yes
212       ;;
213     --cxxflags)
214       echo_cxxflags=yes
215       ;;
216     --objcflags)
217       echo_objcflags=yes
218       ;;
219     --ldflags)
220       echo_ldflags=yes
221       ;;
222     --libs|-libs)
223       echo_libs=yes
224       ;;
225     -*)
226       usage 1 1>&1
227       ;;
228     libvlc)
229       cppflags="${cppflags} -D__LIBVLC__ -I${top_builddir}src/misc"
230       ;;
231     plugin)
232       echo_plugin=yes
233       cppflags="${cppflags} -D__LIBVLC__ -D__PLUGIN__"
234       ;;
235     builtin)
236       echo_builtin=yes
237       cppflags="${cppflags} -D__LIBVLC__ -D__BUILTIN__"
238       ;;
239     pic)
240       ;;
241     mozilla)
242       ;;
243     external)
244       echo_external=yes
245       libs="${libs} -lvlc -lvlc-control"
246       ;;
247     *)
248       module="$tgt"
249       ;;
250   esac
251
252   # Register per-module *FLAGS
253   register_flags "$tgt"
254
255   # Register module targets
256   register_targets "$tgt"
257
258   shift
259 done
260
261 #
262 #  If a module was requested, use its name
263 #
264 if test -n "${module}"; then
265   cppflags="${cppflags} -DMODULE_NAME=${module} -DMODULE_NAME_IS_${module}"
266 fi
267
268 #
269 #  Output what we were asked
270 #
271 if test "${echo_linkage}" = yes; then
272   if test "${echo_plugin}" = yes; then
273     for module in `echo "${plugins}"`; do
274       register_flags "${module}"
275     done
276   fi
277   if test "${echo_builtin}" = yes; then
278     for module in `echo "${builtins}"`; do
279       register_flags "${module}"
280     done
281   fi
282   echo "${linkage}"
283   exit 0
284 fi
285
286 if test "${echo_target}" = yes; then
287   if test "${echo_plugin}" = yes; then
288     for module in `echo "${plugins}"`; do
289       register_targets "${module}"
290     done
291     for target in `echo "${list}"`; do printf "${top_builddir}modules/${target}_plugin "; done
292     printf '\n'
293   fi
294   if test "${echo_builtin}" = yes; then
295     for module in `echo "${builtins}"`; do
296       register_targets "${module}"
297     done
298     for target in `echo "${list}"`; do printf "${top_builddir}modules/${target}.a "; done
299     printf '\n'
300   fi
301   exit 0
302 fi
303
304 if test "${echo_list}" = yes; then
305   if test "${echo_plugin}" = yes; then
306     echo "${plugins}"
307     printf '\n'
308   fi
309   if test "${echo_builtin}" = yes; then
310     echo "${builtins}"
311     printf '\n'
312   fi
313   exit 0
314 fi
315
316 if test "${echo_prefix}" = yes; then
317   echo "${prefix}"
318 fi
319 if test "${echo_exec_prefix}" = yes; then
320   echo "${exec_prefix}"
321 fi
322 if test "${echo_cppflags}" = yes; then
323   echo "${cppflags}"
324 fi
325 if test "${echo_cflags}" = yes; then
326   echo "${cppflags} ${cflags}"
327 fi
328 if test "${echo_cxxflags}" = yes; then
329   echo "${cppflags} ${cxxflags}"
330 fi
331 if test "${echo_objcflags}" = yes; then
332   echo "${cppflags} ${objcflags}"
333 fi
334 if test "${echo_ldflags}" = yes; then
335   echo "${ldflags}"
336 fi
337
338 # Libs
339 # There are 4 possibilities
340 #  - We are a plugin or a builtin
341 #  - We are building from the outside (external):
342 #       - Give full libvlc linkflags + -lvlc (in libdir)
343 #       - Link with builtins in libdir
344 #  - We are building something from the inside (builtin)
345 #       - Link with builtins in place
346 #  If you want something shared from the inside (binding),
347 #  you need "builtin vlc"
348 if test "${echo_libs}" = yes; then
349   if test "${echo_builtin}" = yes; then
350     for module in `echo "${builtins}"`; do
351       register_targets "${module}"
352       register_flags "${module}"
353     done
354     for target in `echo "${list}"`; do printf "${top_builddir}modules/${target}.a "; done
355   fi
356   if test "${echo_external}" = yes; then
357     for module in `echo "${builtins}"`; do
358       libs="${libs} @libdir@/vlc/lib${module}.a"
359     done
360     for module in `echo "${builtins}"`; do
361       register_flags "${module}"
362     done
363     register_flags "vlc"
364   fi
365   echo "${libs}"
366 fi