offer a friendlier single-line command
[platform/upstream/curl.git] / maketgz
1 #! /bin/sh
2 # Script to build release-archives with
3 #
4
5 version=$1
6
7 if [ -z "$version" ]; then
8   echo "Specify a version number!"
9   exit
10 fi
11
12 libversion="$version"
13
14 # we make curl the same version as libcurl
15 curlversion=$libversion
16
17 major=`echo $libversion |cut -d. -f1 | sed -e "s/[^0-9]//g"`
18 minor=`echo $libversion |cut -d. -f2 | sed -e "s/[^0-9]//g"`
19 patch=`echo $libversion |cut -d. -f3 | cut -d- -f1 | sed -e "s/[^0-9]//g"`
20
21 numeric=`perl -e 'printf("%02x%02x%02x\n", '"$major, $minor, $patch);"`
22
23 HEADER=include/curl/curlver.h
24 CHEADER=src/version.h
25
26 # requires a date command that knows -u for UTC time zone
27 datestamp=`date -u`
28
29 # Replace version number in header file:
30 sed -e 's/^#define LIBCURL_VERSION .*/#define LIBCURL_VERSION "'$libversion'"/g' \
31     -e 's/^#define LIBCURL_VERSION_NUM .*/#define LIBCURL_VERSION_NUM 0x'$numeric'/g' \
32     -e 's/^#define LIBCURL_VERSION_MAJOR .*/#define LIBCURL_VERSION_MAJOR '$major'/g' \
33     -e 's/^#define LIBCURL_VERSION_MINOR .*/#define LIBCURL_VERSION_MINOR '$minor'/g' \
34     -e 's/^#define LIBCURL_VERSION_PATCH .*/#define LIBCURL_VERSION_PATCH '$patch'/g' \
35     -e "s/^#define LIBCURL_TIMESTAMP .*/#define LIBCURL_TIMESTAMP \"$datestamp\"/g" \
36  $HEADER >$HEADER.dist
37
38 # Replace version number in header file:
39 sed 's/#define CURL_VERSION .*/#define CURL_VERSION "'$curlversion'"/g' $CHEADER >$CHEADER.dist
40
41 echo "generate VC8 makefiles"
42 # Generate VC8 versions from the VC6 Makefile versions 
43 sed -e "s#/GX /DWIN32 /YX#/EHsc /DWIN32#" -e 's#/GZ#/RTC1#' -e 's/wsock32.lib/wsock32.lib bufferoverflowu.lib/g' -e 's/VC6/VC8/g' lib/Makefile.vc6 > lib/Makefile.vc8.dist
44 sed -e "s#/GX /DWIN32 /YX#/EHsc /DWIN32#" -e 's#/GZ#/RTC1#' -e 's/wsock32.lib/wsock32.lib bufferoverflowu.lib/g' -e 's/VC6/VC8/g' src/Makefile.vc6 > src/Makefile.vc8.dist
45
46 # Replace version number in plist file:
47 PLIST=lib/libcurl.plist
48 sed "s/7\.12\.3/$libversion/g" $PLIST > $PLIST.dist
49
50 echo "curl version $curlversion"
51 echo "libcurl version $libversion"
52 echo "libcurl numerical $numeric"
53 echo "datestamp $datestamp"
54
55 findprog()
56 {
57   file="$1"
58   for part in `echo $PATH| tr ':' ' '`; do
59     path="$part/$file"
60     if [ -x "$path" ]; then
61       # there it is!
62       return 1
63     fi
64   done
65
66   # no such executable
67   return 0
68 }
69
70 echo "maketgz: cp lib/config.h.in src/config.h.in"
71 cp lib/config.h.in src/config.h.in
72
73 ############################################################################
74 #
75 # Enforce a rerun of configure (updates the VERSION)
76 #
77
78 echo "Re-running config.status"
79 ./config.status --recheck >/dev/null
80
81 ############################################################################
82 #
83 # automake is needed to run to make a non-GNU Makefile.in if Makefile.am has
84 # been modified.
85 #
86
87 if { findprog automake >/dev/null 2>/dev/null; } then
88   echo "- Could not find or run automake, I hope you know what you're doing!"
89 else
90   echo "Runs automake --include-deps"
91   automake --include-deps Makefile >/dev/null
92 fi
93
94 ############################################################################
95 #
96 # Make sure we have updated HTML versions of all man pages:
97 #
98 echo "make html"
99 make -s html
100
101 # And the PDF versions
102 echo "make pdf"
103 make -s pdf
104
105 ############################################################################
106 #
107 # Now run make dist to generate a tar.gz archive
108 #
109
110 echo "make dist"
111 targz="curl-$version.tar.gz"
112 make -s dist VERSION=$version
113
114 ############################################################################
115 #
116 # Now make a bz2 archive from the tar.gz original
117 #
118
119 bzip2="curl-$version.tar.bz2"
120 echo "Generating $bzip2"
121 gzip -dc $targz | bzip2 - > $bzip2
122
123 ############################################################################
124 #
125 # Now make a zip archive from the tar.gz original
126 #
127 makezip ()
128 {
129   rm -rf $tempdir
130   mkdir $tempdir
131   cd $tempdir
132   gzip -dc ../$targz | tar -xf -
133   find . | zip $zip -@ >/dev/null
134   mv $zip ../
135   cd ..
136   rm -rf $tempdir
137 }
138
139 zip="curl-$version.zip"
140 echo "Generating $zip"
141 tempdir=".builddir"
142 makezip
143
144 echo "------------------"
145 echo "maketgz report:"
146 echo ""
147 ls -l $targz $bzip2 $zip
148
149 md5sum $targz $bzip2 $zip
150
151 echo "Run this:"
152 echo "gpg -b -a $targz && gpg -b -a $bzip2 && gpg -b -a $zip"