make it compile on mingw32.
[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.8.2                      # Base version
41
42 #############################################################################
43
44 echo "Preparing SILC source tree for configuration and compilation..."
45
46 distribution=$1
47 if test "$distribution" = ""; then
48   distribution="toolkit";
49 fi
50
51 version=$2
52 if test "$version" = ""; then
53   version=$SILC_VERSION;
54 fi
55
56 dist_version=$3
57 if test "$dist_version" = ""; then
58   dist_version=$version
59 fi
60
61 echo "Preparing $distribution distribution version $version (package $dist_version)"
62
63 #
64 # Go though the subdirs and create the Makefile.ams from the
65 # Makefile.am.pre files.
66 #
67 subdirs=`grep "$distribution"_SUBDIRS= distributions |cut -d=  -f2`
68 ed=`grep "$distribution"_EXTRA_DIST= distributions |cut -d=  -f2`
69 sed -e "/SILC_DISTRIBUTION_SUBDIRS/s//$subdirs/" -e "/SILC_DISTRIBUTION_EXTRA/s,,$ed," Makefile.am.pre >Makefile.am
70 path=`pwd`
71 for i in $subdirs
72 do
73   cd $i
74   sub=`grep "$distribution"_SUBDIRS_"$i"= $path/distributions |cut -d=  -f2`
75   if test "$sub" = ""; then
76     cd $path
77     continue;
78   fi
79   if [ -f Makefile.am.pre ]; then
80     sed -e "/SILC_DISTRIBUTION_SUBDIRS/s//$sub/" -e "/SILC_DISTRIBUTION_SUBDIRS/s//$sub/" Makefile.am.pre >Makefile.am 2>/dev/null
81   fi
82   cd $path
83 done
84 cd $path
85
86
87 #
88 # Replace version string, package name and distribution infos, and create 
89 # the actual configure.in
90 #
91 echo "# Automatically generated by ./prepare from configure.in.pre. Do not edit!" >configure.in2
92 sed -e "/SILC_VERSION/s//$dist_version/" -e "/SILC_PACKAGE/s//silc-"$distribution"/" configure.in.pre >>configure.in2
93
94 #
95 # Create also the acconfig.h for the distribution. Note that this sets
96 # also dist labels for distributions that are not defined.
97 #
98 cp acconfig.h.pre acconfig.h
99 dists=`grep DISTRIBUTIONS= distributions |cut -d=  -f2`
100 touch am_cond
101 for i in $dists
102 do
103   dl=`grep "$i"_DISTLABEL= distributions |cut -d=  -f2`
104   echo "#undef $dl" >>acconfig.h
105   if test "$i" = "$distribution"; then
106     echo "AM_CONDITIONAL($dl, test xtrue = xtrue)" >>am_cond
107   else
108     echo "AM_CONDITIONAL($dl, test xtrue = xfalse)" >>am_cond
109   fi
110 done
111
112 sed '/SILC_DIST_DEFINE/ r am_cond' configure.in2 >configure.in3
113 dl=`grep "$distribution"_DISTLABEL= distributions |cut -d=  -f2`
114 sed -e "/SILC_DIST_DEFINE/s//$dl/" configure.in3 >configure.in
115 rm -f configure.in2 configure.in3 am_cond
116
117
118 #
119 # Prepare the Makefile.defines
120 #
121 cp Makefile.defines.pre Makefile.defines.in
122 cp Makefile.defines_int.pre Makefile.defines_int.in
123 cp Makefile.defines.in irssi
124 cp Makefile.defines_int.in irssi
125 cp Makefile.defines.in lib/silcmath/mpi
126 cp Makefile.defines_int.in lib/silcmath/mpi
127
128 aclocal
129 autoconf
130 autoheader >/dev/null 2>/dev/null
131 automake
132
133 echo "Preparing mpi"
134 cd lib/silcmath/mpi
135 aclocal
136 autoconf
137 autoheader </dev/null 2>/dev/null
138 automake >/dev/null 2>/dev/null
139 cd ../../..
140
141 file=includes/version_internal.h
142 echo "/* Automatically generated by ./prepare */" >$file
143 echo "#define SILC_VERSION_STRING \"$version\"" >>$file
144 echo "#define SILC_DIST_VERSION_STRING \"$dist_version\"" >>$file
145 echo "#define SILC_PROTOCOL_VERSION_STRING \"SILC-1.0-$version\"" >>$file
146 echo "#define SILC_NAME \"SILC $distribution\"" >>$file
147
148 # preparing irssi
149 echo "Preparing irssi"
150 cd irssi
151 sh autogen.sh 2>/dev/null 1>/dev/null
152 cd ..
153 file=irssi/irssi-version.h.in
154 version_date=`date +%Y%m%d`
155 echo "/* automatically created by autogen.sh */" > $file
156 echo "#define IRSSI_VERSION \"$dist_version (Irssi base: @VERSION@ - SILC base: SILC Toolkit $version)\"" >>$file
157 echo "#define IRSSI_VERSION_DATE $version_date" >> $file
158 echo "#define IRSSI_VERSION_TIME $version_date" >> $file
159
160 echo "Done, now run ./configure and make."