]> git.lyx.org Git - lyx.git/blob - development/tools/makeLyXsigc.sh
FILMagain changes (will need some work)
[lyx.git] / development / tools / makeLyXsigc.sh
1 #!/bin/sh
2 ## Author: Allan Rae <rae@lyx.org>
3 ## With bug fixes and improvements by Karl Nelson.
4 ##
5 ## Severely hacked version of the libsigc++/win32/makevc.sh script
6 ## Builds the 'mini' libsigc++ distribution for use with LyX.
7 ## Hopefully the generated distribution is generic enough for use by
8 ## other apps also.
9 ##
10 if test ! -f .cvsignore ; then
11   ## could also test for acconfig.h since we need that too.
12   echo "Must be run in a CVS controlled source directory"
13   echo "You can't build the lyx-sigc distribution from a tarball"
14   ## This just makes my life considerably easier.
15   exit 1
16 fi
17
18 if test ! -f config.status ; then
19   echo "Must be run in configured source directory"
20   exit 1
21 fi
22
23 version=`grep SIGC_VERSION config.status | awk -F% '{print $3}'`
24 package="libsigc++-$version"
25 tarfile="$package.tar.gz"
26 configure="$package/configure.in"
27
28 if test ! -f $tarfile ; then
29   echo "Must have dist file $tarfile"
30   echo "Try:  make dist"
31   exit 1
32 fi
33
34 echo "Unpack distribution."
35 if test -d $package; then
36 rm -R $package
37 fi
38 tar xzf $tarfile --exclude CVS
39
40
41
42 echo "Removing irrelevent or regeneratable files."
43 find $package -name "Makefile.in" | xargs rm
44 find $package -name "*.Makefile" | xargs rm
45 ( cd $package;
46   cp ../acconfig.h sigc++;
47   mv [ACFT]* doc;
48   rm -f doc/riscos doc/ChangeLog;
49   mv  ltdll.c sigc-config.in doc sigc++;
50   rm -Rf lyx win32 scripts tests riscos djgpp borland examples;
51   rm -Rf aclocal.m4 libsigc++.spec*;
52   cd sigc++/ ;
53     find macros -name "*.h.m4" | sed -e 's,macros/\(.*\)\.m4,\1,' | xargs rm;
54     rm -rf README scripts/README generator.h config )
55
56
57 echo "Make autogen.sh for testing"
58 ( cd $package/sigc++;
59   cat > autogen.sh << EOF
60 #!/bin/sh
61 #
62 # You shouldn't need to use this script in your application unless it doesn't
63 # have its own equivalent.
64 #
65 libtoolize --automake
66 aclocal $ACLOCAL_FLAG
67 autoheader
68 automake --add-missing --foreign
69 autoconf
70 EOF
71   chmod a+x autogen.sh 
72 )
73
74
75 echo "Limiting to Signal2"
76 # we only need up to Signal2
77 # NOTE: sigc++ needs 2 slots higher than the number of signals (see bind.h)
78 # Anyone feeling keen?
79 # How would you like to make this a parameter-controlled stripping of
80 # the headers instead?
81 #
82 for i in `ls $package/sigc++/macros/*.h.m4`; do
83   case $i in
84     $package/sigc++/macros/slot.h.m4)
85         sed < $i > $i.tmp \
86                 -e '/.*ARGS(P,[56789]).*/d'
87         ;;
88     *)
89         sed < $i > $i.tmp \
90                 -e '/.*ARGS(P,[3456789]).*/d'
91         ;;
92   esac
93   rm -f $i
94   mv $i.tmp $i
95 done
96
97
98 echo "Changing <sigc++config.h> to <sigc++/sigc++config.h>"
99 #
100 # This change means that if the compiler can find <sigc++/slot.h> it can also
101 # find the sigc++config.h header which is internal to the library.
102 #
103 for i in `ls $package/sigc++/macros/*.h.m4 $package/sigc++/*.h`; do
104   sed < $i > $i.tmp \
105         -e 's%\(\(sigc++\)config.h\)%\2/\1%'
106   rm -f $i
107   mv $i.tmp $i
108 done
109
110
111 echo "Building application level config/"
112 mkdir $package/config
113 mv $package/sigc++.m4 $package/config
114
115
116 echo "Creating custom sigc++/configure.in"
117 ## My sed doesn't seem to want to match newlines in scripts. As a result
118 ## the first two scripts haven't been merged into one.
119 ## These separate scripts are ordered approximately in the order in which
120 ## they match in the unmodified configure.in.
121 ##
122 ## Note that you have to be very careful about quoting.  Look at the second
123 ## script for example: '\'', \\\ and \$
124 ##
125 ## Now for some explanation of what each script is supposed to change: 
126 ##
127 #       -e 's/\(Nelson\)/\1\
128 ### Modified by makeLyXsigc.sh (Allan Rae)/'
129 #
130 #  Credit where credit is due.
131 #
132 #    -e 's%\(AC_INIT\)(sigc++)%\1(slot.cc)\
133 #\
134 #AC_DEFUN(LYX_FIX_MAKEFILE_IN,[\
135 ### modify Makefile.in if need be -- since we still use automake\
136 #for dir in \$srcdir \$srcdir/macros ; do\
137 #( cd \$dir ;\
138 #  sed < Makefile.in > Makefile_tmp \\\
139 #        -e '\''s/all\: all-redirect/all: all-@USE_INCLUDED_SIGC@\\\
140 #all-yes: all-redirect\\\
141 #all-no:/'\'' ;\
142 #  mv Makefile_tmp Makefile.in )\
143 #done\
144 #])\
145 #\
146 #LYX_FIX_MAKEFILE_IN%'
147 #
148 # Change which file autoconf demands to be in the current directory.
149 # Add a way to not make anything in the sigc++ package when using an
150 # externally supplied library.
151 #
152 #    -e 's%\(AUX_DIR(\)scripts%\1../config%'
153 #
154 # Use the applications auxilliary directory. Assumed to be ../config. 
155 #
156 #    -e 's%config/\(sigc++config\.h\)%\1%'
157 #
158 # Move sigc++config.h out of the now removed config/.
159 #
160 #    -e '/.*\.spec.*/d' \
161 #    -e '\%.*sigc++/Makefile.*%d' \
162 #    -e '\%.*config/Makefile.*%d'
163 #
164 # Remove unnecessary files from the AC_OUTPUT list.
165 #
166 #    -e 's,sigc++/,,g'
167 #
168 # No subdir sigc++.  This also results in sigc++/macros -> macros.
169 #
170 #    -e '\%.*tests/.*%d' \
171 #    -e '\%.*examples/.*%d' \
172 #    -e '\%.*scripts/.*%d'
173 #
174 # These directories have been completely removed and aren't relevent.
175 #
176 #    -e 's/.*\(AM_DISABLE_\)STATIC/\1SHARED/' \
177 #
178 # We want to default to static libs.  Although we still need to ensure that
179 # configure is forced to only produce static libs.
180 #
181 #    -e 's/AM_MAINTAINER_MODE/AC_ARG_WITH([included-libsigc],\
182 #  [  --without-included-libsigc\
183 #                             Use the libsigc++ installed on the system\
184 #                             Used when libsigc++ is bundled with applications],\
185 #  [sigc_use_included_libsigc=$withval],\
186 #  [sigc_use_included_libsigc=yes])\
187 #if test x$sigc_use_included_libsigc = xno; then\
188 #  ## just change the setting for the Makefile\
189 #  USE_INCLUDED_SIGC=no\
190 #  AC_SUBST(USE_INCLUDED_SIGC)\
191 #else\
192 ####\
193 #### This else..fi goes till the end of the file!\
194 ####\
195 #  USE_INCLUDED_SIGC=yes\
196 #  AC_SUBST(USE_INCLUDED_SIGC)/'
197 #
198 # Kill two birds with the one stone.  We want maintainer access as standard
199 # and we want to be able to choose between using this package or the full
200 # library installed on the local system.  If using the latter option we don't
201 # have to run most of the configure script so we hide it in a conditional.
202 #
203 #    -e 's/\(AC_OUTPUT.*\)/\
204 ####\
205 #### This is the end of the massive if..then..else..fi\
206 ####\
207 #fi\
208 #\
209 #\1/'
210 #
211 # Close the conditional introduced in the previous script.
212 #
213 ( cd $package;
214   sed < configure.in > sigc++/configure.in \
215     -e 's/\(Nelson\)/\1\
216 ## Modified by makeLyXsigc.sh (Allan Rae)/' \
217     -e 's%\(AC_INIT\)(sigc++)%\1(slot.cc)\
218 \
219 AC_DEFUN(LYX_FIX_MAKEFILE_IN,[\
220 ## modify Makefile.in if need be -- since we still use automake\
221 for dir in \$srcdir \$srcdir/macros ; do\
222 ( cd \$dir ;\
223   sed < Makefile.in > Makefile_tmp \\\
224         -e '\''s/all\: all-redirect/all: all-@USE_INCLUDED_SIGC@\\\
225 all-yes: all-redirect\\\
226 all-no:/'\'' ;\
227   mv Makefile_tmp Makefile.in )\
228 done\
229 ])\
230 \
231 LYX_FIX_MAKEFILE_IN%' \
232     -e 's%\(AUX_DIR(\)scripts%\1../config%' \
233     -e 's%config/\(sigc++config\.h\)%\1%' \
234     -e '/.*\.spec.*/d' \
235     -e '\%.*sigc++/Makefile.*%d' \
236     -e '\%.*config/Makefile.*%d' \
237     -e 's,sigc++/,,g' \
238     -e '\%.*tests/.*%d' \
239     -e '\%.*examples/.*%d' \
240     -e '\%.*scripts/.*%d' \
241     -e 's/.*\(AM_DISABLE_\)STATIC/\1SHARED/' \
242     -e 's/AM_MAINTAINER_MODE/AC_ARG_WITH([included-libsigc],\
243   [  --without-included-libsigc\
244                              Use the libsigc++ installed on the system\
245                              Used when libsigc++ is bundled with applications],\
246   [sigc_use_included_libsigc=$withval],\
247   [sigc_use_included_libsigc=yes])\
248 if test x$sigc_use_included_libsigc = xno; then\
249   ## just change the setting for the Makefile\
250   USE_INCLUDED_SIGC=no\
251   AC_SUBST(USE_INCLUDED_SIGC)\
252 else\
253 ###\
254 ### This else..fi goes till the end of the file!\
255 ###\
256   USE_INCLUDED_SIGC=yes\
257   AC_SUBST(USE_INCLUDED_SIGC)/' \
258     -e 's/\(AC_OUTPUT.*\)/\
259 ###\
260 ### This is the end of the massive if..then..else..fi\
261 ###\
262 fi\
263 \
264 \1/' )
265
266 echo "Modifying sigc++/Makefile.am"
267 #
268 #    -e 's%\(SUBDIRS =\)\(.*\)config\(.*\)%\1\2\3\
269 #DISTCLEANFILES= *.orig *.rej *~ *.bak core \
270 #MAINTAINERCLEANFILES= \$(srcdir)/Makefile.in \$(srcdir)/configure \$(srcdir)/sigc++config* \$(srcdir)/stamp* \$(srcdir)/aclocal.m4 \$(srcdir)/acinclude.m4 \
271 #ETAGS_ARGS = --lang=c++%'
272 #
273 # We've removed the sigc++/config/ above now we just make sure automake knows.
274 # We also want maintainer-clean to actually remove stuff. Same for distclean.
275 #
276 #    -e '/^INCLUDES/{s%\(dir)\)%\1/..%;}'
277 #
278 # All the headers are included with <sigc++/xxx.h> so we need an adjustment.
279 #
280 #    -e '/^M4_DIR/{s/sigc++\///;}'
281 #
282 # In the mini-dist the macros are directly under the top_srcdir which in this
283 # case is sigc++/.
284 #
285 #    -e '/^libsigc.*dir/d'
286 #
287 # Not installing the headers or the library.
288 #
289 #    -e 's/^libsigcinclude/noinst/'
290 #
291 # Don't install the headers.
292 #
293 #    -e 's/generator.h//'
294 #
295 # We don't need generator.h.
296 #
297 #    -e 's/lib_//' \
298 #    -e 's/\(LTLIB\)/noinst_\1/'
299 #
300 # These two lines make sure we don't install the library.
301 #
302 #    -e '/EXTRA_DIST.*/d';
303 #
304 # We don't want the extra bits that libsigc++ does.
305 #
306 ( cd $package/sigc++;
307   sed < Makefile.am > Makefile.tmp \
308     -e 's%\(SUBDIRS =\)\(.*\)config\(.*\)%\1\2\3\
309 DISTCLEANFILES= *.orig *.rej *~ *.bak core \
310 MAINTAINERCLEANFILES= \$(srcdir)/Makefile.in \$(srcdir)/configure \$(srcdir)/sigc++config* \$(srcdir)/stamp* \$(srcdir)/aclocal.m4 \$(srcdir)/acinclude.m4 \
311 ETAGS_ARGS = --lang=c++%' \
312     -e '/^INCLUDES/{s%\(dir)\)%\1/..%g;}' \
313     -e '/^M4_DIR/{s/sigc++\///;}' \
314     -e '/^libsigc.*dir/d' \
315     -e 's/^libsigcinclude/noinst/' \
316     -e 's/generator.h//' \
317     -e 's/lib_//' \
318     -e 's/\(LTLIB\)/noinst_\1/' \
319     -e '/EXTRA_DIST.*/d' \
320     -e 's/-version-info.*ION)//' \
321     -e 's/-release.*EASE)//';
322   rm -f Makefile.am ;
323   mv Makefile.tmp Makefile.am )
324
325
326 echo "Modifying sigc++/macros/Makefile.am"
327 #
328 #    -e '/^m4includedir/d' \
329 #    -e 's/^m4include/noinst/'
330 #
331 # We're not installing any of this.
332 #
333 #    -e '$a\
334 #MAINTAINERCLEANFILES=\$(srcdir)/Makefile.in'
335 #
336 # Clean up.
337 #
338 ( cd $package/sigc++/macros;
339   sed < Makefile.am > Makefile.tmp \
340     -e '/^m4includedir/d' \
341     -e 's/^m4include/noinst/' \
342     -e '$a\
343 MAINTAINERCLEANFILES=\$(srcdir)/Makefile.in' ;
344   rm -f Makefile.am ;
345   mv Makefile.tmp Makefile.am )
346
347
348 echo "Adding various .cvsignore"
349 ( cd $package/sigc++;
350   cp ../../sigc++/.cvsignore . ;
351   cp ../../sigc++/macros/.cvsignore macros;
352   cp ../../doc/.cvsignore doc;
353   cat >> .cvsignore <<EOF
354 aclocal.m4
355 config.log
356 config.status
357 configure
358 libtool
359 sigc-config
360 stamp*
361 sigc++config.h
362 sigc++config.h.in
363 EOF
364 )
365
366
367 echo "Adding sigc++/DO_NOT_MODIFY_THESE_FILES"
368 ( cd $package/sigc++;
369   cat > DO_NOT_MODIFY_THESE_FILES <<EOF
370 These files are all collected together from a checked out copy of the
371 libsigc++ CVS repository by the ../development/tools/makeLyXsigc.sh file.
372 Some of these files are modified by that script.  If you need to fix a bug in
373 the code then you should try to get the latest CVS libsigc++ and regenerate
374 this entire subpackage. If the problem still persists it may be necessary to
375 modify the generation script.
376
377 If an error is found while porting to a new platform read the doc/requirements
378 file.
379
380 Remember to contact the LyX developers list if you are having problems.
381 Allan. (ARRae)
382 EOF
383 )
384
385
386 echo "Packing files."
387 ( cd $package ;
388   chmod -R a+r sigc++ config ;
389   GZIP=--best tar chozf lyx-sigc++-$version.tar.gz sigc++ config )
390 mv $package/lyx*gz .
391 #rm -Rf $package
392
393 chmod a+r lyx-sigc++-$version.tar.gz