xref: /netbsd-src/crypto/external/bsd/heimdal/dist/cf/w32-detect-vc-version.pl (revision ca1c9b0c534faa5fd4c7d36fd3c199a2a3d7b0e4)
1*ca1c9b0cSelric########################################################################
2*ca1c9b0cSelric#
3*ca1c9b0cSelric# Copyright (c) 2010, Secure Endpoints Inc.
4*ca1c9b0cSelric# All rights reserved.
5*ca1c9b0cSelric#
6*ca1c9b0cSelric# Redistribution and use in source and binary forms, with or without
7*ca1c9b0cSelric# modification, are permitted provided that the following conditions
8*ca1c9b0cSelric# are met:
9*ca1c9b0cSelric#
10*ca1c9b0cSelric# - Redistributions of source code must retain the above copyright
11*ca1c9b0cSelric#   notice, this list of conditions and the following disclaimer.
12*ca1c9b0cSelric#
13*ca1c9b0cSelric# - Redistributions in binary form must reproduce the above copyright
14*ca1c9b0cSelric#   notice, this list of conditions and the following disclaimer in
15*ca1c9b0cSelric#   the documentation and/or other materials provided with the
16*ca1c9b0cSelric#   distribution.
17*ca1c9b0cSelric#
18*ca1c9b0cSelric# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19*ca1c9b0cSelric# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20*ca1c9b0cSelric# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21*ca1c9b0cSelric# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22*ca1c9b0cSelric# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23*ca1c9b0cSelric# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24*ca1c9b0cSelric# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25*ca1c9b0cSelric# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26*ca1c9b0cSelric# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27*ca1c9b0cSelric# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28*ca1c9b0cSelric# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29*ca1c9b0cSelric# POSSIBILITY OF SUCH DAMAGE.
30*ca1c9b0cSelric#
31*ca1c9b0cSelric
32*ca1c9b0cSelric# Try to detect the version of Visual C++ in use by parsing the output
33*ca1c9b0cSelric# of cl.exe.
34*ca1c9b0cSelric
35*ca1c9b0cSelric$cl_cmd = shift;
36*ca1c9b0cSelric
37*ca1c9b0cSelricdie "C compiler command should be specified" if ($cl_cmd eq '');
38*ca1c9b0cSelric
39*ca1c9b0cSelricopen(CL, '-|', $cl_cmd." 2>&1") or die "Can't run C compiler command [$cl_cmd]";
40*ca1c9b0cSelric
41*ca1c9b0cSelric$verline = <CL>;
42*ca1c9b0cSelric
43*ca1c9b0cSelricif ($verline =~ /(\d+).(\d+).(\d+).(\d+)/) {
44*ca1c9b0cSelric    print "Found Version: $1.$2.$3.$4\n";
45*ca1c9b0cSelric    exit $1 + 0;
46*ca1c9b0cSelric} else {
47*ca1c9b0cSelric    print "Mismatch";
48*ca1c9b0cSelric    exit 1;
49*ca1c9b0cSelric}
50