Git init
[external/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 ###########################################################################
26
27 version=$1
28
29 if [ -z "$version" ]; then
30   echo "Specify a version number!"
31   exit
32 fi
33
34 libversion="$version"
35
36 # we make curl the same version as libcurl
37 curlversion=$libversion
38
39 major=`echo $libversion |cut -d. -f1 | sed -e "s/[^0-9]//g"`
40 minor=`echo $libversion |cut -d. -f2 | sed -e "s/[^0-9]//g"`
41 patch=`echo $libversion |cut -d. -f3 | cut -d- -f1 | sed -e "s/[^0-9]//g"`
42
43 numeric=`perl -e 'printf("%02x%02x%02x\n", '"$major, $minor, $patch);"`
44
45 HEADER=include/curl/curlver.h
46 CHEADER=src/version.h
47
48 # requires a date command that knows -u for UTC time zone
49 datestamp=`date -u`
50
51 # Replace version number in header file:
52 sed -e 's/^#define LIBCURL_VERSION .*/#define LIBCURL_VERSION "'$libversion'"/g' \
53     -e 's/^#define LIBCURL_VERSION_NUM .*/#define LIBCURL_VERSION_NUM 0x'$numeric'/g' \
54     -e 's/^#define LIBCURL_VERSION_MAJOR .*/#define LIBCURL_VERSION_MAJOR '$major'/g' \
55     -e 's/^#define LIBCURL_VERSION_MINOR .*/#define LIBCURL_VERSION_MINOR '$minor'/g' \
56     -e 's/^#define LIBCURL_VERSION_PATCH .*/#define LIBCURL_VERSION_PATCH '$patch'/g' \
57     -e "s/^#define LIBCURL_TIMESTAMP .*/#define LIBCURL_TIMESTAMP \"$datestamp\"/g" \
58  $HEADER >$HEADER.dist
59
60 # Replace version number in header file:
61 sed 's/#define CURL_VERSION .*/#define CURL_VERSION "'$curlversion'"/g' $CHEADER >$CHEADER.dist
62
63 # Generate VC8, VC9, and VC10 versions from the VC6 Makefile versions
64 for ver in vc8 vc9 vc10; do
65   make -f Makefile.dist $ver
66   mv src/Makefile.$ver src/Makefile.$ver.dist
67   mv lib/Makefile.$ver lib/Makefile.$ver.dist
68 done
69
70 # Replace version number in plist file:
71 PLIST=lib/libcurl.plist
72 sed "s/7\.12\.3/$libversion/g" $PLIST > $PLIST.dist
73
74 echo "curl version $curlversion"
75 echo "libcurl version $libversion"
76 echo "libcurl numerical $numeric"
77 echo "datestamp $datestamp"
78
79 findprog()
80 {
81   file="$1"
82   for part in `echo $PATH| tr ':' ' '`; do
83     path="$part/$file"
84     if [ -x "$path" ]; then
85       # there it is!
86       return 1
87     fi
88   done
89
90   # no such executable
91   return 0
92 }
93
94 echo "maketgz: cp lib/curl_config.h.in src/curl_config.h.in"
95 cp lib/curl_config.h.in src/curl_config.h.in
96
97 ############################################################################
98 #
99 # Enforce a rerun of configure (updates the VERSION)
100 #
101
102 echo "Re-running config.status"
103 ./config.status --recheck >/dev/null
104
105 ############################################################################
106 #
107 # automake is needed to run to make a non-GNU Makefile.in if Makefile.am has
108 # been modified.
109 #
110
111 if { findprog automake >/dev/null 2>/dev/null; } then
112   echo "- Could not find or run automake, I hope you know what you're doing!"
113 else
114   echo "Runs automake --include-deps"
115   automake --include-deps Makefile >/dev/null
116 fi
117
118 ############################################################################
119 #
120 # Make sure we have updated HTML versions of all man pages:
121 #
122 echo "make html"
123 make -s html
124
125 # And the PDF versions
126 echo "make pdf"
127 make -s pdf
128
129 echo "produce CHANGES"
130 git log --pretty=fuller --no-color --date=short --decorate=full -1000 | ./log2changes.pl > CHANGES.dist
131
132 ############################################################################
133 #
134 # Now run make dist to generate a tar.gz archive
135 #
136
137 echo "make dist"
138 targz="curl-$version.tar.gz"
139 make -s dist VERSION=$version
140
141 ############################################################################
142 #
143 # Now make a bz2 archive from the tar.gz original
144 #
145
146 bzip2="curl-$version.tar.bz2"
147 echo "Generating $bzip2"
148 gzip -dc $targz | bzip2 --best - > $bzip2
149
150 ############################################################################
151 #
152 # Now make an lzma archive from the tar.gz original
153 #
154
155 lzma="curl-$version.tar.lzma"
156 echo "Generating $lzma"
157 gzip -dc $targz | lzma --best - > $lzma
158
159 ############################################################################
160 #
161 # Now make a zip archive from the tar.gz original
162 #
163 makezip ()
164 {
165   rm -rf $tempdir
166   mkdir $tempdir
167   cd $tempdir
168   gzip -dc ../$targz | tar -xf -
169   find . | zip $zip -@ >/dev/null
170   mv $zip ../
171   cd ..
172   rm -rf $tempdir
173 }
174
175 zip="curl-$version.zip"
176 echo "Generating $zip"
177 tempdir=".builddir"
178 makezip
179
180 echo "------------------"
181 echo "maketgz report:"
182 echo ""
183 ls -l $targz $bzip2 $zip $lzma
184
185 echo "Run this:"
186 echo "gpg -b -a $targz && gpg -b -a $bzip2 && gpg -b -a $zip && gpg -b -a $lzma"