updates.
[silc.git] / prepare
1 #! /bin/sh
2 #
3 #  prepare
4 #
5 #  Author: Pekka Riikonen <priikone@silcnet.org>
6 #
7 #  Copyright (C) 2000 - 2001 Pekka Riikonen
8 #
9 #  This program is free software; you can redistribute it and/or modify
10 #  it under the terms of the GNU General Public License as published by
11 #  the Free Software Foundation; version 2 of the License.
12 #
13 #  This program is distributed in the hope that it will be useful,
14 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 #  GNU General Public License for more details.
17 #
18
19 #
20 # Prepares SILC source tree for configuration and compilation. This is
21 # done only after checkout from CVS. This is only for developers of SILC
22 # and will never appear in public distribution. When creating distributions
23 # this is always run first. After the distribution is created all
24 # temporary files (including these prepare* scripts) are removed.
25 #
26
27 #
28 # Usage: ./prepare [<distribution> <base version> <package version>]
29 #
30 # If <package version> is omitted <base version> is used as package
31 # version.  The package version appears in the package name and in those
32 # distributions that used the SILC_DIST_VERSION_STRING define in the
33 # code.  The base version is the SILC_VERSION_STRING define.
34 #
35
36 #
37 # SILC Distribution versions. Set here or give the version on the command
38 # line as argument.
39 #
40 SILC_VERSION=0.6                        # Base version
41
42
43 #############################################################################
44
45 echo "Preparing SILC source tree for configuration and compilation..."
46
47 distribution=$1
48 if test "$distribution" = ""; then
49   distribution="toolkit";
50 fi
51
52 version=$2
53 if test "$version" = ""; then
54   version=$SILC_VERSION;
55 fi
56
57 dist_version=$3
58 if test "$dist_version" = ""; then
59   dist_version=$version
60 fi
61
62 echo "Preparing $distribution distribution version $version (package $dist_version)"
63
64 #
65 # Go though the subdirs and create the Makefile.ams from the
66 # Makefile.am.pre files.
67 #
68 subdirs=`grep "$distribution"_SUBDIRS= distributions |cut -d=  -f2`
69 ed=`grep "$distribution"_EXTRA_DIST= distributions |cut -d=  -f2`
70 sed -e "/SILC_DISTRIBUTION_SUBDIRS/s//$subdirs/" -e "/SILC_DISTRIBUTION_EXTRA/s,,$ed," Makefile.am.pre >Makefile.am
71 path=`pwd`
72 for i in $subdirs
73 do
74   cd $i
75   sub=`grep "$distribution"_SUBDIRS_"$i"= $path/distributions |cut -d=  -f2`
76   if test "$sub" = ""; then
77     cd $path
78     continue;
79   fi
80   if [ -f Makefile.am.pre ]; then
81     sed -e "/SILC_DISTRIBUTION_SUBDIRS/s//$sub/" -e "/SILC_DISTRIBUTION_SUBDIRS/s//$sub/" Makefile.am.pre >Makefile.am 2>/dev/null
82   fi
83   cd $path
84 done
85 cd $path
86
87
88 #
89 # Replace version string, package name and distribution infos, and create 
90 # the actual configure.in
91 #
92 echo "# Automatically generated by ./prepare from configure.in.pre. Do not edit!" >configure.in2
93 sed -e "/SILC_VERSION/s//$dist_version/" -e "/SILC_PACKAGE/s//silc-"$distribution"/" configure.in.pre >>configure.in2
94
95 #
96 # Create also the acconfig.h for the distribution. Note that this sets
97 # also dist labels for distributions that are not defined.
98 #
99 cp acconfig.h.pre acconfig.h
100 dists=`grep DISTRIBUTIONS= distributions |cut -d=  -f2`
101 touch am_cond
102 for i in $dists
103 do
104   dl=`grep "$i"_DISTLABEL= distributions |cut -d=  -f2`
105   echo "#undef $dl" >>acconfig.h
106   if test "$i" = "$distribution"; then
107     echo "AM_CONDITIONAL($dl, test xtrue = xtrue)" >>am_cond
108   else
109     echo "AM_CONDITIONAL($dl, test xtrue = xfalse)" >>am_cond
110   fi
111 done
112
113 sed '/SILC_DIST_DEFINE/ r am_cond' configure.in2 >configure.in3
114 dl=`grep "$distribution"_DISTLABEL= distributions |cut -d=  -f2`
115 sed -e "/SILC_DIST_DEFINE/s//$dl/" configure.in3 >configure.in
116 rm -f configure.in2 configure.in3 am_cond
117
118
119 #
120 # Prepare the Makefile.defines
121 #
122 cp Makefile.defines.pre Makefile.defines.in
123 cp Makefile.defines_int.pre Makefile.defines_int.in
124 cp Makefile.defines.in irssi
125 cp Makefile.defines_int.in irssi
126 cp Makefile.defines.in lib/silcmath/mpi
127 cp Makefile.defines_int.in lib/silcmath/mpi
128
129 aclocal
130 autoconf
131 autoheader >/dev/null 2>/dev/null
132 automake
133
134 echo "Preparing trq"
135 cd lib/trq
136 aclocal
137 autoconf
138 autoheader </dev/null 2>/dev/null
139 automake >/dev/null 2>/dev/null
140 cd ../..
141
142 echo "Preparing mpi"
143 cd lib/silcmath/mpi
144 aclocal
145 autoconf
146 autoheader </dev/null 2>/dev/null
147 automake >/dev/null 2>/dev/null
148 cd ../../..
149
150 file=includes/version_internal.h
151 echo "/* Automatically generated by ./prepare */" >$file
152 echo "#define SILC_VERSION_STRING \"$version\"" >>$file
153 echo "#define SILC_DIST_VERSION_STRING \"$dist_version\"" >>$file
154 echo "#define SILC_PROTOCOL_VERSION_STRING \"SILC-1.0-$version\"" >>$file
155 echo "#define SILC_NAME \"SILC $distribution\"" >>$file
156
157 # preparing irssi
158 echo "Preparing irssi"
159 cd irssi
160 sh autogen.sh 2>/dev/null 1>/dev/null
161 cd ..
162 file=irssi/irssi-version.h.in
163 version_date=`date +%Y%m%d`
164 echo "/* automatically created by autogen.sh */" > $file
165 echo "#define IRSSI_VERSION \"$dist_version (Irssi base: @VERSION@ - SILC base: SILC Toolkit $version)\"" >>$file
166 echo "#define IRSSI_VERSION_DATE \"$version_date\"" >> $file
167
168 echo "Done, now run ./configure and make."