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