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