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