]> git.sesse.net Git - vlc/blob - vlc-config.in.in
vlc-config: fixed optimizations by splitting CFLAGS_OPTIM into CFLAGS_OPTIM_SIZE...
[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     --libs)
197       echo_libs=yes
198       ;;
199     -*)
200       usage 1 1>&1
201       ;;
202     libvlc)
203       cppflags="${cppflags} -D__LIBVLC__ -I${top_builddir}src/misc"
204       ;;
205     plugin)
206       echo_plugin=yes
207       cppflags="${cppflags} -D__LIBVLC__ -D__PLUGIN__"
208       ;;
209     builtin)
210       echo_builtin=yes
211       cppflags="${cppflags} -D__LIBVLC__ -D__BUILTIN__"
212       ;;
213     pic)
214       ;;
215     mozilla)
216       ;;
217     external)
218       echo_external=yes
219       ldflags="${ldflags} -lvlc -lvlc-control"
220       ;;      
221     *)
222       module="$1"
223       ;;
224   esac
225
226   # Register per-module *FLAGS
227   register_flags "$1"
228
229   # Register module targets
230   register_targets "$1"
231
232   shift
233 done
234
235 libs="-L@libdir@"
236
237 #
238 #  If a module was requested, use its name
239 #
240 if test -n "${module}"; then
241   cppflags="${cppflags} -DMODULE_NAME=${module} -DMODULE_NAME_IS_${module}"
242 fi
243
244 #
245 #  Output what we were asked
246 #
247 if test "${echo_linkage}" = yes; then
248   if test "${echo_plugin}" = yes; then
249     for module in `echo "${plugins}"`; do
250       register_flags "${module}"
251     done
252   fi
253   if test "${echo_builtin}" = yes; then
254     for module in `echo "${builtins}"`; do
255       register_flags "${module}"
256     done
257   fi
258   echo "${linkage}"
259   exit 0
260 fi
261
262 if test "${echo_target}" = yes; then
263   if test "${echo_plugin}" = yes; then
264     for module in `echo "${plugins}"`; do
265       register_targets "${module}"
266     done
267     for target in `echo "${list}"`; do printf "${top_builddir}modules/${target}_plugin "; done
268     printf '\n'
269   fi
270   if test "${echo_builtin}" = yes; then
271     for module in `echo "${builtins}"`; do
272       register_targets "${module}"
273     done
274     for target in `echo "${list}"`; do printf "${top_builddir}modules/${target}.a "; done
275     printf '\n'
276   fi
277   exit 0
278 fi
279
280 if test "${echo_list}" = yes; then
281   if test "${echo_plugin}" = yes; then
282     echo "${plugins}"
283     printf '\n'
284   fi
285   if test "${echo_builtin}" = yes; then
286     echo "${builtins}"
287     printf '\n'
288   fi
289   exit 0
290 fi
291
292 if test "${echo_prefix}" = yes; then
293   echo "${prefix}"
294 fi
295 if test "${echo_exec_prefix}" = yes; then
296   echo "${exec_prefix}"
297 fi
298 if test "${echo_cppflags}" = yes; then
299   echo "${cppflags}"
300 fi
301 if test "${echo_cflags}" = yes; then
302   echo "${cppflags} ${cflags}"
303 fi
304 if test "${echo_cxxflags}" = yes; then
305   echo "${cppflags} ${cxxflags}"
306 fi
307 if test "${echo_objcflags}" = yes; then
308   echo "${cppflags} ${objcflags}"
309 fi
310
311 # Libs
312 # There are 4 possibilities
313 #  - We are a plugin or a builtin
314 #  - We are building from the outside (external):
315 #       - Give full libvlc linkflags + -lvlc (in libdir)
316 #       - Link with builtins in libdir
317 #  - We are building something from the inside (builtin)
318 #       - Link with builtins in place
319 #  If you want something shared from the inside (binding),
320 #  you need "builtin vlc"
321 if test "${echo_libs}" = yes; then
322   if test "${echo_builtin}" = yes; then
323     for module in `echo "${builtins}"`; do
324       register_targets "${module}"
325       register_flags "${module}"
326     done
327     for target in `echo "${list}"`; do printf "${top_builddir}modules/${target}.a "; done
328   fi
329   if test "${echo_external}" = yes; then
330     for module in `echo "${builtins}"`; do
331       ldflags="${ldflags} @libdir@/vlc/lib${module}.a"
332     done
333     for module in `echo "${builtins}"`; do
334       register_flags "${module}"
335     done
336     register_flags "vlc"
337   fi
338   echo "${libs} ${ldflags}"
339 fi