6ad429b5d76821660e0d9ac4cd03419c5688616a
[platform/upstream/curl.git] / maketgz
1 #! /bin/sh
2 # Script to build release-archives with
3 #
4
5 echo "LIB version number?"
6 read version
7
8 libversion="$version"
9
10 echo "CURL version number?"
11 read curlversion
12
13 HEADER=include/curl/curl.h
14 CHEADER=src/version.h
15
16
17 # Replace version number in header file:
18 sed 's/#define LIBCURL_VERSION.*/#define LIBCURL_VERSION "'$libversion'"/g' $HEADER >$HEADER.new
19
20 # Save old header file
21 cp -p $HEADER $HEADER.old
22
23 # Make new header:
24 mv $HEADER.new $HEADER
25
26 # Replace version number in header file:
27 sed 's/#define CURL_VERSION.*/#define CURL_VERSION "'$curlversion'"/g' $CHEADER >$CHEADER.new
28
29 # Save old header file
30 cp -p $CHEADER $CHEADER.old
31
32 # Make new header:
33 mv $CHEADER.new $CHEADER
34
35 findprog()
36 {
37   file="$1"
38   for part in `echo $PATH| tr ':' ' '`; do
39     path="$part/$file"
40     if [ -x "$path" ]; then
41       # there it is!
42       return 1
43     fi
44   done
45
46   # no such executable
47   return 0
48 }
49
50 ############################################################################
51 #
52 # If we have autoconf we can just as well update configure.in to contain our
53 # brand new version number:
54 #
55  
56 if { findprog autoconf >/dev/null 2>/dev/null; } then
57   echo "- No autoconf found, we leave configure as it is"
58 else
59   # Replace version number in configure.in file:
60
61   CONF="configure.in"
62
63   sed 's/^AM_INIT_AUTOMAKE.*/AM_INIT_AUTOMAKE(curl,"'$version'")/g' $CONF >$CONF.new
64
65   # Save old  file
66   cp -p $CONF $CONF.old
67
68   # Make new configure.in
69   mv $CONF.new $CONF
70  
71   # Update the configure script
72   echo "Runs autoconf"
73   autoconf
74 fi
75
76 ############################################################################
77 #
78 # automake is needed to run to make a non-GNU Makefile.in if Makefile.am has
79 # been modified.
80 #
81
82 if { findprog automake >/dev/null 2>/dev/null; } then
83   echo "- Could not find or run automake, I hope you know what you're doing!"
84 else
85   echo "Runs automake --include-deps"
86   automake --include-deps
87 fi
88
89 ############################################################################
90 #
91 # Now run make first to make the file dates decent and make sure that it
92 # compiles just before release!
93 #
94
95 make
96
97 # get current dir
98 dir=`pwd`
99
100 # Get basename
101 orig=`basename $dir`
102
103 # Get the left part of the dash (-)
104 new=`echo $orig | cut -d- -f1`
105
106 # Build new directory name
107 n=$new-$version;
108
109 # Tell the world what we're doing
110 echo "Copying files into distribution archive";
111
112 if [ -r $n ]; then
113   echo "Directory already exists!"
114   exit
115 fi
116
117 # Create the new dir
118 mkdir $n
119
120 # Copy all relevant files, with path and permissions!
121 tar -cf - `cat FILES` | (cd $n; tar -xBpf -)
122
123 # Create the distribution root Makefile from Makefile.dist
124 cp -p Makefile.dist $n/Makefile
125
126 ############################################################################
127 #
128 # Replace @SHELL@ with /bin/sh in the Makefile.in files!
129 #
130 echo "Replace @SHELL@ with /bin/sh in the Makefile.in files"
131 temp=/tmp/curl$$
132 for file in Makefile.in lib/Makefile.in src/Makefile.in; do
133   in="$n/$file"
134   sed "s:@SHELL@:/bin/sh:g" $in >$temp
135   cp $temp $in
136 done
137 rm -rf $temp
138
139 # Tell the world what we're doing
140 echo "creates $n.tar.gz";
141
142 # Make a tar archive of it all
143 tar -cvf $n.tar $n
144
145 # gzip the archive
146 gzip $n.tar
147
148 # Make it world readable
149 chmod a+r $n.tar.gz ;
150
151 # Delete the temp dir
152 rm -rf $n