Skip to content

Commit d79cdc5

Browse files
mmcnabb-vmsfreddy77
authored andcommitted
VMS: configure from trunk (almost)
Also, read version from version.h instead of Configure. Previous code mistakenly included single quotes in config.h VERSION Manual install of two headers is still required, as they depend on gperf which we don't have a VMS port for. Signed-off-by: Matt McNabb <matthew.mcnabb@vmssoftware.com>
1 parent fca0d7d commit d79cdc5

File tree

4 files changed

+112
-4
lines changed

4 files changed

+112
-4
lines changed

vms/README.vms

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@ run the configuration script like so:
2929

3030
$ @[.vms]configure
3131

32+
or if you are building from a github checkout (as opposed to a release tarball)
33+
34+
$ @[.vms]configure_trunk
35+
3236
This creates a descrip.mms in the top-level source directory which you may
3337
execute by simply running MMK (a freeware MMS alternative available from
3438
https://github.com/endlesssoftware/mmk). You may change some default behaviors
35-
by sypplying one or more of the following macros to the make utility:
39+
by supplying one or more of the following macros to the make utility:
3640

3741
TDSVER
3842

vms/configure.com

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,19 @@ $! from Perl's configure.com, largely the work of Peter Prymmer.
2424
$!
2525
$ SAY := "write sys$output"
2626
$!
27-
$ SEARCH/KEY=(POS:2,SIZE:8) SYS$DISK:[]Configure. "VERSION="/EXACT/OUTPUT=version.tmp
27+
$! Extract the version string from version.h
28+
$ SEARCH [.include.freetds]version.h "#define TDS_VERSION_NO"/EXACT/OUTPUT=version.tmp
2829
$ open/read version version.tmp
2930
$ read version versionline
3031
$ close version
3132
$ delete/noconfirm/nolog version.tmp;*
32-
$ versionstring = f$element(1, "=", f$edit(versionline, "COLLAPSE"))
33+
$ quote = """"
34+
$ vers1 = f$element(1, quote, versionline)
35+
$! Expect "FreeTDS v1.6.dev" etc. - want to put the 1.6.dev bit into config.h
36+
$ offset = f$locate("v", vers1)
37+
$ versionstring = f$extract(offset+1, 99, vers1)
38+
$ write sys$output "Version: ''versionstring'"
39+
$ if versionstring .EQS. "" THEN EXIT 44
3340
$ gosub check_crtl
3441
$!
3542
$! The system-supplied iconv() is fine, but unless the internationalization
@@ -212,7 +219,9 @@ $ @vmsconfigtmp.com
212219
$ delete/noconfirm/nolog vmsconfigtmp.com;
213220
$!
214221
$ Say ""
215-
$ Say "Configuration complete; run MMK or MMS to build."
222+
$ Say "Configuration complete; run MMK to build."
223+
$ Say "Sample build command: mmk/MACRO=(""MSDBLIB""=1,""ODBC""=1,""ODBC_MARS""=1,""ODBC_WIDE""=1)"
224+
$ Say " append 'check' to run tests"
216225
$ EXIT
217226
$!
218227
$ CHECK_CRTL:

vms/configure_trunk.com

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
$! Setup for build from github trunk.
2+
$! @configure.com depends on files present in release tarballs.
3+
$!
4+
$! Requires PERL; Tested with VSI-packaged Perl 5.40-0
5+
$!
6+
$! This is intended to be run by @[.vms]configure_trunk, from project root
7+
$
8+
$! Read version number from configure.ac and apply to version.h and Configure
9+
$ perl [.vms]generate_version.pl
10+
$
11+
$ perl [.src.tds]tds_willconvert.pl include/freetds/proto.h >[.src.tds]tds_willconvert.h
12+
$ perl [.src.tds]num_limits.pl >[.src.tds]num_limits.h
13+
$ perl [.src.tds]types.pl misc/types.csv include/freetds/proto.h >[.src.tds]tds_types.h
14+
$ perl [.src.replacements]iconv_charsets.pl >[.src.replacements]iconv_charsets.h
15+
$ perl [.src.odbc]odbc_export.pl [.src.odbc]odbc.c >[.src.odbc]odbc_export.h
16+
$ perl [.src.odbc]odbc_export.pl [.src.odbc]error.c >[.src.odbc]error_export.h
17+
$
18+
$! encodings.h and charset_lookup.h are generated by PERL with GPerf
19+
$! There's no current port of this at the moment
20+
$! perl [.include.freetds]encodings.pl [.include.freetds] gperf >encodings.h
21+
$ if F$SEARCH("[.include.freetds]encodings.h") .EQS. ""
22+
$ THEN
23+
$ write sys$output "Please obtain include/freetds/encodings.h and include/freetds/charset_lookup.h from a FreeTDS nightly tarball"
24+
$ EXIT 44
25+
$ endif
26+
$
27+
$ @[.vms]configure

vms/generate_version.pl

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
#!/usr/bin/perl
3+
use strict;
4+
use warnings;
5+
6+
my $input_file = 'configure.ac';
7+
my $version_in = 'include/freetds/version.h.in';
8+
my $version_out = 'include/freetds/version.h';
9+
10+
# Extract version from AC_INIT in configure.ac
11+
open my $in, '<', $input_file or die "Cannot open $input_file: $!";
12+
my $version;
13+
while (<$in>) {
14+
if (/AC_INIT\s*\(\s*FreeTDS\s*,\s*([^\)]+)\)/) {
15+
$version = $1;
16+
last;
17+
}
18+
}
19+
close $in;
20+
die "AC_INIT line not found" unless defined $version;
21+
22+
# Replace dev suffix with dev.CURRENTDATE
23+
my @t = localtime();
24+
my $build_number = sprintf("%04d%02d%02d", $t[5]+1900, $t[4]+1, $t[3]);
25+
$version =~ s/\.dev\..*/.dev.$build_number/;
26+
my $output_version = $version;
27+
28+
# Prepare values for usages that require numbers only
29+
# For this purpose, translate 1.6.dev to 1.5.9999
30+
# Currently this appears only to be the ODBC driver version report,
31+
# which expects subversion to have a maximum of 4 digits.
32+
my $ver = $version;
33+
$ver =~ s/dev.*$/9999/; # Replace dev with 9999
34+
$ver =~ s/rc\d*/9999/i; # Replace rc with 9999
35+
my ($major, $minor, $subversion) = split(/\./, $ver);
36+
$major //= 0;
37+
$minor //= 0;
38+
$subversion //= 0;
39+
40+
if ($subversion !~ /^\d{1,4}$/) {
41+
die "Invalid SUBVERSION format: $subversion";
42+
}
43+
44+
if ($subversion eq '9999') {
45+
$minor = $minor - 1;
46+
}
47+
48+
# Substitute tokens in version.h.in
49+
open my $vin, '<', $version_in or die "Cannot open $version_in: $!";
50+
my @lines = <$vin>;
51+
close $vin;
52+
53+
foreach my $line (@lines) {
54+
$line =~ s/\@PACKAGE\@/FreeTDS/g;
55+
$line =~ s/\@VERSION\@/$output_version/g;
56+
$line =~ s/\@MAJOR\@/$major/g;
57+
$line =~ s/\@MINOR\@/$minor/g;
58+
$line =~ s/\@SUBVERSION\@/$subversion/g;
59+
$line =~ s/\@BUILD_NUMBER\@/$build_number/g;
60+
}
61+
62+
open my $vout, '>', $version_out or die "Cannot write $version_out: $!";
63+
print $vout @lines;
64+
close $vout;
65+
66+
print "Generated $version_out successfully.\n";
67+
print "VERSION=$output_version MAJOR=$major MINOR=$minor SUBVERSION=$subversion BUILD_NUMBER=$build_number\n";
68+

0 commit comments

Comments
 (0)