]> git.sesse.net Git - vlc/blob - vlc-config.in.in
vlc-config: Add a specific flag for libs, and remove werror there.
[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 cflags_werror="@CFLAGS_WERROR@"
31
32 #
33 #  Do not touch below this place unless you really know what you are doing
34 #
35 usage()
36 {
37         cat << BLAH
38 Usage: vlc-config OPTIONS MODULES
39 Options:
40         [--prefix[=DIR]]          set prefix
41         [--exec-prefix[=DIR]]     set exec prefix
42         [--version]               print version and exit
43         [--linkage]               print linkage mode (c, c++, objc)
44         [--list]                  print modules names and exit
45         [--libs]                  output linking flags
46         [--cflags]                output C compilation flags
47         [--cxxflags]              output C++ compilation flags
48         [--objcflags]             output Objective C compilation flags
49 Modules:
50         vlc                       the main VLC object
51         plugin                    flags for plugin modules
52         builtin                   flags for built-in modules
53         pic                       flags for PIC code
54         MODULE                    any available module (dummy, gtk, avi, etc.)
55         libs                      flags for external libs
56 BLAH
57         exit $1
58 }
59
60 register_flags()
61 {
62   case "$1" in
63     #@1@#
64     *)
65       ;;
66   esac
67 }
68
69 if test $# -eq 0; then
70         usage 1 1>&2
71 fi
72
73 #
74 #  No need to include the default @*FLAGS@ values here because they are
75 #  automatically added when using $(COMPILE), $(CXXCOMPILE) or $(OBJCCOMPILE)
76 #
77 if test "@includedir@" != "/usr/include"; then
78   includes="-I@includedir@"
79 fi
80 if test "${top_builddir}" != ""; then
81   top_builddir="${top_builddir}/"
82 elif test "${TOP_BUILDDIR}" != ""; then
83   top_builddir="${TOP_BUILDDIR}/"
84 fi
85 includes="${includes}"
86 cppflags="${includes}"
87 module=""
88 linkage="c"
89
90 #
91 #  On Linux and Solaris, activate 64-bit off_t (by default under BSD)
92 #
93 cppflags="${cppflags} -D_FILE_OFFSET_BITS=64 -D__USE_UNIX98 -D_LARGEFILE64_SOURCE -D_REENTRANT -D_THREAD_SAFE"
94
95 #
96 #  Various additional defines
97 #
98 if [ "${debug}" = yes ]; then
99   cppflags="${cppflags} -DDEBUG"
100   cflags="${cflags} -g"
101   cxxflags="${cxxflags} -g"
102   objcflags="${objcflags} -g"
103   ldflags="${ldflags} -g"
104 fi
105 if [ "${cprof}" = yes ]; then
106   cppflags="${cppflags} -DCPROF"
107   cflags="${cflags} -finstrument-functions"
108   cxxflags="${cxxflags} -finstrument-functions"
109   objcflags="${objcflags} -finstrument-functions"
110 fi
111 if [ "${gprof}" = yes ]; then
112   cppflags="${cppflags} -DGPROF"
113   cflags="${cflags} -pg"
114   cxxflags="${cxxflags} -pg"
115   objcflags="${objcflags} -pg"
116   ldflags="${ldflags} -pg"
117 fi
118 if [ "${release}" = yes ]; then
119   cppflags="${cppflags} -DHAVE_RELEASE"
120 fi
121 if [ "${optim}" = size ]; then
122   cflags="${cflags} ${cflags_optim_size} ${cflags_tuning}"
123   cxxflags="${cxxflags} ${cflags_optim_size} ${cflags_tuning}"
124   objcflags="${objcflags} ${cflags_optim_size} ${cflags_tuning}"
125   if [ "${debug}" != yes -a "${gprof}" != yes -a "${cprof}" != yes ]; then
126     cflags="${cflags} ${cflags_optim_nodebug}"
127     cxxflags="${cxxflags} ${cflags_optim_nodebug}"
128     objcflags="${objcflags} ${cflags_optim_nodebug}"
129   fi
130 elif [ "${optim}" = speed ]; then
131   cflags="${cflags} ${cflags_optim_speed} ${cflags_tuning}"
132   cxxflags="${cxxflags} ${cflags_optim_speed} ${cflags_tuning}"
133   objcflags="${objcflags} ${cflags_optim_speed} ${cflags_tuning}"
134   if [ "${debug}" != yes -a "${gprof}" != yes -a "${cprof}" != yes ]; then
135     cflags="${cflags} ${cflags_optim_nodebug}"
136     cxxflags="${cxxflags} ${cflags_optim_nodebug}"
137     objcflags="${objcflags} ${cflags_optim_nodebug}"
138   fi
139 else
140   cflags="${cflags} ${cflags_nooptim}"
141   cxxflags="${cxxflags} ${cflags_nooptim}"
142   objcflags="${objcflags} ${cflags_nooptim}"
143 fi
144
145 #
146 #  The main argument loop
147 #
148 while test $# -gt 0; do
149   case "$1" in
150   -*=*) optarg=`echo "$1" | sed 's/-[_a-zA-Z0-9\-]*=//'` ;;
151   *) optarg= ;;
152   esac
153
154   # Mangle plugin name, if applicable
155   # This is just a convenience hack for modules/common.am
156   tgt="$1"
157   tgt="${tgt##*/}"
158   case "$tgt" in
159     lib*_plugin_la-*.lo)
160       tgt="${tgt#*lib}"
161       tgt="${tgt%_plugin_la-*.lo}"
162       ;;
163     lib*_plugin.la)
164       tgt="${tgt#lib}"
165       tgt="${tgt%_plugin.la}"
166       ;;
167     *)
168       ;;
169   esac
170
171   case "$tgt" in
172     --prefix=*)
173       prefix="${optarg}"
174       if test "${exec_prefix_set}" = no ; then
175         exec_prefix="${optarg}"
176       fi
177       ;;
178     --prefix)
179       echo_prefix=yes
180       ;;
181     --exec-prefix=*)
182       exec_prefix="${optarg}"
183       exec_prefix_set=yes
184       ;;
185     --exec-prefix)
186       echo_exec_prefix=yes
187       ;;
188     --version)
189       echo "@VERSION@"
190       exit 0
191       ;;
192     --linkage)
193       echo_linkage=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     libvlccore)
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     libs)
231       # Avoid to use werror on what is not vlc's code.
232       cflags_werror=""
233       ;;
234     pic)
235       ;;
236     mozilla)
237       ;;
238     *)
239       module="$tgt"
240       ;;
241   esac
242
243   # Register per-module *FLAGS
244   register_flags "$tgt"
245
246   shift
247 done
248
249 #
250 #  If a module was requested, use its name
251 #
252 if test -n "${module}"; then
253   cppflags="${cppflags} -DMODULE_NAME=${module} -DMODULE_NAME_IS_${module} -DMODULE_STRING=\"${module}\""
254 fi
255
256 #
257 # Set the Werror flags.
258 #
259
260 cflags="${cflags} ${cflags_werror}"
261
262 #
263 #  Output what we were asked
264 #
265 if test "${echo_linkage}" = yes; then
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 something from the inside (builtin)
308 #       - Link with builtins in place
309 #  If you want something shared from the inside (binding),
310 #  you need "builtin vlc"
311 if test "${echo_libs}" = yes; then
312   echo "${libs}"
313 fi