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