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