]> git.sesse.net Git - vlc/blob - bootstrap
bootstrap: test for the presence of contrib/share/aclocal before including it because...
[vlc] / bootstrap
1 #! /bin/sh
2
3 ##  bootstrap file for the VLC media player
4 ##  $Id$
5 ##
6 ## Copyright (C) 2005 the VideoLAN team
7 ##
8 ##  Initial author: Sam Hocevar <sam@zoy.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"
35
36 # Check for contrib directory
37 if test -d extras/contrib/bin; then
38   export PATH=./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 fi
50
51 # Check for automake
52 amvers="none"
53 if automake-1.9 --version >/dev/null 2>&1; then
54   amvers="-1.9"
55 elif automake-1.8 --version >/dev/null 2>&1; then
56   amvers="-1.8"
57 elif automake-1.7 --version >/dev/null 2>&1; then
58   amvers="-1.7"
59 elif automake-1.6 --version >/dev/null 2>&1; then
60   amvers="-1.6"
61   if expr "`automake-1.6 --version | sed -e '1s/[^0-9]*//' -e q`" "<=" "1.6.1" > /dev/null 2>&1; then
62     AUTOMAKESUCKS=yes
63   fi
64 elif automake-1.5 --version >/dev/null 2>&1; then
65   INSTALLSUCKS=yes
66   amvers="-1.5"
67 elif automake --version > /dev/null 2>&1; then
68   amvers=""
69   case "`automake --version | sed -e '1s/[^0-9]*//' -e q`" in
70     0|0.*|1|1.[01234]|1.[01234][-.]*)
71       amvers="none" ;;
72     1.5|1.5.*)
73       INSTALLSUCKS=yes ;;
74     1.6|1.6.0|1.6.1)
75       AUTOMAKESUCKS=yes ;;
76     1.9|1.9.2)
77       ;;
78   esac
79 fi
80
81 if test "${amvers}" = "none"; then
82   set +x
83   echo "you need automake version 1.5 or later"
84   exit 1
85 fi
86
87 # Check for gettext
88 if gettextize --version >/dev/null 2>&1; then
89 # Autopoint is available from 0.11.3, but we need 0.11.5
90 if expr `gettextize --version | sed -e '1s/[^0-9]*//' -e q` \
91         '>=' 0.11.5 >/dev/null 2>&1; then
92   # We have gettext, and a recent version! Everything is cool.
93   autopoint=autopoint
94   GETTEXT=yes
95 else
96   # User's gettext is too old. try to continue anyway.
97   autopoint=:
98   GETTEXT=old
99 fi;else
100   set +x
101   echo "you need gettextize (package gettext-devel or gettext)"
102   exit 1
103 fi
104
105 # Check for pkg-config
106 if pkg-config --version >/dev/null 2>&1; then
107   # We have pkg-config, everything is cool.
108   PKGCONFIG=yes
109 else
110   PKGCONFIG=no
111 fi
112
113 aclocal=aclocal${amvers}
114 automake=automake${amvers}
115 autoconf=autoconf
116 autoheader=autoheader
117
118 ##
119 ## Generate the modules makefile, by parsing modules/**/Modules.am
120 ##
121
122 set +x
123 echo "generating modules/**/Makefile.am and m4/private.m4"
124
125 # Prepare m4/private.m4
126 rm -f m4/private.m4 && cat > m4/private.m4 << EOF
127 dnl  Private VLC macros - generated by bootstrap
128
129 EOF
130
131 if [ "${PKGCONFIG}" = "no" ]; then cat >> m4/private.m4 << EOF
132 dnl  User does not have pkg-config, so assume package was not found
133 AC_DEFUN([PKG_CHECK_MODULES],[ifelse([\$4], , :, [\$4])])
134
135 EOF
136 fi
137
138 if [ "${GETTEXT}" != "yes" ]; then cat >> m4/private.m4 << EOF
139 dnl  User does not have gettext, so this is a no-op
140 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
141
142 EOF
143 fi
144
145 rm -f m4/private.m4-tmp1 && cat > m4/private.m4-tmp1 << EOF
146 dnl  The required AM_CONDITIONAL calls
147 dnl  XXX: too many conditionals make the build very slow, disabled them
148 AC_DEFUN([VLC_CONDITIONALS], [
149 EOF
150 rm -f m4/private.m4-tmp2 && cat > m4/private.m4-tmp2 << EOF
151 dnl  The required AC_SUBST calls
152 AC_DEFUN([VLC_SUBSTS], [
153 EOF
154 rm -f m4/private.m4-tmp3 && cat > m4/private.m4-tmp3 << EOF
155 dnl  The required AC_OUTPUT calls
156 dnl  XXX: this feature is only supported starting from automake-1.7
157 AC_DEFUN([VLC_MAKEFILES], [AC_OUTPUT([
158 EOF
159 rm -f m4/private.m4-tmp4 && cat > m4/private.m4-tmp4 << EOF
160 dnl  Helper macro for vlc-config generation
161 AC_DEFUN([VLC_CONFIG_HELPER], [
162   cat >> vlc-config.in << BLAH
163 EOF
164
165 modules=""
166
167 rm -f modules/Makefile.am && cat > modules/Makefile.am << EOF
168 # Autogenerated by bootstrap - DO NOT EDIT
169 EXTRA_DIST = LIST
170 SUBDIRS = `sed -ne 's,modules/\([^/]*\)/Makefile,\1,p' configure.ac | xargs`
171 EOF
172
173 for dir in `sed -ne 's,modules/\(.*\)/Makefile,\1,p' configure.ac`
174 do
175   printf "."
176   modf="modules/${dir}/Modules.am"
177   makf="modules/${dir}/Makefile.am"
178   basedir="`echo "${dir}" | cut -f1 -d/`"
179   # automake will not recurse for make dist if we don't define SUBDIRS = .
180   subdirs="`sed -ne 's,'modules/${dir}'/\([^/]*\)/Makefile,\1,p' configure.ac | xargs`"
181   mods="`sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < "${modf}" | xargs`"
182   extra_libs=""
183   for mod in $mods
184   do
185     extra_libs="${extra_libs} lib${mod}_plugin.a"
186     extra_libs="${extra_libs} lib${mod}.a lib${mod}_pic.a"
187   done
188   rm -f "${makf}" && cat > "${makf}" << EOF
189
190 # ${makf} automatically generated from ${modf} by bootstrap
191 # DO NOT EDIT - edit Modules.am or \$(top_srcdir)/bootstrap instead
192
193 basedir = ${basedir}
194 mods = ${mods}
195
196 NULL =
197 libvlc_LIBRARIES =
198 noinst_LIBRARIES =
199 noinst_HEADERS =
200 EXTRA_DIST = Modules.am
201 BUILT_SOURCES =
202 SUBDIRS = ${subdirs}
203 SUFFIXES = _plugin\$(LIBEXT) _plugin.a
204
205 libvlcdir = \$(libdir)/vlc/\$(basedir)
206
207 EXTRA_LIBRARIES = ${extra_libs}
208 include Modules.am
209
210 all: all-modules
211
212 # Find out which modules were enabled and tell make to build them
213 all-modules:
214         @set fnord \$\$MAKEFLAGS; amf=\$\$2; targets=\`\\
215         if test "\$(plugin)" != "no"; then z=\$\$(\$(VLC_CONFIG) --list plugin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}_plugin\$(LIBEXT);; esac; done; fi; \\
216         if test "\$(builtin)" != "no"; then z=\$\$(\$(VLC_CONFIG) --list builtin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}.a;; esac; done; fi; \\
217         if test "\$(pic)" = "pic"; then z=\$\$(\$(VLC_CONFIG) --list builtin); for mod in \$(mods); do case "\$\$z " in *\ \$\${mod}\ *) echo lib\$\${mod}_pic.a;; esac; done; fi; \\
218         \`; case "\$\$targets" in *lib*) \$(MAKE) \$(AM_MAKEFLAGS) \$\$targets || case "\$\$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \\
219         test -z "\$\$fail"
220
221 # Build a plugin with the adequate linker and linker's flags
222 _plugin.a_plugin\$(LIBEXT):
223         @mod="\$*" ; mod=\$\${mod#lib} ; \
224         ldfl="\`\$(VLC_CONFIG) --libs plugin \$\$mod\` -u \$(SYMPREF)\$(VLC_ENTRY)" ; \
225         case \`\$(VLC_CONFIG) --linkage \$\$mod\` in \\
226           c++)  ld="\$(CXXLINK)" ;; \
227           objc) ld="\$(OBJCLINK)" ;; \
228           c|*)  ld="\$(LINK)" ;; \
229         esac ; \
230         echo \$\$ld \$< \$\$ldfl ; \
231         \$\$ld \$< \$\$ldfl
232
233 if MAINTAINER_MODE
234 \$(srcdir)/Makefile.am: \$(srcdir)/Modules.am \$(top_srcdir)/bootstrap
235         cd \$(top_srcdir) && \$(SHELL) ./bootstrap
236 endif
237
238 mostlyclean-local:
239         -rm -f *.a *\$(LIBEXT)
240
241 ### automake creates libvlcdir after running install-*-local
242 ### so we have to create it ourselves first
243 install-exec-local: all-modules
244         mkdir -p -- "\$(DESTDIR)\$(libvlcdir)"
245         @z=\$\$(\$(VLC_CONFIG) --list plugin); \
246         for mod in \$(mods); do \
247           case "\$\$z " \
248             in *\ \$\${mod}\ *) \
249               echo \$(INSTALL_PROGRAM) "lib\$\${mod}_plugin\$(LIBEXT)" "\$(DESTDIR)\$(libvlcdir)/" ; \
250               \$(INSTALL_PROGRAM) "lib\$\${mod}_plugin\$(LIBEXT)" "\$(DESTDIR)\$(libvlcdir)/" || exit \$\$?; \
251               ;; \
252           esac; \
253         done
254         @z=\$\$(\$(VLC_CONFIG) --list builtin); \
255         for mod in \$(mods); do \
256           case "\$\$z " \
257             in *\ \$\${mod}\ *) \
258               echo \$(INSTALL_DATA) "lib\$\${mod}.a" "\$(DESTDIR)\$(libdir)/vlc/" ; \
259               \$(INSTALL_DATA) "lib\$\${mod}.a" "\$(DESTDIR)\$(libdir)/vlc/" || exit \$\$?; \
260               ;; \
261           esac; \
262         done
263 if BUILD_MOZILLA
264         @z=\$\$(\$(VLC_CONFIG) --list builtin); \
265         for mod in \$(mods); do \
266           case "\$\$z " \
267             in *\ \$\${mod}\ *) \
268               echo \$(INSTALL_DATA) "lib\$\${mod}_pic.a" "\$(DESTDIR)\$(libdir)/vlc/" ; \
269               \$(INSTALL_DATA) "lib\$\${mod}_pic.a" "\$(DESTDIR)\$(libdir)/vlc/" || exit \$\$?; \
270               ;; \
271           esac; \
272         done
273 endif
274
275 uninstall-local:
276         @z=\$\$(\$(VLC_CONFIG) --list plugin); \
277         for mod in \$(mods); do \
278           case "\$\$z " \
279             in *\ \$\${mod}\ *) \
280               echo rm -f "\$(DESTDIR)\$(libvlcdir)/lib\$\${mod}_plugin\$(LIBEXT)" ; \
281               rm -f "\$(DESTDIR)\$(libvlcdir)/lib\$\${mod}_plugin\$(LIBEXT)" || true; \
282               ;; \
283           esac; \
284         done
285         @z=\$\$(\$(VLC_CONFIG) --list builtin); \
286         for mod in \$(mods); do \
287           case "\$\$z " \
288             in *\ \$\${mod}\ *) \
289               echo rm -f "\$(DESTDIR)\$(libdir)/vlc/lib\$\${mod}.a" ; \
290               rm -f "\$(DESTDIR)\$(libdir)/vlc/lib\$\${mod}.a" || true; \
291               ;; \
292           esac; \
293         done
294 if BUILD_MOZILLA
295         @z=\$\$(\$(VLC_CONFIG) --list builtin); \
296         for mod in \$(mods); do \
297           case "\$\$z " \
298             in *\ \$\${mod}\ *) \
299               echo rm -f "\$(DESTDIR)\$(libdir)/vlc/lib\$\${mod}_pic.a" ; \
300               rm -f "\$(DESTDIR)\$(libdir)/vlc/lib\$\${mod}_pic.a" || true; \
301               ;; \
302           esac; \
303         done
304 endif
305
306 EOF
307   for mod in $mods
308   do
309     if grep '^nodist_SOURCES_'${mod}'' < "${modf}" >/dev/null 2>&1; then
310         NODIST=''; else
311         NODIST='#'; fi
312     cat >> m4/private.m4-tmp4 << EOF
313     ${mod}) list="\\\${list} ${dir}/lib${mod}" ;;
314 EOF
315 # Generation of modules/**/Makefile.am
316 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
317 # - L_ is for LIBRARIES_, D_ for DATA_, B_ for BUILT_SOURCES_, F_ for LDFLAGS_,
318 #   S_ for SOURCES_, _p is for _plugin, _b is for _builtin. This is to reduce
319 #   the resulting file size.
320 # - *_CFLAGS, *_CXXFLAGS etc. because per-object CPPFLAGS does not seem to
321 #   work properly with any automake version I tested.
322     cat >> "${makf}" << EOF
323 # The ${mod} plugin
324
325 EOF
326     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
327 clean-local: clean-${mod}
328 clean-${mod}:
329         -test -z "\$(nodist_SOURCES_${mod})" || rm -f \$(nodist_SOURCES_${mod})
330
331 EOF
332     fi
333     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
334 BUILT_SOURCES += \$(B${mod})
335 EOF
336     fi
337     cat >> "${makf}" << EOF
338 lib${mod}_plugin_a_SOURCES = \$(SOURCES_${mod})
339 EOF
340     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
341 nodist_lib${mod}_plugin_a_SOURCES = \$(nodist_SOURCES_${mod})
342 EOF
343     fi
344     cat >> "${makf}" << EOF
345 lib${mod}_plugin_a_CFLAGS = \`\$(VLC_CONFIG) --cflags plugin ${mod}\`
346 lib${mod}_plugin_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags plugin ${mod}\`
347 lib${mod}_plugin_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags plugin ${mod}\`
348
349 lib${mod}_pic_a_SOURCES = \$(SOURCES_${mod})
350 EOF
351     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
352 nodist_lib${mod}_pic_a_SOURCES = \$(nodist_SOURCES_${mod})
353 EOF
354     fi
355     cat >> "${makf}" << EOF
356 lib${mod}_pic_a_CFLAGS = \`\$(VLC_CONFIG) --cflags builtin pic ${mod}\`
357 lib${mod}_pic_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags builtin pic ${mod}\`
358 lib${mod}_pic_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags builtin pic ${mod}\`
359
360 lib${mod}_a_SOURCES = ${PRIVATE}\$(SOURCES_${mod})
361 EOF
362     if [ "${NODIST}" != "#" ]; then cat >> "${makf}" << EOF
363 nodist_lib${mod}_a_SOURCES = ${PRIVATE}\$(nodist_SOURCES_${mod})
364 EOF
365     fi
366     cat >> "${makf}" << EOF
367 lib${mod}_a_CFLAGS = \`\$(VLC_CONFIG) --cflags builtin ${mod}\`
368 lib${mod}_a_CXXFLAGS = \`\$(VLC_CONFIG) --cxxflags builtin ${mod}\`
369 lib${mod}_a_OBJCFLAGS = \`\$(VLC_CONFIG) --objcflags builtin ${mod}\`
370
371 EOF
372   done
373 done
374
375 cat >> m4/private.m4-tmp1 << EOF
376 ])
377 EOF
378 cat m4/private.m4-tmp1 >> m4/private.m4 && rm -f m4/private.m4-tmp1
379 cat >> m4/private.m4-tmp2 << EOF
380 ])
381 EOF
382 cat m4/private.m4-tmp2 >> m4/private.m4 && rm -f m4/private.m4-tmp2
383 cat >> m4/private.m4-tmp3 << EOF
384 ])])
385 EOF
386 cat m4/private.m4-tmp3 >> m4/private.m4 && rm -f m4/private.m4-tmp3
387 cat >> m4/private.m4-tmp4 << EOF
388 BLAH
389 ])
390 EOF
391 cat m4/private.m4-tmp4 >> m4/private.m4 && rm -f m4/private.m4-tmp4
392
393 echo " done."
394
395 ###
396 ###  classic bootstrap stuff
397 ###
398 set -x
399
400 # remove autotools cruft
401 rm -f aclocal.m4 configure config.log config.h config.h.in
402 rm -Rf autom4te*.cache
403 # remove old autotools extra cruft
404 rm -f config.guess config.sub missing mkinstalldirs compile depcomp install-sh
405 # remove new autotools extra cruft
406 rm -Rf autotools
407 mkdir autotools
408 # remove libtool cruft
409 rm -f ltmain.sh libtool ltconfig
410 # remove gettext cruft
411 rm -f ABOUT-NLS
412 rm -Rf intl
413 # remove old vlc cruft
414 rm -f m4/oldgettext.m4 stamp-pic configure.ac.in Modules.am
415 # remove new vlc cruft
416 rm -f stamp-builtin stamp-h* mozilla/stamp-pic
417
418 # Automake complains if these are not present
419 rm -f vlc-config.in && printf "" > vlc-config.in
420 if [ "$GETTEXT" != "yes" ]; then
421   test -d intl || mkdir intl
422   printf "" > intl/Makefile.am
423   printf "" > ABOUT-NLS
424 fi
425
426 # Do the rest
427 ${autopoint} -f
428 ${aclocal} ${ACLOCAL_ARGS}
429 ${autoconf}
430 ${autoheader}
431 ${automake} --add-missing --copy
432
433 ##
434 ##  files which need to be regenerated
435 ##
436 rm -f vlc-config.in vlc-config
437 rm -f src/misc/modules_builtin.h
438 rm -f mozilla/vlcintf.h
439
440 # Shut up
441 set +x
442
443 ##
444 ##  Tell the user about gettext, pkg-config and sed
445 ##
446 if [ "${GETTEXT}" = "old" ]; then
447   cat << EOF
448
449 ==========================================================
450 NOTE: you have an old version of gettext installed on your
451 system. The vlc build will work, but if your system does not
452 have libintl you will not have internationalization support.
453 We suggest upgrading to gettext 0.11.5 or later.
454 EOF
455 fi
456
457 if [ "$PKGCONFIG" = "no" ]; then
458   cat << EOF
459
460 ==============================================================
461 NOTE: you do not have the "pkg-config" utility on your system;
462 detection of the Gtk-2.0 and GNOME 2.0 libraries will not be
463 reliable.
464 EOF
465 fi
466
467 if [ "$AUTOMAKESUCKS" = "yes" ]; then
468   cat << EOF
469
470 =============================================================
471 IMPORTANT NOTE: your version of automake has a bug which will
472 prevent proper plugin compilation. Either compile VLC with
473 the --disable-plugins flag, or use a version of automake newer
474 than 1.6.1 (1.6.2 is OK, and so are the 1.5 series).
475 EOF
476 fi
477
478 if [ "$INSTALLSUCKS" = "yes" ]; then
479   cat << EOF
480
481 =============================================================
482 IMPORTANT NOTE: your version of automake has a bug which will
483 prevent proper installation. Do not use "make install" with this
484 version of automake, or use a version of automake newer than 1.5
485 (such as 1.6 or 1.7).
486 EOF
487 fi
488