]> git.sesse.net Git - vlc/blob - vlc-config.in.in
Source files can be in subdirectories
[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   case "$tgt" in
155     *lib*_plugin_la-*.lo)
156       tgt="${tgt#*lib}"
157       tgt="${tgt%_plugin_la-*.lo}"
158       ;;
159     lib*_plugin.la)
160       tgt="${tgt#lib}"
161       tgt="${tgt%_plugin.la}"
162       ;;
163     *)
164       ;;
165   esac
166
167   case "$tgt" in
168     --prefix=*)
169       prefix="${optarg}"
170       if test "${exec_prefix_set}" = no ; then
171         exec_prefix="${optarg}"
172       fi
173       ;;
174     --prefix)
175       echo_prefix=yes
176       ;;
177     --exec-prefix=*)
178       exec_prefix="${optarg}"
179       exec_prefix_set=yes
180       ;;
181     --exec-prefix)
182       echo_exec_prefix=yes
183       ;;
184     --version)
185       echo "@VERSION@"
186       exit 0
187       ;;
188     --linkage)
189       echo_linkage=yes
190       ;;
191     --list)
192       echo_list=yes
193       ;;
194     --cflags)
195       echo_cflags=yes
196       ;;
197     --cppflags)
198       echo_cppflags=yes
199       ;;
200     --cxxflags)
201       echo_cxxflags=yes
202       ;;
203     --objcflags)
204       echo_objcflags=yes
205       ;;
206     --ldflags)
207       echo_ldflags=yes
208       ;;
209     --libs|-libs)
210       echo_libs=yes
211       ;;
212     -*)
213       usage 1 1>&1
214       ;;
215     libvlc)
216       cppflags="${cppflags} -D__LIBVLC__ -I${top_builddir}src/misc"
217       ;;
218     plugin)
219       echo_plugin=yes
220       cppflags="${cppflags} -D__LIBVLC__ -D__PLUGIN__"
221       ;;
222     builtin)
223       echo_builtin=yes
224       cppflags="${cppflags} -D__LIBVLC__ -D__BUILTIN__"
225       ;;
226     pic)
227       ;;
228     mozilla)
229       ;;
230     external)
231       echo_external=yes
232       libs="${libs} -lvlc -lvlc-control"
233       ;;
234     *)
235       module="$tgt"
236       ;;
237   esac
238
239   # Register per-module *FLAGS
240   register_flags "$tgt"
241
242   shift
243 done
244
245 #
246 #  If a module was requested, use its name
247 #
248 if test -n "${module}"; then
249   cppflags="${cppflags} -DMODULE_NAME=${module} -DMODULE_NAME_IS_${module}"
250 fi
251
252 #
253 #  Output what we were asked
254 #
255 if test "${echo_linkage}" = yes; then
256   if test "${echo_plugin}" = yes; then
257     for module in `echo "${plugins}"`; do
258       register_flags "${module}"
259     done
260   fi
261   if test "${echo_builtin}" = yes; then
262     for module in `echo "${builtins}"`; do
263       register_flags "${module}"
264     done
265   fi
266   echo "${linkage}"
267   exit 0
268 fi
269
270 if test "${echo_list}" = yes; then
271   if test "${echo_plugin}" = yes; then
272     echo "${plugins}"
273     printf '\n'
274   fi
275   if test "${echo_builtin}" = yes; then
276     echo "${builtins}"
277     printf '\n'
278   fi
279   exit 0
280 fi
281
282 if test "${echo_prefix}" = yes; then
283   echo "${prefix}"
284 fi
285 if test "${echo_exec_prefix}" = yes; then
286   echo "${exec_prefix}"
287 fi
288 if test "${echo_cppflags}" = yes; then
289   echo "${cppflags}"
290 fi
291 if test "${echo_cflags}" = yes; then
292   echo "${cppflags} ${cflags}"
293 fi
294 if test "${echo_cxxflags}" = yes; then
295   echo "${cppflags} ${cxxflags}"
296 fi
297 if test "${echo_objcflags}" = yes; then
298   echo "${cppflags} ${objcflags}"
299 fi
300 if test "${echo_ldflags}" = yes; then
301   echo "${ldflags}"
302 fi
303
304 # Libs
305 # There are 4 possibilities
306 #  - We are a plugin or a builtin
307 #  - We are building from the outside (external):
308 #       - Give full libvlc linkflags + -lvlc (in libdir)
309 #       - Link with builtins in libdir
310 #  - We are building something from the inside (builtin)
311 #       - Link with builtins in place
312 #  If you want something shared from the inside (binding),
313 #  you need "builtin vlc"
314 if test "${echo_libs}" = yes; then
315   if test "${echo_external}" = yes; then
316     for module in `echo "${builtins}"`; do
317       libs="${libs} @libdir@/vlc/lib${module}.a"
318     done
319     for module in `echo "${builtins}"`; do
320       register_flags "${module}"
321     done
322     register_flags "vlc"
323   fi
324   echo "${libs}"
325 fi