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