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