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