]> git.sesse.net Git - vlc/blob - bootstrap
* httpd: added HEAD command support.
[vlc] / bootstrap
1 #! /bin/sh
2
3 ##  bootstrap file for the VLC media player
4 ##  $Id: bootstrap,v 1.71 2003/07/24 20:34:47 sam Exp $
5 ##
6 ##  Authors: Sam Hocevar <sam@zoy.org>
7
8 if test "$#" != "0"; then
9   echo "Usage: $0"
10   echo "  Calls automake, autoconf, autoheader, autopoint and other auto* to generate"
11   echo "  m4 macros and prepare Makefiles."
12   exit 1
13 fi
14
15 ###
16 ###  Get a sane environment, just in case
17 ###
18 LANG=C
19 export LANG
20 CYGWIN=binmode
21 export CYGWIN
22
23 set -e
24
25 ##
26 ## Naively assume our system doesn't suck. Unfortunately it seldom doesn't.
27 ##
28 AUTOMAKESUCKS=no
29 INSTALLSUCKS=no
30
31 ##
32 ## Generate the modules makefile, by parsing modules/**/Modules.am
33 ##
34
35 printf "generating modules/**/Makefile.am and m4/private.m4"
36
37 # Prepare m4/private.m4
38 rm -f m4/private.m4 && cat > m4/private.m4 << EOF
39 dnl  Private VLC macros - generated by bootstrap
40
41 EOF
42 rm -f m4/private.m4-tmp1 && cat > m4/private.m4-tmp1 << EOF
43 dnl  The required AM_CONDITIONAL calls
44 dnl  XXX: too many conditionals make the build very slow, disabled them
45 AC_DEFUN([AX_VLC_CONDITIONALS], [
46 EOF
47 rm -f m4/private.m4-tmp2 && cat > m4/private.m4-tmp2 << EOF
48 dnl  The required AC_SUBST calls
49 AC_DEFUN([AX_VLC_SUBSTS], [
50 EOF
51 rm -f m4/private.m4-tmp3 && cat > m4/private.m4-tmp3 << EOF
52 dnl  The required AC_OUTPUT calls
53 dnl  XXX: this feature is only supported starting from automake-1.7
54 AC_DEFUN([AX_VLC_MAKEFILES], [AC_OUTPUT([
55 EOF
56 rm -f m4/private.m4-tmp4 && cat > m4/private.m4-tmp4 << EOF
57 dnl  Helper macro for vlc-config generation
58 AC_DEFUN([AX_VLC_CONFIG_HELPER], [
59   cat >> vlc-config.in << BLAH
60 EOF
61
62 modules=""
63
64 rm -f modules/Makefile.am && cat > modules/Makefile.am << EOF
65 # Autogenerated by bootstrap - DO NOT EDIT
66 EXTRA_DIST = LIST
67 SUBDIRS = `sed -ne 's,modules/\([^/]*\)/Makefile,\1,p' configure.ac | xargs`
68 #DIST_SUBDIRS = \$(SUBDIRS)
69 EOF
70
71 for dir in `sed -ne 's,modules/\(.*\)/Makefile,\1,p' configure.ac`
72 do
73   printf "."
74   mf="modules/${dir}/Modules.am"
75   basedir="${dir%%\/*}"
76   # automake will not recurse for make dist if we don't define SUBDIRS = .
77   subdirs="`sed -ne 's,'modules/${dir}'/\([^/]*\)/Makefile,\1,p' configure.ac | xargs`"
78   rm -f modules/${dir}/Makefile.am && cat > modules/${dir}/Makefile.am << EOF
79
80 # Autogenerated by bootstrap - DO NOT EDIT - edit Modules.am instead
81
82 NULL =
83 libvlc_LIBRARIES =
84 noinst_LIBRARIES =
85 noinst_HEADERS =
86 EXTRA_DIST = Modules.am
87 BUILT_SOURCES =
88 SUBDIRS = ${subdirs}
89 #DIST_SUBDIRS = \$(SUBDIRS)
90 libvlcdir = \$(libdir)/vlc/${basedir}
91 include Modules.am
92
93 clean: clean-local
94 clean-local:
95         -rm -f *.a *.so *.dll *.sl *.dylib
96
97 EOF
98   for mod in `sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < ${mf}`
99   do
100     if grep '^SOURCES_'${mod}'.*=.*PRIVATE' < ${mf} >/dev/null 2>&1; then
101         PRIVATE='#'; else
102         PRIVATE=''; fi
103     if grep '^nodist_SOURCES_'${mod}'' < ${mf} >/dev/null 2>&1; then
104         NODIST=''; else
105         NODIST='#'; fi
106 #    cat >> m4/private.m4-tmp1 << EOF
107 #dnl  AM_CONDITIONAL(${mod}_p, test x\$${mod}_p = xyes)
108 #dnl  AM_CONDITIONAL(${mod}_b, test x\$${mod}_b = xyes)
109 #EOF
110     cat >> m4/private.m4-tmp4 << EOF
111     ${mod}) list="\\\${list} ${dir}/lib${mod}" ;;
112 EOF
113 # Generation of modules/**/Makefile.am
114 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
115 # - L_ is for LIBRARIES_, D_ for DATA_, B_ for BUILT_SOURCES_, F_ for LDFLAGS_,
116 #   S_ for SOURCES_, _p is for _plugin, _b is for _builtin. This is to reduce
117 #   the resulting file size.
118 # - *_CFLAGS, *_CXXFLAGS etc. because per-object CPPFLAGS does not seem to
119 #   work properly with any automake version I tested.
120     cat >> modules/${dir}/Makefile.am << EOF
121 # The ${mod} plugin
122 clean: clean-${mod}
123 all: all-${mod}
124
125 EOF
126     if [ "${NODIST}" != "#" ]; then cat >> modules/${dir}/Makefile.am << EOF
127 clean-${mod}:
128         -test -z "\$(nodist_SOURCES_${mod})" || rm -f \$(nodist_SOURCES_${mod})
129
130 EOF
131     fi
132     cat >> modules/${dir}/Makefile.am << EOF
133 all-${mod}:
134 if BUILD_MOZILLA
135         @set fnord \$\$MAKEFLAGS; amf=\$\$2; \\
136         if test "\$(plugin)" != "no" \\
137             && \$(VLC_CONFIG) --target plugin | grep "${dir}/lib${mod}_plugin" >/dev/null 2>&1; then \\
138           \$(MAKE) \$(AM_MAKEFLAGS) lib${mod}_plugin\$(LIBEXT) || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \\
139         fi; \\
140         if test "\$(builtin)" != "no" \\
141             && \$(VLC_CONFIG) --target builtin | grep "${dir}/lib${mod}\\.a" >/dev/null 2>&1; then \\
142           \$(MAKE) \$(AM_MAKEFLAGS) lib${mod}.a || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \\
143         fi; \\
144         if test "\$(pic)" != "no" \\
145             && \$(VLC_CONFIG) --target builtin pic | grep "${dir}/lib${mod}_pic\\.a" >/dev/null 2>&1; then \\
146           \$(MAKE) \$(AM_MAKEFLAGS) lib${mod}_pic.a || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \\
147         fi; \\
148         test -z "\$\$fail"
149 else
150         @set fnord \$\$MAKEFLAGS; amf=\$\$2; \\
151         if test "\$(plugin)" != "no" \\
152             && \$(VLC_CONFIG) --target plugin | grep "${dir}/lib${mod}_plugin" >/dev/null 2>&1; then \\
153           \$(MAKE) \$(AM_MAKEFLAGS) lib${mod}_plugin\$(LIBEXT) || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \\
154         fi; \\
155         if test "\$(builtin)" != "no" \\
156             && \$(VLC_CONFIG) --target builtin | grep "${dir}/lib${mod}\\.a" >/dev/null 2>&1; then \\
157           \$(MAKE) \$(AM_MAKEFLAGS) lib${mod}.a || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \\
158         fi; \\
159         test -z "\$\$fail"
160 endif
161
162 if UNTRUE
163 L${mod}p = lib${mod}_plugin.a
164 D${mod}p = lib${mod}_plugin\$(LIBEXT)
165 L${mod}b = lib${mod}.a
166 L${mod}pic = lib${mod}_pic.a
167 EOF
168     if [ "${NODIST}" != "#" ]; then cat >> modules/${dir}/Makefile.am << EOF
169 B${mod} = \$(nodist_SOURCES_${mod})
170 EOF
171     fi
172     cat >> modules/${dir}/Makefile.am << EOF
173 endif
174
175 EOF
176     if [ "${NODIST}" != "#" ]; then cat >> modules/${dir}/Makefile.am << EOF
177 ${PRIVATE}BUILT_SOURCES += \$(B${mod})
178 EOF
179     fi
180     cat >> modules/${dir}/Makefile.am << EOF
181 ${PRIVATE}lib${mod}_plugin_a_SOURCES = \$(SOURCES_${mod})
182 EOF
183     if [ "${NODIST}" != "#" ]; then cat >> modules/${dir}/Makefile.am << EOF
184 ${PRIVATE}nodist_lib${mod}_plugin_a_SOURCES = \$(nodist_SOURCES_${mod})
185 EOF
186     fi
187     cat >> modules/${dir}/Makefile.am << EOF
188 lib${mod}_plugin_a_CFLAGS = \`\$(VLC_CONFIG) --cflags plugin ${mod}\`
189 lib${mod}_plugin_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags plugin ${mod}\`
190 lib${mod}_plugin_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags plugin ${mod}\`
191
192 lib${mod}_pic_a_SOURCES = ${PRIVATE}\$(SOURCES_${mod})
193 EOF
194     if [ "${NODIST}" != "#" ]; then cat >> modules/${dir}/Makefile.am << EOF
195 nodist_lib${mod}_pic_a_SOURCES = ${PRIVATE}\$(nodist_SOURCES_${mod})
196 EOF
197     fi
198     cat >> modules/${dir}/Makefile.am << EOF
199 lib${mod}_pic_a_CFLAGS = \`\$(VLC_CONFIG) --cflags builtin pic ${mod}\`
200 lib${mod}_pic_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags builtin pic ${mod}\`
201 lib${mod}_pic_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags builtin pic ${mod}\`
202
203 lib${mod}_a_SOURCES = ${PRIVATE}\$(SOURCES_${mod})
204 EOF
205     if [ "${NODIST}" != "#" ]; then cat >> modules/${dir}/Makefile.am << EOF
206 nodist_lib${mod}_a_SOURCES = ${PRIVATE}\$(nodist_SOURCES_${mod})
207 EOF
208     fi
209     cat >> modules/${dir}/Makefile.am << EOF
210 lib${mod}_a_CFLAGS = \`\$(VLC_CONFIG) --cflags builtin ${mod}\`
211 lib${mod}_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags builtin ${mod}\`
212 lib${mod}_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags builtin ${mod}\`
213
214 libvlc_LIBRARIES += \$(L${mod}b) \$(L${mod}pic)
215 lib${mod}_DATA = \$(D${mod}p)
216
217 lib${mod}dir = \$(libdir)/vlc/${topdir}
218 ${PRIVATE}noinst_LIBRARIES += \$(L${mod}p)
219 ${PRIVATE}lib${mod}_plugin\$(LIBEXT): \$(lib${mod}_plugin_a_OBJECTS)
220 ${PRIVATE}      @case \`\$(VLC_CONFIG) --linkage ${mod}\` in \\
221 ${PRIVATE}        c++) echo \$(CXXLINK) \$(lib${mod}_plugin_a_OBJECTS) \\\`\$(VLC_CONFIG) --libs plugin ${mod}\\\` ; \$(CXXLINK) \$(lib${mod}_plugin_a_OBJECTS) \`\$(VLC_CONFIG) --libs plugin ${mod}\` ;; \\
222 ${PRIVATE}        objc) echo \$(OBJCLINK) \$(lib${mod}_plugin_a_OBJECTS) \\\`\$(VLC_CONFIG) --libs plugin ${mod}\\\` ; \$(OBJCLINK) \$(lib${mod}_plugin_a_OBJECTS) \`\$(VLC_CONFIG) --libs plugin ${mod}\` ;; \\
223 ${PRIVATE}        c|*) echo \$(LINK) \$(lib${mod}_plugin_a_OBJECTS) \\\`\$(VLC_CONFIG) --libs plugin ${mod}\\\` ; \$(LINK) \$(lib${mod}_plugin_a_OBJECTS) \`\$(VLC_CONFIG) --libs plugin ${mod}\` ;; \\
224 ${PRIVATE}      esac
225
226
227 EOF
228   done
229 done
230
231 cat >> m4/private.m4-tmp1 << EOF
232   AM_CONDITIONAL(UNTRUE, false)
233 ])
234 EOF
235 cat m4/private.m4-tmp1 >> m4/private.m4 && rm -f m4/private.m4-tmp1
236 cat >> m4/private.m4-tmp2 << EOF
237 ])
238 EOF
239 cat m4/private.m4-tmp2 >> m4/private.m4 && rm -f m4/private.m4-tmp2
240 cat >> m4/private.m4-tmp3 << EOF
241 ])])
242 EOF
243 cat m4/private.m4-tmp3 >> m4/private.m4 && rm -f m4/private.m4-tmp3
244 cat >> m4/private.m4-tmp4 << EOF
245 BLAH
246 ])
247 EOF
248 cat m4/private.m4-tmp4 >> m4/private.m4 && rm -f m4/private.m4-tmp4
249
250 echo "done."
251
252 ###
253 ###  classic bootstrap stuff
254 ###
255 set -x
256
257 # remove autotools cruft
258 rm -f aclocal.m4 configure config.log config.h config.h.in
259 # remove old autotools extra cruft
260 rm -f config.guess config.sub missing mkinstalldirs compile depcomp install-sh
261 # remove new autotools extra cruft
262 (cd autotools && rm -f config.guess config.sub missing mkinstalldirs compile depcomp install-sh)
263 # remove libtool cruft
264 rm -f ltmain.sh libtool ltconfig
265 # remove gettext cruft
266 rm -f ABOUT-NLS
267 rm -Rf intl
268 # remove old vlc cruft
269 rm -f m4/oldgettext.m4 stamp-pic configure.ac.in Modules.am
270 # remove new vlc cruft
271 rm -f stamp-builtin stamp-h* mozilla/stamp-pic
272
273 # Check for gettext
274 if gettextize --version >/dev/null 2>&1; then
275 # Autopoint is available from 0.11.3, but we need 0.11.5
276 if expr `gettextize --version | sed -e '1s/[^0-9]*//' -e q` \
277         '>=' 0.11.5 >/dev/null 2>&1; then
278   # We have gettext, and a recent version! Everything is cool.
279   autopoint=autopoint
280   GETTEXT=yes
281 else
282   # User's gettext is too old. try to continue anyway.
283   echo > ABOUT-NLS
284   mkdir -p intl
285   echo > intl/Makefile.am
286   cat >> m4/private.m4 << EOF
287 dnl  User's gettext is too old, so this is a no-op
288 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
289
290 EOF
291   autopoint=:
292   GETTEXT=old
293 fi;else
294   # we don't have gettext. grmbl. try to continue anyway.
295   echo > ABOUT-NLS
296   mkdir -p intl
297   echo > intl/Makefile.am
298   cat >> m4/private.m4 << EOF
299 dnl  User does not have gettext, so this is a no-op
300 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
301
302 EOF
303   autopoint=:
304   GETTEXT=no
305 fi
306
307 # Check for pkg-config
308 if pkg-config --version >/dev/null 2>&1; then
309   # We have pkg-config, everything is cool.
310   PKGCONFIG=yes
311 else
312   # Not present, use a workaround.
313   cat >> m4/private.m4 << EOF
314 dnl  User does not have pkg-config, so this is a no-op
315 AC_DEFUN([PKG_CHECK_MODULES], [])
316
317 EOF
318   PKGCONFIG=no
319 fi
320
321 # Check for automake
322 amvers="none"
323 if automake-1.7 --version >/dev/null 2>&1; then
324   amvers="-1.7"
325   # If we also have 1.6, use it instead because it is faster
326   if automake-1.6 --version >/dev/null 2>&1; then
327     if expr "`automake-1.6 --version | sed -e '1s/[^0-9]*//' -e q`" ">" "1.6.1" > /dev/null 2>&1; then
328       amvers="-1.6"
329     fi
330   fi
331 elif automake-1.6 --version >/dev/null 2>&1; then
332   amvers="-1.6"
333   if expr "`automake-1.6 --version | sed -e '1s/[^0-9]*//' -e q`" "<=" "1.6.1" > /dev/null 2>&1; then
334     AUTOMAKESUCKS=yes
335   fi
336 elif automake-1.5 --version >/dev/null 2>&1; then
337   INSTALLSUCKS=yes
338   amvers="-1.5"
339 elif automake --version > /dev/null 2>&1; then
340   amvers=""
341   case "`automake --version | sed -e '1s/[^0-9]*//' -e q`" in
342     0|0.*|1|1.[01234]|1.[01234][-.]*)
343       amvers="none" ;;
344     1.5|1.5.*)
345       INSTALLSUCKS=yes ;;
346     1.6|1.6.0|1.6.1)
347       AUTOMAKESUCKS=yes ;;
348   esac
349 fi
350
351 if test "${amvers}" = "none"; then
352   set +x
353   echo "you need automake version 1.5 or later"
354   exit 1
355 fi
356
357 aclocal=aclocal${amvers}
358 automake=automake${amvers}
359 autoconf=autoconf
360 autoheader=autoheader
361
362 # Automake complains if this is not present
363 rm -f vlc-config.in && printf "" > vlc-config.in
364
365 # Do the rest
366 ${autopoint} -f
367 ${aclocal} -I m4
368 ${autoconf}
369 ${autoheader}
370 ${automake} --add-missing --copy
371
372 ##
373 ##  files which need to be regenerated
374 ##
375 rm -f vlc-config.in vlc-config
376 rm -f src/misc/modules_builtin.h src/misc/modules_plugin.h
377 rm -f include/vlc_symbols.h
378 rm -f mozilla/vlcintf.h
379
380 # Shut up
381 set +x
382
383 ##
384 ##  Tell the user about gettext, pkg-config and sed
385 ##
386 case "${GETTEXT}" in
387   yes) ;;
388   no) cat << EOF
389
390 ===========================================================
391 IMPORTANT NOTE: you do not have gettext installed on your
392 system. The vlc build will work, but you will not have
393 internationalization support. We suggest installing gettext.
394 EOF
395   ;;
396   old) cat << EOF
397
398 ==========================================================
399 NOTE: you have an old version of gettext installed on your
400 system. The vlc build will work, but if your system does not
401 have libintl you will not have internationalization support.
402 We suggest upgrading to gettext 0.11.5 or later.
403 EOF
404   ;;
405 esac
406
407 case "$PKGCONFIG" in
408   yes) ;;
409   no) cat << EOF
410
411 ==============================================================
412 NOTE: you do not have the "pkg-config" utility on your system;
413 detection of the Gtk-2.0 and GNOME 2.0 libraries will not be
414 reliable.
415 EOF
416   ;;
417 esac
418
419 case "$AUTOMAKESUCKS" in
420   no) ;;
421   yes) cat << EOF
422
423 =============================================================
424 IMPORTANT NOTE: your version of automake has a bug which will
425 prevent proper plugin compilation. Either compile VLC with
426 the --disable-plugins flag, or use a version of automake newer
427 than 1.6.1 (1.6.2 is OK, and so are the 1.5 series).
428 EOF
429   ;;
430 esac
431
432 case "$INSTALLSUCKS" in
433   no) ;;
434   yes) cat << EOF
435
436 =============================================================
437 IMPORTANT NOTE: your version of automake has a bug which will
438 prevent proper installation. Do not use "make install" with this
439 version of automake, or use a version of automake newer than 1.5
440 (such as 1.6 or 1.7).
441 EOF
442   ;;
443 esac
444