3 # Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
5 # Permission to use, copy, modify, and/or distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 # PERFORMANCE OF THIS SOFTWARE.
17 # Id: setpk11provider.pl,v 1.2 2009/10/12 16:41:13 each Exp
20 # This script sets the PKCS#11 provider name in the build scripts.
22 # for instance: setpk11provider.pl bp201w32HSM
26 die "Usage: perl setpk11provider.pl <pkcs11_provider_dll_name>\n"
29 my $provider=$ARGV[0];
31 $provider =~ s
|\
.[dD
][lL
][lL
]$||;
33 # List of files that need to be updated
34 @filelist = ("../bin/pkcs11/win32//pk11keygen.mak",
35 "../bin/pkcs11/win32//pk11keygen.dsp",
36 "../bin/pkcs11/win32//pk11list.mak",
37 "../bin/pkcs11/win32//pk11list.dsp",
38 "../bin/pkcs11/win32//pk11destroy.mak",
39 "../bin/pkcs11/win32//pk11destroy.dsp");
41 # function to replace the provider define
43 my($filename, $substr, $line);
49 open (RFILE
, $filename) || die "Can't open file $filename: $!";
54 foreach $line (@Lines) {
55 $line =~ s/unknown_provider/$substr/gi;
58 open (RFILE
, ">$filename") || die "Can't open file $filename: $!";
59 foreach $line (@Lines) {
65 # update config.h to define or undefine USE_PKCS11
67 my($havexml, $substr, $line);
72 open (RFILE
, "../config.h") || die "Can't open config.h";
76 foreach $line (@Lines) {
78 $line =~ s/^.*#undef USE_PKCS11.*$/define USE_PKCS11 1/;
80 $line =~ s/^#define USE_PKCS11 .*$/\/\
* #undef USE_PKCS11 \*\//;
84 open (RFILE
, ">../config.h") || die "Can't open config.h";
85 print "Updating file ../config.h\n";
86 foreach $line (@Lines) {
92 #Update the list of files
95 print "Provider is $provider\n";
96 foreach $file (@filelist) {
97 print "Updating file $file\n";
98 updatefile
($file, $provider);