]> git.lyx.org Git - lyx.git/blob - development/tools/makeLyXsigc.sh
ws change
[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 Signal3"
76 # we only need up to Signal3
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,[6789]).*/d'
87         ;;
88     *)
89         sed < $i > $i.tmp \
90                 -e '/.*ARGS(P,[456789]).*/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 's/--dis\(able-threads\)/--en\1/' \
161 #    -e 's;dis\(ables.*threading\);en\1;' \
162 #    -e 's;\(^enable.*threads=\"\)yes;\1no;' \
163 #
164 # Don't use threads.
165 #
166 #    -e '/.*\.spec.*/d' \
167 #    -e '\%.*sigc++/Makefile.*%d' \
168 #    -e '\%.*config/Makefile.*%d'
169 #
170 # Remove unnecessary files from the AC_OUTPUT list.
171 #
172 #    -e 's,sigc++/,,g'
173 #
174 # No subdir sigc++.  This also results in sigc++/macros -> macros.
175 #
176 #    -e '\%.*tests/.*%d' \
177 #    -e '\%.*examples/.*%d' \
178 #    -e '\%.*scripts/.*%d'
179 #
180 # These directories have been completely removed and aren't relevent.
181 #
182 #    -e 's/.*\(AM_DISABLE_\)STATIC/\1SHARED/' \
183 #
184 # We want to default to static libs.  Although we still need to ensure that
185 # configure is forced to only produce static libs.
186 #
187 #    -e 's/AM_MAINTAINER_MODE/AC_ARG_WITH([included-libsigc],\
188 #  [  --without-included-libsigc\
189 #                             Use the libsigc++ installed on the system\
190 #                             Used when libsigc++ is bundled with applications],\
191 #  [sigc_use_included_libsigc=$withval],\
192 #  [sigc_use_included_libsigc=yes])\
193 #if test x$sigc_use_included_libsigc = xno; then\
194 #  ## just change the setting for the Makefile\
195 #  USE_INCLUDED_SIGC=no\
196 #  AC_SUBST(USE_INCLUDED_SIGC)\
197 #else\
198 ####\
199 #### This else..fi goes till the end of the file!\
200 ####\
201 #  USE_INCLUDED_SIGC=yes\
202 #  AC_SUBST(USE_INCLUDED_SIGC)/'
203 #
204 # Kill two birds with the one stone.  We want maintainer access as standard
205 # and we want to be able to choose between using this package or the full
206 # library installed on the local system.  If using the latter option we don't
207 # have to run most of the configure script so we hide it in a conditional.
208 #
209 #    -e 's/\(AC_OUTPUT.*\)/\
210 ####\
211 #### This is the end of the massive if..then..else..fi\
212 ####\
213 #fi\
214 #\
215 #\1/'
216 #
217 # Close the conditional introduced in the previous script.
218 #
219 ( cd $package;
220   sed < configure.in > sigc++/configure.in \
221     -e 's/\(Nelson\)/\1\
222 ## Modified by makeLyXsigc.sh (Allan Rae)/' \
223     -e 's%\(AC_INIT\)(sigc++)%\1(slot.cc)\
224 \
225 AC_DEFUN(LYX_FIX_MAKEFILE_IN,[\
226 ## modify Makefile.in if need be -- since we still use automake\
227 for dir in \$srcdir \$srcdir/macros ; do\
228 ( cd \$dir ;\
229   sed < Makefile.in > Makefile_tmp \\\
230         -e '\''s/all\: all-redirect/all: all-@USE_INCLUDED_SIGC@\\\
231 all-yes: all-redirect\\\
232 all-no:/'\'' ;\
233   mv Makefile_tmp Makefile.in )\
234 done\
235 ])\
236 \
237 LYX_FIX_MAKEFILE_IN%' \
238     -e 's%\(AUX_DIR(\)scripts%\1../config%' \
239     -e 's%config/\(sigc++config\.h\)%\1%' \
240     -e 's/--dis\(able-threads\)/--en\1/' \
241     -e 's;dis\(ables.*threading\);en\1;' \
242     -e 's;\(^enable.*threads=\"\)yes;\1no;' \
243     -e '/.*\.spec.*/d' \
244     -e '\%.*sigc++/Makefile.*%d' \
245     -e '\%.*config/Makefile.*%d' \
246     -e 's,sigc++/,,g' \
247     -e '\%.*tests/.*%d' \
248     -e '\%.*examples/.*%d' \
249     -e '\%.*scripts/.*%d' \
250     -e 's/.*\(AM_DISABLE_\)STATIC/\1SHARED/' \
251     -e 's/AM_MAINTAINER_MODE/AC_ARG_WITH([included-libsigc],\
252   [  --without-included-libsigc\
253                              Use the libsigc++ installed on the system\
254                              Used when libsigc++ is bundled with applications],\
255   [sigc_use_included_libsigc=$withval],\
256   [sigc_use_included_libsigc=yes])\
257 if test x$sigc_use_included_libsigc = xno; then\
258   ## just change the setting for the Makefile\
259   USE_INCLUDED_SIGC=no\
260   AC_SUBST(USE_INCLUDED_SIGC)\
261 else\
262 ###\
263 ### This else..fi goes till the end of the file!\
264 ###\
265   USE_INCLUDED_SIGC=yes\
266   AC_SUBST(USE_INCLUDED_SIGC)/' \
267     -e 's/\(AC_OUTPUT.*\)/\
268 ###\
269 ### This is the end of the massive if..then..else..fi\
270 ###\
271 fi\
272 \
273 \1/' )
274
275 echo "Modifying sigc++/Makefile.am"
276 #
277 #    -e 's%\(SUBDIRS =\)\(.*\)config\(.*\)%\1\2\3\
278 #DISTCLEANFILES= *.orig *.rej *~ *.bak core \
279 #MAINTAINERCLEANFILES= \$(srcdir)/Makefile.in \$(srcdir)/configure \$(srcdir)/sigc++config* \$(srcdir)/stamp* \$(srcdir)/aclocal.m4 \$(srcdir)/acinclude.m4 \
280 #ETAGS_ARGS = --lang=c++%'
281 #
282 # We've removed the sigc++/config/ above now we just make sure automake knows.
283 # We also want maintainer-clean to actually remove stuff. Same for distclean.
284 #
285 #    -e '/^INCLUDES/{s%\(dir)\)%\1/..%;}'
286 #
287 # All the headers are included with <sigc++/xxx.h> so we need an adjustment.
288 #
289 #    -e '/^M4_DIR/{s/sigc++\///;}'
290 #
291 # In the mini-dist the macros are directly under the top_srcdir which in this
292 # case is sigc++/.
293 #
294 #    -e '/^libsigc.*dir/d'
295 #
296 # Not installing the headers or the library.
297 #
298 #    -e 's/^libsigcinclude/noinst/'
299 #
300 # Don't install the headers.
301 #
302 #    -e 's/generator.h//'
303 #
304 # We don't need generator.h.
305 #
306 #    -e 's/lib_//' \
307 #    -e 's/\(LTLIB\)/noinst_\1/'
308 #
309 # These two lines make sure we don't install the library.
310 #
311 #    -e '/EXTRA_DIST.*/d';
312 #
313 # We don't want the extra bits that libsigc++ does.
314 #
315 #    -e 's/\(libsigc_la_SOURCES=\)\(.*\)/\1 $(BUILT_SOURCES)\2/' \
316 #    -e '/%.h:/i\
317 #Makefile: $(BUILT_SOURCES)\
318 #'
319 # Make sure the built sources are built.
320 #
321 ( cd $package/sigc++;
322   sed < Makefile.am > Makefile.tmp \
323     -e 's%\(SUBDIRS =\)\(.*\)config\(.*\)%\1\2\3\
324 DISTCLEANFILES= *.orig *.rej *~ *.bak core \
325 MAINTAINERCLEANFILES= \$(srcdir)/Makefile.in \$(srcdir)/configure \$(srcdir)/sigc++config* \$(srcdir)/stamp* \$(srcdir)/aclocal.m4 \$(srcdir)/acinclude.m4 \
326 ETAGS_ARGS = --lang=c++%' \
327     -e '/^INCLUDES/{s%\(dir)\)%\1/..%g;}' \
328     -e '/^M4_DIR/{s/sigc++\///;}' \
329     -e '/^libsigc.*dir/d' \
330     -e 's/^libsigcinclude/noinst/' \
331     -e 's/generator.h//' \
332     -e 's/lib_//' \
333     -e 's/\(LTLIB\)/noinst_\1/' \
334     -e '/EXTRA_DIST.*/d' \
335     -e 's/-version-info.*ION)//' \
336     -e 's/-release.*EASE)//' \
337     -e 's/\(libsigc_la_SOURCES=\)\(.*\)/\1 $(BUILT_SOURCES)\2/' \
338     -e '/%.h:/i\
339 Makefile: $(BUILT_SOURCES)\
340 ';
341   rm -f Makefile.am ;
342   mv Makefile.tmp Makefile.am )
343
344
345 echo "Modifying sigc++/macros/Makefile.am"
346 #
347 #    -e '/^m4includedir/d' \
348 #    -e 's/^m4include/noinst/'
349 #
350 # We're not installing any of this.
351 #
352 #    -e '$a\
353 #MAINTAINERCLEANFILES=\$(srcdir)/Makefile.in'
354 #
355 # Clean up.
356 #
357 ( cd $package/sigc++/macros;
358   sed < Makefile.am > Makefile.tmp \
359     -e '/^m4includedir/d' \
360     -e 's/^m4include/noinst/' \
361     -e '$a\
362 MAINTAINERCLEANFILES=\$(srcdir)/Makefile.in' ;
363   rm -f Makefile.am ;
364   mv Makefile.tmp Makefile.am )
365
366
367 echo "Adding various .cvsignore"
368 ( cd $package/sigc++;
369   cp ../../sigc++/.cvsignore . ;
370   cp ../../sigc++/macros/.cvsignore macros;
371   cp ../../doc/.cvsignore doc;
372   cat >> .cvsignore <<EOF
373 aclocal.m4
374 config.log
375 config.status
376 configure
377 libtool
378 sigc-config
379 stamp*
380 sigc++config.h
381 sigc++config.h.in
382 acinclude.m4
383 EOF
384 )
385
386
387 echo "Adding sigc++/DO_NOT_MODIFY_THESE_FILES"
388 ( cd $package/sigc++;
389   cat > DO_NOT_MODIFY_THESE_FILES <<EOF
390 These files are all collected together from a checked out copy of the
391 libsigc++ CVS repository by the ../development/tools/makeLyXsigc.sh file.
392 Some of these files are modified by that script.  If you need to fix a bug in
393 the code then you should try to get the latest CVS libsigc++ and regenerate
394 this entire subpackage. If the problem still persists it may be necessary to
395 modify the generation script.
396
397 If an error is found while porting to a new platform read the doc/requirements
398 file.
399
400 Remember to contact the LyX developers list if you are having problems.
401 Allan. (ARRae)
402 EOF
403 )
404
405
406 echo "Packing files."
407 ( cd $package ;
408   chmod -R a+r sigc++ config ;
409   GZIP=--best tar chozf lyx-sigc++-$version.tar.gz sigc++ config )
410 mv $package/lyx*gz .
411 #rm -Rf $package
412
413 chmod a+r lyx-sigc++-$version.tar.gz