1#!/usr/bin/env perl
2# Copyright (C) Daniel Stenberg
3# SPDX-License-Identifier: MIT
4
5$version = $ARGV[0];
6
7if($version eq "") {
8    print "Enter version number!\n";
9    exit;
10}
11
12if(!-f "include/ares.h") {
13    print "run this script in the ares source root dir\n";
14    exit;
15}
16
17my ($major, $minor, $patch)=split(/\./, $version);
18
19$major += 0;
20$minor += 0;
21$patch += 0;
22
23open(VER, "<include/ares_version.h") ||
24    die "can't open include/ares_version.h";
25open(NEWV, ">include/ares_version.h.dist");
26while(<VER>) {
27    $_ =~ s/^\#define ARES_VERSION_MAJOR .*/\#define ARES_VERSION_MAJOR $major/;
28    $_ =~ s/^\#define ARES_VERSION_MINOR .*/\#define ARES_VERSION_MINOR $minor/;
29    $_ =~ s/^\#define ARES_VERSION_PATCH .*/\#define ARES_VERSION_PATCH $patch/;
30    $_ =~ s/^\#define ARES_VERSION_STR .*/\#define ARES_VERSION_STR \"$version\"/;
31
32    print NEWV $_;
33}
34close(VER);
35close(NEWV);
36print "include/ares_version.h.dist created\n";
37
38if(!-f "configure") {
39    print "running buildconf\n";
40    `./buildconf`;
41}
42print "adding $version in the configure.ac file\n";
43`sed -e 's/AC_INIT.*/AC_INIT([c-ares], [$version],/' < configure.ac > configure.ac.dist`;
44
45print "adding $version in the CMakeLists.txt file\n";
46`sed -e 's/SET.*CARES_VERSION.*/SET (CARES_VERSION "$version")/' < CMakeLists.txt > CMakeLists.txt.dist && rm -f CMakeLists.txt && mv CMakeLists.txt.dist CMakeLists.txt`;
47
48# now make a new configure script with this
49print "makes a new configure script\n";
50`autoconf configure.ac.dist >configure`;
51
52# now run this new configure to get a fine makefile
53print "running configure\n";
54`./configure`;
55
56print "produce CHANGES\n";
57`git log --pretty=fuller --no-color --date=short --decorate=full -1000 | ./git2changes.pl > CHANGES.dist`;
58
59# now make the actual tarball
60print "running make dist\n";
61`make dist VERSION=$version`;
62
63# remove temporary sourced man pages
64`make -s clean-sourced-manpages`;
65
66print "removing temporary configure.ac file\n";
67`rm configure.ac.dist`;
68print "removing temporary ares_version.h file\n";
69`rm include/ares_version.h.dist`;
70
71print "NOTE: now tag this release!\n";
72