]> git.sesse.net Git - vlc/blob - bootstrap
- bootstrap: quick fix for libtooling modules for mingw
[vlc] / bootstrap
1 #! /bin/sh
2
3 ##  bootstrap file for the VLC media player
4 ##
5 ## Copyright (C) 2005-2006 the VideoLAN team
6 ##
7 ##  Authors: Sam Hocevar <sam@zoy.org>
8 ##           RĂ©mi Denis-Courmont <rem # videolan # org>
9
10 if test "$#" != "0"; then
11   echo "Usage: $0"
12   echo "  Calls automake, autoconf, autoheader, autopoint and other auto* to generate"
13   echo "  m4 macros and prepare Makefiles."
14   exit 1
15 fi
16
17 ###
18 ###  Get a sane environment, just in case
19 ###
20 LANG=C
21 export LANG
22 CYGWIN=binmode
23 export CYGWIN
24
25 set -e
26 set -x
27
28 ##
29 ## Check for various tools
30 ##
31 AUTOMAKESUCKS=no
32 INSTALLSUCKS=no
33
34 ACLOCAL_ARGS="-I m4 ${ACLOCAL_ARGS}"
35
36 # Check for contrib directory
37 if test -d extras/contrib/bin; then
38   export PATH="`pwd`/extras/contrib/bin:$PATH"
39   if test -d extras/contrib/share/aclocal; then
40     ACLOCAL_ARGS="${ACLOCAL_ARGS} -I extras/contrib/share/aclocal"
41   fi
42   if test ".`uname -s`" = ".Darwin"; then
43     export LD_LIBRARY_PATH=./extras/contrib/lib:$LD_LIBRARY_PATH
44     export DYLD_LIBRARY_PATH=./extras/contrib/lib:$DYLD_LIBRARY_PATH
45   elif test ".`uname -s`" = ".BeOS"; then
46     export LIBRARY_PATH=./extras/contrib/lib:$LIBRARY_PATH
47     export BELIBRARIES=./extras/contrib/lib:$BELIBRARIES
48   fi
49 elif test ".`uname -s`" = ".Darwin"; then
50   set +x
51   echo ""
52   echo "ERR: Contribs haven't been built"
53   echo "ERR: Please run:"
54   echo "ERR: "
55   echo "ERR:    'cd extras/contrib && ./bootstrap && make && cd ../..'"
56   echo "ERR: "
57   echo "ERR: Make sure fink has been disabled too."
58   echo ""
59   set -x
60   exit 1
61 fi
62
63 # Check for autoconf
64 rm -f m4/autoconf260.m4
65 case "$(autoconf --version|head -n 1)" in
66   *2.5[012345678]*)
67     echo "Hey, your autoconf is quite old. Update it." >&2
68     exit 1
69     ;;
70
71   *2.59*)
72     echo "Enabling provisional autoconf 2.59 work-around. Update autoconf ASAP."
73     cp -f extras/m4/autoconf260.m4 m4/
74     ;;
75 esac
76
77 # Check for automake
78 amvers="no"
79 for v in "-1.10" "110" "-1.9" "19"; do
80   if automake${v} --version >/dev/null 2>&1; then
81     amsuff="${v}"
82     amvers="`echo ${v} | sed -e 's/^-//'`"
83     break
84   fi
85 done
86
87 if test "${amvers}" = "no" && automake --version > /dev/null 2>&1; then
88   amvers="`automake --version | sed -e '1s/[^0-9]*//' -e q`"
89   amsuff=""
90 fi
91
92 case "${amvers}" in
93   no|1.[012345678]|1.[0123456].*|1[0123456]|1.[0123456]-*)
94     set +x
95     echo "$0: you need automake version 1.9 or later"
96     exit 1
97     ;;
98 esac
99
100 # Check for libtool
101 libtoolize="no"
102 if test -x extras/contrib/bin/libtoolize; then
103   libtoolize="extras/contrib/bin/libtoolize"
104 elif glibtoolize --version >/dev/null 2>&1; then
105   libtoolize="glibtoolize"
106 elif libtoolize --version >/dev/null 2>&1; then
107   libtoolize="libtoolize"
108 fi
109
110 if test "$libtoolize" = "no"; then
111   set +x
112   echo "$0: you need libtool"
113   exit 1
114 fi
115
116 # Check for gettext
117 if gettextize --version >/dev/null 2>&1; then
118 # Autopoint is available from 0.11.3, but we need 0.11.5
119 if expr `gettextize --version | sed -e '1s/[^0-9]*//' -e q` \
120         '>=' 0.11.5 >/dev/null 2>&1; then
121   # We have gettext, and a recent version! Everything is cool.
122   autopoint=autopoint
123   GETTEXT=yes
124 else
125   # User's gettext is too old. try to continue anyway.
126   autopoint=:
127   GETTEXT=old
128 fi;else
129   set +x
130   echo "you need gettextize (package gettext-devel or gettext)"
131   exit 1
132 fi
133
134 # Check for pkg-config
135 if pkg-config --version >/dev/null 2>&1; then
136   # We have pkg-config, everything is cool.
137   PKGCONFIG=yes
138 else
139   PKGCONFIG=no
140 fi
141
142 aclocal=aclocal${amsuff}
143 automake=automake${amsuff}
144 autoconf=autoconf
145 autoheader=autoheader
146
147 ##
148 ## Generate the modules makefile, by parsing modules/**/Modules.am
149 ##
150
151 set +x
152 echo "generating modules/**/Makefile.am and m4/private.m4"
153
154 # Prepare m4/private.m4
155 rm -f m4/private.m4 && cat > m4/private.m4 << EOF
156 dnl  Private VLC macros - generated by bootstrap
157
158 EOF
159
160 if [ "${PKGCONFIG}" = "no" ]; then cat >> m4/private.m4 << EOF
161 dnl  User does not have pkg-config, so assume package was not found
162 AC_DEFUN([PKG_CHECK_MODULES],[ifelse([\$4], , :, [\$4])])
163
164 EOF
165 fi
166
167 if [ "${GETTEXT}" != "yes" ]; then cat >> m4/private.m4 << EOF
168 dnl  User does not have gettext, so this is a no-op
169 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
170
171 EOF
172 fi
173
174 cat >> m4/private.m4 << EOF
175 dnl  Helper macro for vlc-config generation
176 AC_DEFUN([VLC_CONFIG_HELPER], [
177   cat >> vlc-config.in << BLAH
178 EOF
179
180 modules=""
181
182 rm -f modules/Makefile.am && cat > modules/Makefile.am << EOF
183 # Autogenerated by bootstrap - DO NOT EDIT
184 EXTRA_DIST = LIST
185 SUBDIRS = `sed -ne 's,modules/\([^/]*\)/Makefile,\1,p' configure.ac | xargs`
186 EOF
187
188 for dir in `sed -ne 's,modules/\(.*\)/Makefile,\1,p' configure.ac`
189 do
190   printf "."
191   modf="modules/${dir}/Modules.am"
192   makf="modules/${dir}/Makefile.am"
193   basedir="`echo "${dir}" | cut -f1 -d/`"
194   # automake will not recurse for make dist if we don't define SUBDIRS = .
195   subdirs="`sed -ne 's,'modules/${dir}'/\([^/]*\)/Makefile,\1,p' configure.ac | xargs`"
196   mods="`sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < "${modf}" | xargs`"
197   extra_ltlibs=""
198   for mod in $mods
199   do
200     extra_ltlibs="${extra_ltlibs} lib${mod}_plugin.la"
201   done
202   rm -f "${makf}" && cat > "${makf}" << EOF
203
204 # ${makf} automatically generated from ${modf} by bootstrap
205 # DO NOT EDIT - edit Modules.am or \$(top_srcdir)/bootstrap instead
206
207 basedir = ${basedir}
208 mods = ${mods}
209
210 NULL =
211 libvlc_LTLIBRARIES =
212 EXTRA_DIST = Modules.am
213 BUILT_SOURCES =
214 CLEANFILES =
215 SUBDIRS = ${subdirs}
216 SUFFIXES = _plugin\$(LIBEXT) _plugin.la
217
218 libvlcdir = \$(libdir)/vlc/\$(basedir)
219
220 EXTRA_LTLIBRARIES = ${extra_ltlibs}
221
222 include Modules.am
223
224 if HAVE_WIN32
225 LTLIBVLC = -L\$(top_builddir)/src -lvlc.dll
226 else
227 LTLIBVLC = -L\$(top_builddir)/src -lvlc
228 endif
229
230 AM_LDFLAGS = -rpath '\$(libvlcdir)' -avoid-version \\
231         -module -no-undefined -shrext \$(LIBEXT) \\
232         -export-symbol-regex ^\$(VLC_ENTRY)\$\$
233
234 if USE_LIBTOOL
235 AM_LIBADD = \$(LTLIBVLC)
236 else
237 LIBVLC = -l\$(top_builddir) -lvlc
238 endif
239
240 all: all-modules
241
242 nice:
243         \$(top_builddir)/compile
244
245 # Find out which modules were enabled and tell make to build them
246 all-modules:
247 if USE_LIBTOOL
248         @set fnord \$\$MAKEFLAGS; amf=\$\$2; targets=\`\\
249         z=\$\$(\$(VLC_CONFIG) --list plugin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}_plugin.la;; esac; done; \\
250         \`; case "\$\$targets" in *lib*) \$(MAKE) \$(AM_MAKEFLAGS) \$\$targets || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \\
251         test -z "\$\$fail"
252 else
253         @set fnord \$\$MAKEFLAGS; amf=\$\$2; targets=\`\\
254         z=\$\$(\$(VLC_CONFIG) --list plugin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}_plugin\$(LIBEXT);; esac; done; \\
255         z=\$\$(\$(VLC_CONFIG) --list builtin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}.a;; esac; done; \\
256         \`; case "\$\$targets" in *lib*) \$(MAKE) \$(AM_MAKEFLAGS) \$\$targets || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \\
257         test -z "\$\$fail"
258 endif
259
260 # Build a plugin with the adequate linker and linker's flags
261 _plugin.la_plugin\$(LIBEXT):
262         @mod="\$*" ; mod=\$\${mod#lib} ; \
263         ldfl="\`\$(VLC_CONFIG) --libs plugin \$\$mod\` \$(LIBVLC) -u \$(SYMPREF)\$(VLC_ENTRY)" ; \
264         case \`\$(VLC_CONFIG) --linkage \$\$mod\` in \\
265           c++)  ld="\$(CXXLINK)" ;; \
266           objc) ld="\$(OBJCLINK)" ;; \
267           c|*)  ld="\$(LINK)" ;; \
268         esac ; \
269         echo \$\$ld \$< \$\$ldfl ; \
270         \$\$ld \$< \$\$ldfl
271         @if test -f "\$@.exe"; then mv -f -- "\$@.exe" "\$@"; fi
272
273 if MAINTAINER_MODE
274 \$(srcdir)/Makefile.am: \$(srcdir)/Modules.am \$(top_srcdir)/bootstrap
275         cd \$(top_srcdir) && \$(SHELL) ./bootstrap
276 endif
277
278 mostlyclean-local:
279         -rm -f *.la
280 if !USE_LIBTOOL
281         -rm -f *\$(LIBEXT)
282 endif
283
284 ### automake creates libvlcdir after running install-*-local
285 ### so we have to create it ourselves first
286 install-exec-local: all-modules
287 if USE_LIBTOOL
288         @if test -z "\$(libvlc_LTLIBRARIES)"; then \
289           z=\$\$(\$(VLC_CONFIG) --list plugin); \
290           m=\`for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo -n " lib\$\${mod}_plugin.la" ;; esac; done\` ; \
291           test -z "\$\$m" || \
292             \$(MAKE) \$(AM_MAKEFLAGS) libvlc_LTLIBRARIES="\$\$m" install-libvlcLTLIBRARIES || exit \$\$? ; \
293         fi
294 else
295         mkdir -p -- "\$(DESTDIR)\$(libvlcdir)"
296         @z=\$\$(\$(VLC_CONFIG) --list plugin); \
297         for mod in \$(mods); do \
298           case "\$\$z " \
299             in *\ \$\${mod}\ *) \
300               echo \$(INSTALL_PROGRAM) "lib\$\${mod}_plugin\$(LIBEXT)" "\$(DESTDIR)\$(libvlcdir)/" ; \
301               \$(INSTALL_PROGRAM) "lib\$\${mod}_plugin\$(LIBEXT)" "\$(DESTDIR)\$(libvlcdir)/" || exit \$\$?; \
302               ;; \
303           esac; \
304         done
305 endif
306
307 uninstall-local:
308 if USE_LIBTOOL
309         @if test -z "\$(libvlc_LTLIBRARIES)"; then \
310           z=\$\$(\$(VLC_CONFIG) --list plugin); \
311           m=\`for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo -n " lib\$\${mod}_plugin.la" ;; esac; done\` ; \
312           test -z "\$\$m" || \
313             \$(MAKE) \$(AM_MAKEFLAGS) libvlc_LTLIBRARIES="\$\$m" uninstall-libvlcLTLIBRARIES || exit \$\$?; \
314         fi
315 else
316         @z=\$\$(\$(VLC_CONFIG) --list plugin); \
317         for mod in \$(mods); do \
318           case "\$\$z " \
319             in *\ \$\${mod}\ *) \
320               echo rm -f "\$(DESTDIR)\$(libvlcdir)/lib\$\${mod}_plugin\$(LIBEXT)" ; \
321               rm -f "\$(DESTDIR)\$(libvlcdir)/lib\$\${mod}_plugin\$(LIBEXT)" || true; \
322               ;; \
323           esac; \
324         done
325 endif
326
327 EOF
328   for mod in $mods
329   do
330     if grep '^nodist_SOURCES_'${mod}'' < "${modf}" >/dev/null 2>&1; then
331         NODIST=''; else
332         NODIST='#'; fi
333     cat >> m4/private.m4 << EOF
334     ${mod}) list="\\\${list} ${dir}/lib${mod}" ;;
335 EOF
336 # Generation of modules/**/Makefile.am
337 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
338 # - L_ is for LIBRARIES_, D_ for DATA_, B_ for BUILT_SOURCES_, F_ for LDFLAGS_,
339 #   S_ for SOURCES_, _p is for _plugin, _b is for _builtin. This is to reduce
340 #   the resulting file size.
341 # - *_CFLAGS, *_CXXFLAGS etc. because per-object CPPFLAGS does not seem to
342 #   work properly with any automake version I tested.
343     cat >> "${makf}" << EOF
344 # The ${mod} plugin
345
346 EOF
347     cat >> "${makf}" << EOF
348 lib${mod}_plugin_la_SOURCES = \$(SOURCES_${mod})
349 EOF
350     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
351 nodist_lib${mod}_plugin_la_SOURCES = \$(nodist_SOURCES_${mod})
352 CLEANFILES += "\$(nodist_SOURCES_${mod})"
353 BUILT_SOURCES += \$(B${mod})
354 EOF
355     fi
356     cat >> "${makf}" << EOF
357 lib${mod}_plugin_la_CFLAGS = \`\$(VLC_CONFIG) --cflags plugin ${mod}\`
358 lib${mod}_plugin_la_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags plugin ${mod}\`
359 lib${mod}_plugin_la_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags plugin ${mod}\`
360 lib${mod}_plugin_la_LDFLAGS = \`\$(VLC_CONFIG) --libs plugin ${mod}\` \$(AM_LDFLAGS)
361 lib${mod}_plugin_la_LIBADD = \$(AM_LIBADD)
362 EOF
363   done
364 done
365
366 cat >> m4/private.m4 << EOF
367 BLAH
368 ])
369 EOF
370
371 ###
372 ###  classic bootstrap stuff
373 ###
374 set -x
375
376 # remove autotools cruft
377 rm -f aclocal.m4 configure config.log config.h config.h.in
378 rm -Rf autom4te*.cache
379 # remove old autotools extra cruft
380 rm -f config.guess config.sub missing mkinstalldirs compile depcomp install-sh
381 # remove new autotools extra cruft
382 rm -Rf autotools
383 mkdir autotools
384 # remove libtool cruft
385 rm -f ltmain.sh libtool ltconfig
386 # remove gettext cruft
387 rm -f ABOUT-NLS
388 rm -Rf intl
389 # remove vlc cruft
390 rm -f stamp-builtin stamp-h* mozilla/stamp-pic
391
392 # Automake complains if these are not present
393 rm -f vlc-config.in && printf "" > vlc-config.in
394 if [ "$GETTEXT" != "yes" ]; then
395   test -d intl || mkdir intl
396   printf "" > intl/Makefile.am
397   printf "" > ABOUT-NLS
398 fi
399
400 # Libtoolize directory
401 ${libtoolize} --copy --force
402 if test -f "ltmain.sh"; then
403   echo "$0: working around a minor libtool issue"
404   mv ltmain.sh autotools/
405 fi
406
407 # patch for DLL link for libtool on cygwin (remove when fixed)
408 if test ".`uname -s|sed -n '/^CYGWIN/p'`" != "."; then
409 patch -s -p0 << 'EOF'
410 --- autotools/ltmain.orig       2006-12-05 15:15:42.064607000 +0000
411 +++ autotools/ltmain.sh 2006-12-05 15:16:24.705777800 +0000
412 @@ -4360,7 +4360,7 @@
413  
414      prog)
415        case $host in
416 -       *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
417 +       *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,;s,.dll.exe$,.dll,'` ;;
418        esac
419        if test -n "$vinfo"; then
420         $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
421 EOF
422 fi
423
424 # Do the rest
425 ${autopoint} -f
426 ${aclocal} ${ACLOCAL_ARGS}
427 ${autoconf}
428 ${autoheader}
429 ${automake} --add-missing --copy -Wall
430
431 ##
432 ##  files which need to be regenerated
433 ##
434 rm -f vlc-config.in vlc-config
435 rm -f src/misc/modules_builtin.h
436
437 # Shut up
438 set +x
439
440 ##
441 ##  Tell the user about gettext, pkg-config and sed
442 ##
443 if [ "${GETTEXT}" = "old" ]; then
444   cat << EOF
445
446 ==========================================================
447 NOTE: you have an old version of gettext installed on your
448 system. The vlc build will work, but if your system does not
449 have libintl you will not have internationalization support.
450 We suggest upgrading to gettext 0.11.5 or later.
451 EOF
452 fi
453
454 if [ "$PKGCONFIG" = "no" ]; then
455   cat << EOF
456
457 ==============================================================
458 NOTE: you do not have the "pkg-config" utility on your system;
459 detection of the Gtk-2.0 and GNOME 2.0 libraries will not be
460 reliable.
461 EOF
462 fi
463