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