]> git.sesse.net Git - vlc/blob - bootstrap
bootstrap: Attempt to fix Mac OS X build using libtool. Please review.
[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 glibtoolize --version >/dev/null 2>&1; then
103   libtoolize="glibtoolize"
104 elif libtoolize --version >/dev/null 2>&1; then
105   libtoolize="libtoolize"
106 fi
107
108 if test "$libtoolize" = "no"; then
109   set +x
110   echo "$0: you need libtool"
111   exit 1
112 fi
113
114 # Check for gettext
115 if gettextize --version >/dev/null 2>&1; then
116 # Autopoint is available from 0.11.3, but we need 0.11.5
117 if expr `gettextize --version | sed -e '1s/[^0-9]*//' -e q` \
118         '>=' 0.11.5 >/dev/null 2>&1; then
119   # We have gettext, and a recent version! Everything is cool.
120   autopoint=autopoint
121   GETTEXT=yes
122 else
123   # User's gettext is too old. try to continue anyway.
124   autopoint=:
125   GETTEXT=old
126 fi;else
127   set +x
128   echo "you need gettextize (package gettext-devel or gettext)"
129   exit 1
130 fi
131
132 # Check for pkg-config
133 if pkg-config --version >/dev/null 2>&1; then
134   # We have pkg-config, everything is cool.
135   PKGCONFIG=yes
136 else
137   PKGCONFIG=no
138 fi
139
140 aclocal=aclocal${amsuff}
141 automake=automake${amsuff}
142 autoconf=autoconf
143 autoheader=autoheader
144
145 ##
146 ## Generate the modules makefile, by parsing modules/**/Modules.am
147 ##
148
149 set +x
150 echo "generating modules/**/Makefile.am and m4/private.m4"
151
152 # Prepare m4/private.m4
153 rm -f m4/private.m4 && cat > m4/private.m4 << EOF
154 dnl  Private VLC macros - generated by bootstrap
155
156 EOF
157
158 if [ "${PKGCONFIG}" = "no" ]; then cat >> m4/private.m4 << EOF
159 dnl  User does not have pkg-config, so assume package was not found
160 AC_DEFUN([PKG_CHECK_MODULES],[ifelse([\$4], , :, [\$4])])
161
162 EOF
163 fi
164
165 if [ "${GETTEXT}" != "yes" ]; then cat >> m4/private.m4 << EOF
166 dnl  User does not have gettext, so this is a no-op
167 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
168
169 EOF
170 fi
171
172 cat >> m4/private.m4 << EOF
173 dnl  Helper macro for vlc-config generation
174 AC_DEFUN([VLC_CONFIG_HELPER], [
175   cat >> vlc-config.in << BLAH
176 EOF
177
178 modules=""
179
180 rm -f modules/Makefile.am && cat > modules/Makefile.am << EOF
181 # Autogenerated by bootstrap - DO NOT EDIT
182 EXTRA_DIST = LIST
183 SUBDIRS = `sed -ne 's,modules/\([^/]*\)/Makefile,\1,p' configure.ac | xargs`
184 EOF
185
186 for dir in `sed -ne 's,modules/\(.*\)/Makefile,\1,p' configure.ac`
187 do
188   printf "."
189   modf="modules/${dir}/Modules.am"
190   makf="modules/${dir}/Makefile.am"
191   basedir="`echo "${dir}" | cut -f1 -d/`"
192   # automake will not recurse for make dist if we don't define SUBDIRS = .
193   subdirs="`sed -ne 's,'modules/${dir}'/\([^/]*\)/Makefile,\1,p' configure.ac | xargs`"
194   mods="`sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < "${modf}" | xargs`"
195   extra_ltlibs=""
196   for mod in $mods
197   do
198     extra_ltlibs="${extra_ltlibs} lib${mod}_plugin.la"
199   done
200   rm -f "${makf}" && cat > "${makf}" << EOF
201
202 # ${makf} automatically generated from ${modf} by bootstrap
203 # DO NOT EDIT - edit Modules.am or \$(top_srcdir)/bootstrap instead
204
205 basedir = ${basedir}
206 mods = ${mods}
207
208 NULL =
209 libvlc_LTLIBRARIES =
210 EXTRA_DIST = Modules.am
211 BUILT_SOURCES =
212 CLEANFILES =
213 SUBDIRS = ${subdirs}
214 SUFFIXES = _plugin\$(LIBEXT) _plugin.la
215
216 libvlcdir = \$(libdir)/vlc/\$(basedir)
217
218 EXTRA_LTLIBRARIES = ${extra_ltlibs}
219
220 include Modules.am
221
222 LTLIBVLC = \$(top_builddir)/src/libvlc.la
223
224 if USE_LIBTOOL
225 LIBADD = \$(LTLIBVLC)
226 endif
227 if HAVE_WIN32
228 LIBVLC = \$(top_builddir)/src/libvlc.dll
229 LIBADD = \$(LIBVLC)
230 endif
231
232 all: all-modules
233
234 nice:
235         \$(top_builddir)/compile
236
237 # Find out which modules were enabled and tell make to build them
238 all-modules:
239 if USE_LIBTOOL
240         @set fnord \$\$MAKEFLAGS; amf=\$\$2; targets=\`\\
241         z=\$\$(\$(VLC_CONFIG) --list plugin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}_plugin.la;; esac; done; \\
242         \`; case "\$\$targets" in *lib*) \$(MAKE) \$(AM_MAKEFLAGS) \$\$targets || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \\
243         test -z "\$\$fail"
244 else
245         @set fnord \$\$MAKEFLAGS; amf=\$\$2; targets=\`\\
246         z=\$\$(\$(VLC_CONFIG) --list plugin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}_plugin\$(LIBEXT);; esac; done; \\
247         z=\$\$(\$(VLC_CONFIG) --list builtin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}.a;; esac; done; \\
248         \`; case "\$\$targets" in *lib*) \$(MAKE) \$(AM_MAKEFLAGS) \$\$targets || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \\
249         test -z "\$\$fail"
250 endif
251
252 # Build a plugin with the adequate linker and linker's flags
253 _plugin.la_plugin\$(LIBEXT):
254         @mod="\$*" ; mod=\$\${mod#lib} ; \
255         ldfl="\`\$(VLC_CONFIG) --libs plugin \$\$mod\` \$(LIBADD) -u \$(SYMPREF)\$(VLC_ENTRY)" ; \
256         case \`\$(VLC_CONFIG) --linkage \$\$mod\` in \\
257           c++)  ld="\$(CXXLINK)" ;; \
258           objc) ld="\$(OBJCLINK)" ;; \
259           c|*)  ld="\$(LINK)" ;; \
260         esac ; \
261         echo \$\$ld \$< \$\$ldfl ; \
262         \$\$ld \$< \$\$ldfl
263         @if test -f "\$@.exe"; then mv -f -- "\$@.exe" "\$@"; fi
264
265 if MAINTAINER_MODE
266 \$(srcdir)/Makefile.am: \$(srcdir)/Modules.am \$(top_srcdir)/bootstrap
267         cd \$(top_srcdir) && \$(SHELL) ./bootstrap
268 endif
269
270 mostlyclean-local:
271         -rm -f *.la
272 if !USE_LIBTOOL
273         -rm -f *\$(LIBEXT)
274 endif
275
276 ### automake creates libvlcdir after running install-*-local
277 ### so we have to create it ourselves first
278 install-exec-local: all-modules
279 if USE_LIBTOOL
280         @if test -z "\$(libvlc_LTLIBRARIES)"; then \
281           z=\$\$(\$(VLC_CONFIG) --list plugin); \
282           m=\`for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo -n " lib\$\${mod}_plugin.la" ;; esac; done\` ; \
283           test -z "\$\$m" || \
284             \$(MAKE) \$(AM_MAKEFLAGS) libvlc_LTLIBRARIES="\$\$m" install-libvlcLTLIBRARIES || exit \$\$? ; \
285         fi
286 else
287         mkdir -p -- "\$(DESTDIR)\$(libvlcdir)"
288         @z=\$\$(\$(VLC_CONFIG) --list plugin); \
289         for mod in \$(mods); do \
290           case "\$\$z " \
291             in *\ \$\${mod}\ *) \
292               echo \$(INSTALL_PROGRAM) "lib\$\${mod}_plugin\$(LIBEXT)" "\$(DESTDIR)\$(libvlcdir)/" ; \
293               \$(INSTALL_PROGRAM) "lib\$\${mod}_plugin\$(LIBEXT)" "\$(DESTDIR)\$(libvlcdir)/" || exit \$\$?; \
294               ;; \
295           esac; \
296         done
297 endif
298
299 uninstall-local:
300 if USE_LIBTOOL
301         @if test -z "\$(libvlc_LTLIBRARIES)"; then \
302           z=\$\$(\$(VLC_CONFIG) --list plugin); \
303           m=\`for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo -n " lib\$\${mod}_plugin.la" ;; esac; done\` ; \
304           test -z "\$\$m" || \
305             \$(MAKE) \$(AM_MAKEFLAGS) libvlc_LTLIBRARIES="\$\$m" uninstall-libvlcLTLIBRARIES || exit \$\$?; \
306         fi
307 else
308         @z=\$\$(\$(VLC_CONFIG) --list plugin); \
309         for mod in \$(mods); do \
310           case "\$\$z " \
311             in *\ \$\${mod}\ *) \
312               echo rm -f "\$(DESTDIR)\$(libvlcdir)/lib\$\${mod}_plugin\$(LIBEXT)" ; \
313               rm -f "\$(DESTDIR)\$(libvlcdir)/lib\$\${mod}_plugin\$(LIBEXT)" || true; \
314               ;; \
315           esac; \
316         done
317 endif
318
319 EOF
320   for mod in $mods
321   do
322     if grep '^nodist_SOURCES_'${mod}'' < "${modf}" >/dev/null 2>&1; then
323         NODIST=''; else
324         NODIST='#'; fi
325     cat >> m4/private.m4 << EOF
326     ${mod}) list="\\\${list} ${dir}/lib${mod}" ;;
327 EOF
328 # Generation of modules/**/Makefile.am
329 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
330 # - L_ is for LIBRARIES_, D_ for DATA_, B_ for BUILT_SOURCES_, F_ for LDFLAGS_,
331 #   S_ for SOURCES_, _p is for _plugin, _b is for _builtin. This is to reduce
332 #   the resulting file size.
333 # - *_CFLAGS, *_CXXFLAGS etc. because per-object CPPFLAGS does not seem to
334 #   work properly with any automake version I tested.
335     cat >> "${makf}" << EOF
336 # The ${mod} plugin
337
338 EOF
339     cat >> "${makf}" << EOF
340 lib${mod}_plugin_la_SOURCES = \$(SOURCES_${mod})
341 EOF
342     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
343 nodist_lib${mod}_plugin_la_SOURCES = \$(nodist_SOURCES_${mod})
344 CLEANFILES += "\$(nodist_SOURCES_${mod})"
345 BUILT_SOURCES += \$(B${mod})
346 EOF
347     fi
348     cat >> "${makf}" << EOF
349 lib${mod}_plugin_la_CFLAGS = \`\$(VLC_CONFIG) --cflags plugin ${mod}\`
350 lib${mod}_plugin_la_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags plugin ${mod}\`
351 lib${mod}_plugin_la_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags plugin ${mod}\`
352 lib${mod}_plugin_la_LDFLAGS = \`\$(VLC_CONFIG) --libs plugin ${mod}\` \\
353         -rpath '\$(libvlcdir)' -avoid-version -module -shrext \$(LIBEXT) \\
354         -export-symbol-regex ^\$(VLC_ENTRY)\$\$ -no-undefined \$(LIBADD)
355 EOF
356   done
357 done
358
359 cat >> m4/private.m4 << EOF
360 BLAH
361 ])
362 EOF
363
364 ###
365 ###  classic bootstrap stuff
366 ###
367 set -x
368
369 # remove autotools cruft
370 rm -f aclocal.m4 configure config.log config.h config.h.in
371 rm -Rf autom4te*.cache
372 # remove old autotools extra cruft
373 rm -f config.guess config.sub missing mkinstalldirs compile depcomp install-sh
374 # remove new autotools extra cruft
375 rm -Rf autotools
376 mkdir autotools
377 # remove libtool cruft
378 rm -f ltmain.sh libtool ltconfig
379 # remove gettext cruft
380 rm -f ABOUT-NLS
381 rm -Rf intl
382 # remove vlc cruft
383 rm -f stamp-builtin stamp-h* mozilla/stamp-pic
384
385 # Automake complains if these are not present
386 rm -f vlc-config.in && printf "" > vlc-config.in
387 if [ "$GETTEXT" != "yes" ]; then
388   test -d intl || mkdir intl
389   printf "" > intl/Makefile.am
390   printf "" > ABOUT-NLS
391 fi
392
393 # Libtoolize directory
394 ${libtoolize} --copy --force
395 if test -f "ltmain.sh"; then
396   echo "$0: working around a minor libtool issue"
397   mv ltmain.sh autotools/
398 fi
399
400 # patch for DLL link for libtool on cygwin (remove when fixed)
401 if test ".`uname -s|sed -n '/^CYGWIN/p'`" != "."; then
402 patch -s -p0 << 'EOF'
403 --- autotools/ltmain.orig       2006-12-05 15:15:42.064607000 +0000
404 +++ autotools/ltmain.sh 2006-12-05 15:16:24.705777800 +0000
405 @@ -4360,7 +4360,7 @@
406  
407      prog)
408        case $host in
409 -       *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
410 +       *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,;s,.dll.exe$,.dll,'` ;;
411        esac
412        if test -n "$vinfo"; then
413         $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
414 EOF
415 fi
416
417 # Do the rest
418 ${autopoint} -f
419 ${aclocal} ${ACLOCAL_ARGS}
420 ${autoconf}
421 ${autoheader}
422 ${automake} --add-missing --copy -Wall
423
424 ##
425 ##  files which need to be regenerated
426 ##
427 rm -f vlc-config.in vlc-config
428 rm -f src/misc/modules_builtin.h
429
430 # Shut up
431 set +x
432
433 ##
434 ##  Tell the user about gettext, pkg-config and sed
435 ##
436 if [ "${GETTEXT}" = "old" ]; then
437   cat << EOF
438
439 ==========================================================
440 NOTE: you have an old version of gettext installed on your
441 system. The vlc build will work, but if your system does not
442 have libintl you will not have internationalization support.
443 We suggest upgrading to gettext 0.11.5 or later.
444 EOF
445 fi
446
447 if [ "$PKGCONFIG" = "no" ]; then
448   cat << EOF
449
450 ==============================================================
451 NOTE: you do not have the "pkg-config" utility on your system;
452 detection of the Gtk-2.0 and GNOME 2.0 libraries will not be
453 reliable.
454 EOF
455 fi
456