]> git.sesse.net Git - vlc/blob - vlc-config.in.in
* debian/changelog:
[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="${cppflags} -DDEBUG"
17 cflags="${cflags} -g"
18 cxxflags="${cxxflags} -g"
19 objcflags="${objcflags} -g"
20 ldflags="${objcflags} -g"
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 cppflags="${includes}"
84 libs="-L@libdir@"
85 module=""
86 linkage="c"
87
88 #
89 #  On Linux and Solaris, activate 64-bit off_t (by default under BSD)
90 #
91 cppflags="${cppflags} -D_FILE_OFFSET_BITS=64 -D__USE_UNIX98 -D_LARGEFILE64_SOURCE -D_REENTRANT -D_THREAD_SAFE -D_GNU_SOURCE"
92
93 #
94 #  Gettext, data and plugin location
95 #
96 cppflags="${cppflags} -DLOCALEDIR=\"@datadir@/locale\""
97 cppflags="${cppflags} -DDATA_PATH=\"${prefix}/share/vlc\""
98 cppflags="${cppflags} -DPLUGIN_PATH=\"${prefix}/lib/vlc\""
99
100 #
101 #  Various additional defines
102 #
103 if [ "${debug}" = yes ]; then
104   cppflags="${cppflags} -DDEBUG"
105   cflags="${cflags} -g"
106   cxxflags="${cxxflags} -g"
107   objcflags="${objcflags} -g"
108   ldflags="${objcflags} -g"
109 fi
110 if [ "${cprof}" = yes ]; then
111   cppflags="${cppflags} -DCPROF"
112   cflags="${cflags} -finstrument-functions"
113   cxxflags="${cxxflags} -finstrument-functions"
114   objcflags="${objcflags} -finstrument-functions"
115 fi
116 if [ "${gprof}" = yes ]; then
117   cppflags="${cppflags} -DGPROF"
118   cflags="${cflags} -pg"
119   cxxflags="${cxxflags} -pg"
120   objcflags="${objcflags} -pg"
121   ldflags="${ldflags} -pg"
122 fi
123 if [ "${release}" = yes ]; then
124   cppflags="${cppflags} -DHAVE_RELEASE"
125 fi
126 if [ "${optim}" = yes ]; then
127   cppflags="${cppflags} ${cflags_optim} ${cflags_tuning}"
128   if [ "${debug}" != yes -a "${gprof}" != yes -a "${cprof}" != yes ]; then
129     cppflags="${cppflags} ${cflags_optim_nodebug}"
130   fi
131 else
132   cppflags="${cppflags} ${cflags_nooptim}"
133 fi
134
135 #
136 #  The main argument loop
137 #
138 while test $# -gt 0; do
139   case "$1" in
140   -*=*) optarg=`echo "$1" | sed 's/-_a-zA-Z0-9*=//'` ;;
141   *) optarg= ;;
142   esac
143
144   case "$1" in
145     --prefix=*)
146       prefix="${optarg}"
147       if test "${exec_prefix_set}" = no ; then
148         exec_prefix="${optarg}"
149       fi
150       ;;
151     --prefix)
152       echo_prefix=yes
153       ;;
154     --exec-prefix=*)
155       exec_prefix="${optarg}"
156       exec_prefix_set=yes
157       ;;
158     --exec-prefix)
159       echo_exec_prefix=yes
160       ;;
161     --version)
162       echo "@VERSION@"
163       exit 0
164       ;;
165     --linkage)
166       echo_linkage=yes
167       ;;
168     --target)
169       echo_target=yes
170       ;;
171     --cflags)
172       echo_cflags=yes
173       ;;
174     --cxxflags)
175       echo_cxxflags=yes
176       ;;
177     --objcflags)
178       echo_objcflags=yes
179       ;;
180     --libs)
181       echo_libs=yes
182       ;;
183     -*)
184       usage 1 1>&1
185       ;;
186     vlc)
187       cppflags="${cppflags} -D__VLC__"
188       ;;
189     plugin)
190       echo_plugin=yes
191       cppflags="${cppflags} -D__VLC__ -D__PLUGIN__"
192       ;;
193     pic)
194       echo_pic=yes
195       ;;
196     builtin)
197       echo_builtin=yes
198       cppflags="${cppflags} -D__VLC__ -D__BUILTIN__"
199       ;;
200     mozilla)
201       ;;
202     *)
203       module="$1"
204       ;;
205   esac
206
207   # Register per-module *FLAGS
208   register_flags "$1"
209
210   # Register module targets
211   register_targets "$1"
212
213   shift
214 done
215
216 #
217 #  If a module was requested, use its name
218 #
219 if test "${module}" != ""; then
220   cppflags="${cppflags} -DMODULE_NAME=${module} -DMODULE_NAME_IS_${module}"
221 fi
222
223 #
224 #  Output what we were asked
225 #
226 if test "${echo_linkage}" = yes; then
227   if test "${echo_plugin}"; then
228     for module in `echo "${plugins}"`; do
229       register_flags "${module}"
230     done
231   fi
232   if test "${echo_builtin}"; then
233     for module in `echo "${builtins}"`; do
234       register_flags "${module}"
235     done
236   fi
237   echo "${linkage}"
238   exit 0
239 fi
240
241 if test "${echo_target}" = yes; then
242   if test "${echo_plugin}"; then
243     for module in `echo "${plugins}"`; do
244       register_targets "${module}"
245     done
246     echo "${list}" | sed -e 's/[^ ][^ ]*/&_plugin/g'
247   fi
248   if test "${echo_builtin}"; then
249     for module in `echo "${builtins}"`; do
250       register_targets "${module}"
251     done
252     if test "${echo_pic}"; then
253       echo "${list}" | sed -e 's/[^ ][^ ]*/&_pic.a/g'
254     else
255       echo "${list}" | sed -e 's/[^ ][^ ]*/&.a/g'
256     fi
257   fi
258   exit 0
259 fi
260
261 if test "${echo_prefix}" = yes; then
262   echo "${prefix}"
263 fi
264 if test "${echo_exec_prefix}" = yes; then
265   echo "${exec_prefix}"
266 fi
267 if test "${echo_cppflags}" = yes; then
268   echo "${cppflags}"
269 fi
270 if test "${echo_cflags}" = yes; then
271   echo "${cppflags} ${cflags}"
272 fi
273 if test "${echo_cxxflags}" = yes; then
274   echo "${cppflags} ${cxxflags}"
275 fi
276 if test "${echo_objcflags}" = yes; then
277   echo "${cppflags} ${objcflags}"
278 fi
279 if test "${echo_libs}" = yes; then
280   if test "${echo_builtin}"; then
281     for module in `echo "${builtins}"`; do
282       register_targets "${module}"
283       register_flags "${module}"
284     done
285     if test "${echo_pic}"; then
286       libs="`echo "${list}" | sed -e 's/[^ ][^ ]*/&_pic.a/g'` ${libs}"
287     else
288       libs="`echo "${list}" | sed -e 's/[^ ][^ ]*/&.a/g'` ${libs}"
289     fi
290   fi
291   echo "${libs} ${ldflags}"
292 fi
293