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