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