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