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