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