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