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