various changes of CVS to git
[platform/upstream/curl.git] / maketgz
1 #! /bin/sh
2 # Script to build release-archives with. Note that this requires a checkout
3 # from git and you should first run ./buildconf and build curl once.
4 #
5 #***************************************************************************
6 #                                  _   _ ____  _
7 #  Project                     ___| | | |  _ \| |
8 #                             / __| | | | |_) | |
9 #                            | (__| |_| |  _ <| |___
10 #                             \___|\___/|_| \_\_____|
11 #
12 # Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
13 #
14 # This software is licensed as described in the file COPYING, which
15 # you should have received as part of this distribution. The terms
16 # are also available at http://curl.haxx.se/docs/copyright.html.
17 #
18 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
19 # copies of the Software, and permit persons to whom the Software is
20 # furnished to do so, under the terms of the COPYING file.
21 #
22 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
23 # KIND, either express or implied.
24 #
25 # $Id$
26 ###########################################################################
27
28 version=$1
29
30 if [ -z "$version" ]; then
31   echo "Specify a version number!"
32   exit
33 fi
34
35 libversion="$version"
36
37 # we make curl the same version as libcurl
38 curlversion=$libversion
39
40 major=`echo $libversion |cut -d. -f1 | sed -e "s/[^0-9]//g"`
41 minor=`echo $libversion |cut -d. -f2 | sed -e "s/[^0-9]//g"`
42 patch=`echo $libversion |cut -d. -f3 | cut -d- -f1 | sed -e "s/[^0-9]//g"`
43
44 numeric=`perl -e 'printf("%02x%02x%02x\n", '"$major, $minor, $patch);"`
45
46 HEADER=include/curl/curlver.h
47 CHEADER=src/version.h
48
49 # requires a date command that knows -u for UTC time zone
50 datestamp=`date -u`
51
52 # Replace version number in header file:
53 sed -e 's/^#define LIBCURL_VERSION .*/#define LIBCURL_VERSION "'$libversion'"/g' \
54     -e 's/^#define LIBCURL_VERSION_NUM .*/#define LIBCURL_VERSION_NUM 0x'$numeric'/g' \
55     -e 's/^#define LIBCURL_VERSION_MAJOR .*/#define LIBCURL_VERSION_MAJOR '$major'/g' \
56     -e 's/^#define LIBCURL_VERSION_MINOR .*/#define LIBCURL_VERSION_MINOR '$minor'/g' \
57     -e 's/^#define LIBCURL_VERSION_PATCH .*/#define LIBCURL_VERSION_PATCH '$patch'/g' \
58     -e "s/^#define LIBCURL_TIMESTAMP .*/#define LIBCURL_TIMESTAMP \"$datestamp\"/g" \
59  $HEADER >$HEADER.dist
60
61 # Replace version number in header file:
62 sed 's/#define CURL_VERSION .*/#define CURL_VERSION "'$curlversion'"/g' $CHEADER >$CHEADER.dist
63
64 # Generate VC8 and VC9 versions from the VC6 Makefile versions
65 for ver in vc8 vc9; do
66   make -f Makefile.dist $ver
67   mv src/Makefile.$ver src/Makefile.$ver.dist
68   mv lib/Makefile.$ver lib/Makefile.$ver.dist
69 done
70
71 # Replace version number in plist file:
72 PLIST=lib/libcurl.plist
73 sed "s/7\.12\.3/$libversion/g" $PLIST > $PLIST.dist
74
75 echo "curl version $curlversion"
76 echo "libcurl version $libversion"
77 echo "libcurl numerical $numeric"
78 echo "datestamp $datestamp"
79
80 findprog()
81 {
82   file="$1"
83   for part in `echo $PATH| tr ':' ' '`; do
84     path="$part/$file"
85     if [ -x "$path" ]; then
86       # there it is!
87       return 1
88     fi
89   done
90
91   # no such executable
92   return 0
93 }
94
95 echo "maketgz: cp lib/curl_config.h.in src/curl_config.h.in"
96 cp lib/curl_config.h.in src/curl_config.h.in
97
98 ############################################################################
99 #
100 # Enforce a rerun of configure (updates the VERSION)
101 #
102
103 echo "Re-running config.status"
104 ./config.status --recheck >/dev/null
105
106 ############################################################################
107 #
108 # automake is needed to run to make a non-GNU Makefile.in if Makefile.am has
109 # been modified.
110 #
111
112 if { findprog automake >/dev/null 2>/dev/null; } then
113   echo "- Could not find or run automake, I hope you know what you're doing!"
114 else
115   echo "Runs automake --include-deps"
116   automake --include-deps Makefile >/dev/null
117 fi
118
119 ############################################################################
120 #
121 # Make sure we have updated HTML versions of all man pages:
122 #
123 echo "make html"
124 make -s html
125
126 # And the PDF versions
127 echo "make pdf"
128 make -s pdf
129
130 ############################################################################
131 #
132 # Now run make dist to generate a tar.gz archive
133 #
134
135 echo "make dist"
136 targz="curl-$version.tar.gz"
137 make -s dist VERSION=$version
138
139 ############################################################################
140 #
141 # Now make a bz2 archive from the tar.gz original
142 #
143
144 bzip2="curl-$version.tar.bz2"
145 echo "Generating $bzip2"
146 gzip -dc $targz | bzip2 --best - > $bzip2
147
148 ############################################################################
149 #
150 # Now make an lzma archive from the tar.gz original
151 #
152
153 lzma="curl-$version.tar.lzma"
154 echo "Generating $lzma"
155 gzip -dc $targz | lzma --best - > $lzma
156
157 ############################################################################
158 #
159 # Now make a zip archive from the tar.gz original
160 #
161 makezip ()
162 {
163   rm -rf $tempdir
164   mkdir $tempdir
165   cd $tempdir
166   gzip -dc ../$targz | tar -xf -
167   find . | zip $zip -@ >/dev/null
168   mv $zip ../
169   cd ..
170   rm -rf $tempdir
171 }
172
173 zip="curl-$version.zip"
174 echo "Generating $zip"
175 tempdir=".builddir"
176 makezip
177
178 echo "------------------"
179 echo "maketgz report:"
180 echo ""
181 ls -l $targz $bzip2 $zip $lzma
182
183 echo "Run this:"
184 echo "gpg -b -a $targz && gpg -b -a $bzip2 && gpg -b -a $zip && gpg -b -a $lzma"