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