]> git.sesse.net Git - vlc/blob - bootstrap
* bootstrap: remove a -shared flag as ./configure already adds it for
[vlc] / bootstrap
1 #! /bin/sh
2
3 ##  bootstrap file for the VLC media player
4 ##  $Id: bootstrap,v 1.48 2003/05/25 22:36:33 titer Exp $
5 ##
6 ##  Authors: Samuel Hocevar <sam@zoy.org>
7
8 if test x$# != x0; then
9   echo "Usage: ./bootstrap"
10   echo "  Calls automake, autoconf, autoheader, autopoint and other auto* to build"
11   echo "  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 SEDSUCKS=no
27 PERLSUCKS=no
28 AUTOMAKESUCKS=no
29 INSTALLSUCKS=no
30
31 ##
32 ## Check that our tools don't suck
33 ##
34 if test ! 20000 -eq `perl -e 'printf "%s\n","a"x20000' | sed -e 's/.//' 2>/dev/null | wc -c`
35 then
36   SEDSUCKS=yes
37 fi
38
39 # Mac OS X stacksize sucks
40 if test x`uname -s` = xDarwin; then ulimit -s 20000; fi
41
42 ##
43 ## Generate the modules makefile, by parsing modules/**/Modules.am
44 ##
45
46 printf "generating Modules.am and configure.ac"
47
48 rm -f Modules.am configure.ac
49
50 echo > Modules.am
51 echo > configure.ac
52
53 ALL_FLAGS="`sed -n -e '/^[^=A-Z]*[A-Z]*FLAGS_[^=]*=/s/[^=A-Z]*\([A-Z]*FLAGS_[^=]*=\).*/\1/p' < configure.ac.in | sort | uniq`"
54
55 cat >> configure.ac << EOF
56 dnl ################################################################
57 dnl # Do not edit this file, it was generated from configure.ac.in #
58 dnl ################################################################
59
60 EOF
61 sed -n -e '/dnl do not touch this line/q;p' < configure.ac.in >> configure.ac
62
63 modules=""
64 for mf in `sed -ne 's@[^a-z]*\([^ ]*\)am.*@modules/\1am@p' < modules/Makefile.am`
65 do
66   printf "."
67   dir=`echo ${mf} | sed -e 's@\(.*\)/.*@\1@'`
68   topdir=`echo ${dir} | cut -f2 -d/`
69   sym=`echo ${dir} | sed -e 'y@/@_@'`
70   cat >> Modules.am << EOF
71 # Directory ${dir}
72
73 include ${dir}/Modules.am
74
75 EOF
76   sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < ${mf} | while read mod
77   do
78     LINKER="LINK"
79     if echo "$ALL_FLAGS" | grep '^CPPFLAGS_'${mod}'=$' >/dev/null 2>&1; then
80         echo "AC_SUBST(CPPFLAGS_${mod})" >> configure.ac; fi
81     if echo "$ALL_FLAGS" | grep '^CFLAGS_'${mod}'=$' >/dev/null 2>&1; then
82         echo "AC_SUBST(CFLAGS_${mod})" >> configure.ac; fi
83     if echo "$ALL_FLAGS" | grep '^CXXFLAGS_'${mod}'=$' >/dev/null 2>&1; then
84         LINKER="CXXLINK"
85         echo "AC_SUBST(CXXFLAGS_${mod})" >> configure.ac; fi
86     if echo "$ALL_FLAGS" | grep '^OBJCFLAGS_'${mod}'=$' >/dev/null 2>&1; then
87         LINKER="OBJCLINK"
88         echo "AC_SUBST(OBJCFLAGS_${mod})" >> configure.ac; fi
89     if echo "$ALL_FLAGS" | grep '^LDFLAGS_'${mod}'=$' >/dev/null 2>&1; then
90         echo "AC_SUBST(LDFLAGS_${mod})" >> configure.ac; fi
91     if grep '^SOURCES_'${mod}'.*=.*PRIVATE' < ${mf} >/dev/null 2>&1; then
92         PRIVATE='#'; else
93         PRIVATE=''; fi
94     if grep '^nodist_SOURCES_'${mod}'' < ${mf} >/dev/null 2>&1; then
95         NODIST=''; else
96         NODIST='#'; fi
97     cat >> configure.ac << EOF
98 AM_CONDITIONAL(${mod}_plugin, test x\$${mod}_plugin = xyes)
99 AM_CONDITIONAL(${mod}_builtin, test x\$${mod}_builtin = xyes)
100 EOF
101 # Generation of Modules.am
102 # ~~~~~~~~~~~~~~~~~~~~~~~~
103 # - L_ is for LIBRARIES_, D_ for DATA_, B_ for BUILT_SOURCES_, F_ for LDFLAGS_,
104 #   S_ for SOURCES_, _p is for _plugin, _b is for _builtin. This is to reduce
105 #   the resulting file size.
106 # - *_CFLAGS, *_CXXFLAGS etc. include *_CPPFLAGS because per-object CPPFLAGS
107 #   does not seem to work properly with any automake version I tested.
108     cat >> Modules.am << EOF
109 # The ${mod} plugin
110
111 if ${mod}_plugin
112 if UNTRUE
113 L_${mod}_p = ${dir}/lib${mod}_plugin.a
114 endif
115 D_${mod}_p = ${dir}/lib${mod}_plugin\$(LIBEXT)
116 ${NODIST}B_${mod}_p = \$(nodist_SOURCES_${mod})
117 endif
118 if ${mod}_builtin
119 L_${mod}_b = ${dir}/lib${mod}.a
120 F_${mod}_b = \$(LDFLAGS_${mod})
121 if BUILD_MOZILLA
122 L_${mod}_pic = ${dir}/lib${mod}_pic.a
123 endif
124 ${NODIST}B_${mod}_b = \$(nodist_SOURCES_${mod})
125 endif
126
127 L_builtin += \$(L_${mod}_b)
128 L_builtin_pic += \$(L_${mod}_pic)
129 LDFLAGS_builtin += \$(F_${mod}_b)
130 ${PRIVATE}BUILT_SOURCES += \$(B_${mod}_p) \$(B_${mod}_b)
131 PLUGIN_FILES += \$(D_${mod}_p)
132
133 ${PRIVATE}${sym}_lib${mod}_plugin_a_SOURCES = \$(SOURCES_${mod})
134 ${NODIST}${PRIVATE}nodist_${sym}_lib${mod}_plugin_a_SOURCES = \$(nodist_SOURCES_${mod})
135 ${sym}_lib${mod}_plugin_a_CPPFLAGS = \$(CPPFLAGS_plugin) \$(CPPFLAGS_${mod}) -DMODULE_NAME=${mod} -DMODULE_NAME_IS_${mod}
136 ${sym}_lib${mod}_plugin_a_CFLAGS = \$(CFLAGS_plugin) \$(CFLAGS_${mod}) \$(${sym}_lib${mod}_plugin_a_CPPFLAGS)
137 ${sym}_lib${mod}_plugin_a_CXXFLAGS = \$(CXXFLAGS_plugin) \$(CXXFLAGS_${mod}) \$(${sym}_lib${mod}_plugin_a_CPPFLAGS)
138 ${sym}_lib${mod}_plugin_a_OBJCFLAGS = \$(OBJCFLAGS_plugin) \$(OBJCFLAGS_${mod}) \$(${sym}_lib${mod}_plugin_a_CPPFLAGS)
139
140 ${sym}_lib${mod}_pic_a_SOURCES = ${PRIVATE}\$(SOURCES_${mod})
141 ${NODIST}nodist_${sym}_lib${mod}_pic_a_SOURCES = ${PRIVATE}\$(nodist_SOURCES_${mod})
142 ${sym}_lib${mod}_pic_a_CPPFLAGS = \$(CPPFLAGS_builtin_pic) \$(CPPFLAGS_${mod}) -DMODULE_NAME=${mod} -DMODULE_NAME_IS_${mod}
143 ${sym}_lib${mod}_pic_a_CFLAGS = \$(CFLAGS_builtin_pic) \$(CFLAGS_${mod}) \$(${sym}_lib${mod}_pic_a_CPPFLAGS)
144 ${sym}_lib${mod}_pic_a_CXXFLAGS = \$(CXXFLAGS_builtin_pic) \$(CXXFLAGS_${mod}) \$(${sym}_lib${mod}_pic_a_CPPFLAGS)
145 ${sym}_lib${mod}_pic_a_OBJCFLAGS = \$(OBJCFLAGS_builtin_pic) \$(OBJCFLAGS_${mod}) \$(${sym}_lib${mod}_pic_a_CPPFLAGS)
146
147 ${sym}_lib${mod}_a_SOURCES = ${PRIVATE}\$(SOURCES_${mod})
148 ${NODIST}nodist_${sym}_lib${mod}_a_SOURCES = ${PRIVATE}\$(nodist_SOURCES_${mod})
149 ${sym}_lib${mod}_a_CPPFLAGS = \$(CPPFLAGS_builtin) \$(CPPFLAGS_${mod}) -DMODULE_NAME=${mod} -DMODULE_NAME_IS_${mod}
150 ${sym}_lib${mod}_a_CFLAGS = \$(CFLAGS_builtin) \$(CFLAGS_${mod}) \$(${sym}_lib${mod}_a_CPPFLAGS)
151 ${sym}_lib${mod}_a_CXXFLAGS = \$(CXXFLAGS_builtin) \$(CXXFLAGS_${mod}) \$(${sym}_lib${mod}_a_CPPFLAGS)
152 ${sym}_lib${mod}_a_OBJCFLAGS = \$(OBJCFLAGS_builtin) \$(OBJCFLAGS_${mod}) \$(${sym}_lib${mod}_a_CPPFLAGS)
153
154 libvlc_LIBRARIES += \$(L_${mod}_b) \$(L_${mod}_pic)
155 lib${mod}_DATA = \$(D_${mod}_p)
156
157 lib${mod}dir = \$(libdir)/vlc/${topdir}
158 ${PRIVATE}noinst_LIBRARIES += \$(L_${mod}_p)
159 ${PRIVATE}${dir}/lib${mod}_plugin\$(LIBEXT): \$(${sym}_lib${mod}_plugin_a_OBJECTS)
160 ${PRIVATE}      \$(${LINKER}) \$(${sym}_lib${mod}_plugin_a_OBJECTS) \$(LDFLAGS_plugins) \$(LDFLAGS_${mod})
161
162
163 EOF
164   done
165 done
166
167 echo "AM_CONDITIONAL(UNTRUE, false)" >> configure.ac
168 sed -n -e '/dnl do not touch this line/,//p' < configure.ac.in >> configure.ac
169
170 echo "done."
171
172 ###
173 ###  classic bootstrap stuff
174 ###
175 set -x
176
177 # remove autotools cruft
178 rm -f aclocal.m4 configure config.log
179 # remove old autotools extra cruft
180 rm -f config.guess config.sub missing mkinstalldirs compile depcomp install-sh
181 # remove new autotools extra cruft
182 (cd autotools && rm -f config.guess config.sub missing mkinstalldirs compile depcomp install-sh)
183 # remove libtool cruft
184 rm -f ltmain.sh libtool ltconfig
185 # remove gettext cruft
186 rm -f m4/oldgettext.m4 ABOUT-NLS
187 rm -Rf intl
188 # update m4 local macros
189 rm -f m4/vlc.m4 && echo "dnl  Private VLC macros" > m4/vlc.m4
190
191 # Check for gettext
192 if gettextize --version >/dev/null 2>&1
193 then
194 if expr `gettextize --version | sed -e '1s/[^0-9]*//' -e q` \
195         '>' 0.11.2 >/dev/null 2>&1
196 then
197   # We have gettext, and a recent version! Everything is cool.
198   autopoint || exit 1
199   GETTEXT=yes
200 else
201   # User's gettext is too old. try to continue anyway.
202   echo > ABOUT-NLS
203   mkdir -p intl
204   echo > intl/Makefile.am
205   echo 'AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])' >> m4/vlc.m4
206   GETTEXT=old
207 fi;else
208   # we don't have gettext. grmbl. try to continue anyway.
209   echo > ABOUT-NLS
210   mkdir -p intl
211   echo > intl/Makefile.am
212   echo 'AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])' >> m4/vlc.m4
213   GETTEXT=no
214 fi
215
216 # Check for pkg-config
217 if pkg-config --version >/dev/null 2>&1
218 then
219   # We have pkg-config, everything is cool.
220   PKGCONFIG=yes
221 else
222   # Not present, use a workaround.
223   echo 'AC_DEFUN([PKG_CHECK_MODULES], [])' > m4/vlc.m4
224   PKGCONFIG=no
225 fi
226
227 # Check for automake
228 amvers="none"
229 if automake-1.7 --version >/dev/null 2>&1
230 then
231   amvers="-1.7"
232 else
233   if automake-1.6 --version >/dev/null 2>&1
234   then
235     amvers="-1.6"
236     if expr "`automake-1.6 --version | sed -e '1s/[^0-9]*//' -e q`" "<=" "1.6.1" > /dev/null 2>&1
237     then AUTOMAKESUCKS=yes
238     fi
239   else
240     if automake-1.5 --version >/dev/null 2>&1
241     then
242       INSTALLSUCKS=yes
243       amvers="-1.5"
244     else
245       if automake --version > /dev/null 2>&1
246       then
247         amvers=`automake --version | sed -e '1s/[^0-9]*//' -e q`
248         case $amvers in
249         1.6|1.6.0|1.6.1)
250           AUTOMAKESUCKS=yes ;;
251         1.5|1.5.*)
252           INSTALLSUCKS=yes ;;
253         esac
254
255         if expr "$amvers" "<" "1.5" > /dev/null 2>&1
256         then amvers="none"
257         else amvers=""
258         fi
259       fi
260     fi
261   fi
262 fi
263
264 if test x$amvers = xnone
265 then
266   set +x
267   echo "you need automake version 1.5 or later"
268   exit 1
269 fi
270
271 # Do the rest
272 aclocal${amvers} -I m4 || exit 1
273 autoheader || exit 1
274
275 automake${amvers} --add-missing --copy || PERLSUCKS=yes
276
277 case "$PERLSUCKS" in
278   no)
279   ;;
280   yes)
281     set +x
282     cat << EOF
283
284 =======================================================================
285 IMPORTANT NOTE: automake failed, please check the error messages. If it
286 actually segfaulted, it might be because of insufficient stack size; set
287 the stack size to something bigger or unlimited (\`unlimit stacksize')
288 and try again.
289 EOF
290     exit 1
291   ;;
292 esac
293
294 # Wrap automake's long lines, because the Solaris sed doesn't support lines
295 # longer than 3999 characters, and ./configure calls sed. We use Perl instead
296 # of sed for obvious reasons :)
297 perl -ne 'if(/^.{500}/) {s/(.{200}[^ ]* )/$1\\\n\t/g} print $_' < Makefile.in > Makefile.in.tmp && mv Makefile.in.tmp Makefile.in
298
299 autoconf || exit 1
300
301 ##
302 ##  headers which need to be regenerated
303 ##
304 rm -f src/misc/modules_builtin.h src/misc/modules_plugin.h
305 rm -f include/vlc_symbols.h
306 rm -f mozilla/vlcintf.h
307
308 ##
309 ##  Shut up
310 ##
311 set +x
312
313 ##
314 ##  Tell the user about gettext, pkg-config and sed
315 ##
316 case "$GETTEXT" in
317   yes)
318   ;;
319   no)
320     cat << EOF
321
322 ===========================================================
323 IMPORTANT NOTE: you do not have gettext installed on your
324 system. The vlc build will work, but you will not have
325 internationalization support. We suggest installing gettext.
326 EOF
327   ;;
328   old)
329     cat << EOF
330
331 ==========================================================
332 NOTE: you have an old version of gettext installed on your
333 system. The vlc build will work, but if your system does not
334 have libintl you will not have internationalization support.
335 We suggest upgrading to gettext 0.11.3 or later.
336 EOF
337   ;;
338 esac
339
340 case "$PKGCONFIG" in
341   yes)
342   ;;
343   no)
344     cat << EOF
345
346 ==============================================================
347 NOTE: you do not have the "pkg-config" utility on your system;
348 detection of the Gtk-2.0 and GNOME 2.0 libraries will not be
349 reliable.
350 EOF
351   ;;
352 esac
353
354 case "$AUTOMAKESUCKS" in
355   no)
356   ;;
357   yes)
358     cat << EOF
359
360 =============================================================
361 IMPORTANT NOTE: your version of automake has a bug which will
362 prevent proper plugin compilation. Either compile VLC with
363 the --disable-plugins flag, or use a version of automake newer
364 than 1.6.1 (1.6.2 is OK, and so are the 1.5 series).
365 EOF
366   ;;
367 esac
368
369 case "$INSTALLSUCKS" in
370   no)
371   ;;
372   yes)
373     cat << EOF
374
375 =============================================================
376 IMPORTANT NOTE: your version of automake has a bug which will
377 prevent proper installation. Do not use "make install" with this
378 version of automake, or use a version of automake newer than 1.5
379 (such as 1.6 or 1.7).
380 EOF
381   ;;
382 esac
383
384 case "$SEDSUCKS" in
385   no)
386   ;;
387   yes)
388     cat << EOF
389
390 =============================================================
391 IMPORTANT NOTE: the version of 'sed' on your system is unable
392 to handle long lines. bootstrap will try its best to generate
393 a correct Makefile, but you should expect problems. We highly
394 recommend installing GNU sed.
395 EOF
396   ;;
397 esac
398