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