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