]> git.sesse.net Git - vlc/blob - vlc-config.in.in
Unbreak make vlc from subdir
[vlc] / vlc-config.in.in
1 #!/bin/sh
2
3 prefix="@prefix@"
4 exec_prefix="@exec_prefix@"
5 exec_prefix_set=no
6
7 release="@release@"
8 debug="@debug@"
9 gprof="@gprof@"
10 cprof="@cprof@"
11 optim="@optim@"
12
13 plugins="@PLUGINS@"
14 builtins="@BUILTINS@"
15
16 cppflags=""
17 cflags=""
18 cxxflags=""
19 objcflags=""
20 ldflags=""
21
22 cflags_tuning="@CFLAGS_TUNING@"
23 cflags_optim="@CFLAGS_OPTIM@"
24 cflags_optim_nodebug="@CFLAGS_OPTIM_NODEBUG@"
25 cflags_nooptim="@CFLAGS_NOOPTIM@"
26
27 #
28 #  Do not touch below this place unless you really know what you are doing
29 #
30 usage()
31 {
32         cat << BLAH
33 Usage: vlc-config OPTIONS MODULES
34 Options:
35         [--prefix[=DIR]]          set prefix
36         [--exec-prefix[=DIR]]     set exec prefix
37         [--version]               print version and exit
38         [--linkage]               print linkage mode (c, c++, objc)
39         [--target]                print targets and exit
40         [--libs]                  output linking flags
41         [--cflags]                output C compilation flags
42         [--cxxflags]              output C++ compilation flags
43         [--objcflags]             output Objective C compilation flags
44 Modules:
45         vlc                       the main VLC object
46         plugin                    flags for plugin modules
47         builtin                   flags for built-in modules
48         pic                       flags for PIC code
49         MODULE                    any available module (dummy, gtk, avi, etc.)
50 BLAH
51         exit $1
52 }
53
54 register_flags()
55 {
56   case "$1" in
57     #@1@#
58     *)
59       ;;
60   esac
61 }
62
63 register_targets()
64 {
65   case "$1" in
66     #@2@#
67     *)
68       ;;
69   esac
70 }
71
72 if test $# -eq 0; then
73         usage 1 1>&2
74 fi
75
76 #
77 #  No need to include the default @*FLAGS@ values here because they are
78 #  automatically added when using $(COMPILE), $(CXXCOMPILE) or $(OBJCCOMPILE)
79 #
80 if test "@includedir@" != "/usr/include"; then
81   includes="-I@includedir@"
82 fi
83 if test "${top_builddir}" != ""; then
84   top_builddir="${top_builddir}/"
85 fi
86 includes="${includes} -I${top_builddir}include"
87 cppflags="${includes}"
88 libs="-L@libdir@"
89 module=""
90 linkage="c"
91
92 #
93 #  On Linux and Solaris, activate 64-bit off_t (by default under BSD)
94 #
95 cppflags="${cppflags} -D_FILE_OFFSET_BITS=64 -D__USE_UNIX98 -D_LARGEFILE64_SOURCE -D_REENTRANT -D_THREAD_SAFE -D_GNU_SOURCE"
96
97 #
98 #  Gettext, data and plugin location
99 #
100 cppflags="${cppflags} -DLOCALEDIR=\"@datadir@/locale\""
101 cppflags="${cppflags} -DDATA_PATH=\"${prefix}/share/vlc\""
102 cppflags="${cppflags} -DPLUGIN_PATH=\"${prefix}/lib/vlc\""
103
104 #
105 #  Various additional defines
106 #
107 if [ "${debug}" = yes ]; then
108   cppflags="${cppflags} -DDEBUG"
109   cflags="${cflags} -g"
110   cxxflags="${cxxflags} -g"
111   objcflags="${objcflags} -g"
112   ldflags="${ldflags} -g"
113 fi
114 if [ "${cprof}" = yes ]; then
115   cppflags="${cppflags} -DCPROF"
116   cflags="${cflags} -finstrument-functions"
117   cxxflags="${cxxflags} -finstrument-functions"
118   objcflags="${objcflags} -finstrument-functions"
119 fi
120 if [ "${gprof}" = yes ]; then
121   cppflags="${cppflags} -DGPROF"
122   cflags="${cflags} -pg"
123   cxxflags="${cxxflags} -pg"
124   objcflags="${objcflags} -pg"
125   ldflags="${ldflags} -pg"
126 fi
127 if [ "${release}" = yes ]; then
128   cppflags="${cppflags} -DHAVE_RELEASE"
129 fi
130 if [ "${optim}" = yes ]; then
131   cppflags="${cppflags} ${cflags_optim} ${cflags_tuning}"
132   if [ "${debug}" != yes -a "${gprof}" != yes -a "${cprof}" != yes ]; then
133     cppflags="${cppflags} ${cflags_optim_nodebug}"
134   fi
135 else
136   cppflags="${cppflags} ${cflags_nooptim}"
137 fi
138
139 #
140 #  The main argument loop
141 #
142 while test $# -gt 0; do
143   case "$1" in
144   -*=*) optarg=`echo "$1" | sed 's/-_a-zA-Z0-9*=//'` ;;
145   *) optarg= ;;
146   esac
147
148   case "$1" in
149     --prefix=*)
150       prefix="${optarg}"
151       if test "${exec_prefix_set}" = no ; then
152         exec_prefix="${optarg}"
153       fi
154       ;;
155     --prefix)
156       echo_prefix=yes
157       ;;
158     --exec-prefix=*)
159       exec_prefix="${optarg}"
160       exec_prefix_set=yes
161       ;;
162     --exec-prefix)
163       echo_exec_prefix=yes
164       ;;
165     --version)
166       echo "@VERSION@"
167       exit 0
168       ;;
169     --linkage)
170       echo_linkage=yes
171       ;;
172     --target)
173       echo_target=yes
174       ;;
175     --cflags)
176       echo_cflags=yes
177       ;;
178     --cxxflags)
179       echo_cxxflags=yes
180       ;;
181     --objcflags)
182       echo_objcflags=yes
183       ;;
184     --libs)
185       echo_libs=yes
186       ;;
187     -*)
188       usage 1 1>&1
189       ;;
190     vlc)
191       cppflags="${cppflags} -D__VLC__ -I${top_builddir}src/misc"
192       ;;
193     plugin)
194       echo_plugin=yes
195       cppflags="${cppflags} -D__VLC__ -D__PLUGIN__"
196       ;;
197     pic)
198       echo_pic=yes
199       ;;
200     builtin)
201       echo_builtin=yes
202       cppflags="${cppflags} -D__VLC__ -D__BUILTIN__"
203       ;;
204     mozilla)
205       ;;
206     external)
207       echo_external=yes
208       ldflags="${ldflags} -lvlc"
209       ;;      
210     *)
211       module="$1"
212       ;;
213   esac
214
215   # Register per-module *FLAGS
216   register_flags "$1"
217
218   # Register module targets
219   register_targets "$1"
220
221   shift
222 done
223
224 #
225 #  If a module was requested, use its name
226 #
227 if test -n "${module}"; then
228   cppflags="${cppflags} -DMODULE_NAME=${module} -DMODULE_NAME_IS_${module}"
229 fi
230
231 #
232 #  Output what we were asked
233 #
234 if test "${echo_linkage}" = yes; then
235   if test "${echo_plugin}" = yes; then
236     for module in `echo "${plugins}"`; do
237       register_flags "${module}"
238     done
239   fi
240   if test "${echo_builtin}" = yes; then
241     for module in `echo "${builtins}"`; do
242       register_flags "${module}"
243     done
244   fi
245   echo "${linkage}"
246   exit 0
247 fi
248
249 if test "${echo_target}" = yes; then
250   if test "${echo_plugin}" = yes; then
251     for module in `echo "${plugins}"`; do
252       register_targets "${module}"
253     done
254     for target in `echo "${list}"`; do printf "${top_builddir}modules/${target}_plugin "; done
255     printf '\n'
256   fi
257   if test "${echo_builtin}" = yes; then
258     for module in `echo "${builtins}"`; do
259       register_targets "${module}"
260     done
261     if test "${echo_pic}" = yes; then
262       for target in `echo "${list}"`; do printf "${top_builddir}modules/${target}_pic.a "; done
263     else
264       for target in `echo "${list}"`; do printf "${top_builddir}modules/${target}.a "; done
265     fi
266     printf '\n'
267   fi
268   exit 0
269 fi
270
271 if test "${echo_prefix}" = yes; then
272   echo "${prefix}"
273 fi
274 if test "${echo_exec_prefix}" = yes; then
275   echo "${exec_prefix}"
276 fi
277 if test "${echo_cppflags}" = yes; then
278   echo "${cppflags}"
279 fi
280 if test "${echo_cflags}" = yes; then
281   echo "${cppflags} ${cflags}"
282 fi
283 if test "${echo_cxxflags}" = yes; then
284   echo "${cppflags} ${cxxflags}"
285 fi
286 if test "${echo_objcflags}" = yes; then
287   echo "${cppflags} ${objcflags}"
288 fi
289 if test "${echo_libs}" = yes; then
290   if test "${echo_builtin}" = yes; then
291     for module in `echo "${builtins}"`; do
292       register_targets "${module}"
293       register_flags "${module}"
294     done
295     if test "${echo_pic}" = yes; then
296       for target in `echo "${list}"`; do printf "${top_builddir}modules/${target}_pic.a "; done
297     else
298       for target in `echo "${list}"`; do printf "${top_builddir}modules/${target}.a "; done
299     fi
300   fi
301   if test "${echo_external}" = yes; then
302     if test "${echo_pic}" = yes; then
303       for module in `echo "${builtins}"`; do
304         ldflags="${ldflags} @libdir@/vlc/lib${module}_pic.a"
305       done
306     else
307       for module in `echo "${builtins}"`; do
308         ldflags="${ldflags} @libdir@/vlc/lib${module}.a"
309       done
310     fi
311     for module in `echo "${builtins}"`; do
312       register_flags "${module}"
313     done
314     register_flags "vlc"
315   fi
316   echo "${libs} ${ldflags}"
317 fi