1#! /usr/bin/env perl -w 2use 5.10.0; 3use strict; 4use FindBin; 5use lib "$FindBin::Bin/../openssl/util/perl/OpenSSL"; 6use Text::Template; 7 8our $src_dir = "../openssl"; 9 10my @openssl_headers = shift @ARGV; 11my @crypto_headers = shift @ARGV; 12 13my $include_tmpl = Text::Template->new(TYPE => 'FILE', 14 SOURCE => 'include.h.tmpl', 15 DELIMITERS => [ "%%-", "-%%" ]); 16my $include_conf_tmpl = Text::Template->new(TYPE => 'FILE', 17 SOURCE => 'include_config.tmpl', 18 DELIMITERS => [ "%%-", "-%%" ]); 19my $include_asm_tmpl = Text::Template->new(TYPE => 'FILE', 20 SOURCE => 'include_asm.h.tmpl', 21 DELIMITERS => [ "%%-", "-%%" ]); 22my $include_no_asm_tmpl = Text::Template->new(TYPE => 'FILE', 23 SOURCE => 'include_no-asm.h.tmpl', 24 DELIMITERS => [ "%%-", "-%%" ]); 25 26gen_headers(@openssl_headers, 'openssl'); 27gen_headers(@crypto_headers, 'crypto'); 28 29sub gen_headers { 30 my @headers = split / /, $_[0]; 31 my $inc_dir = $_[1]; 32 foreach my $header_name (@headers) { 33 print("Generating headers for: $header_name\n"); 34 35 # Populate and write header file that will be placed OpenSSL's include 36 # directory. 37 my $include = $include_tmpl->fill_in(HASH => { name => $header_name }); 38 open(INCLUDE, "> $src_dir/include/${inc_dir}/${header_name}.h"); 39 print INCLUDE "$include"; 40 close(INCLUDE); 41 # 42 # Poplulate and write the header in the config directory (currently the same 43 # directory as this file) which will determine which include to use 44 # depending on if asm is available or not. 45 my $include_conf = $include_conf_tmpl->fill_in( 46 HASH => { name => $header_name }); 47 open(INCLUDE_CONF, "> ./${header_name}.h"); 48 print INCLUDE_CONF "$include_conf"; 49 close(INCLUDE_CONF); 50 51 # Poplulate and write the asm header. 52 my $include_asm = $include_asm_tmpl->fill_in( 53 HASH => { asmdir => 'asm', incdir => $inc_dir, name => $header_name }); 54 open(INCLUDE_ASM, "> ./${header_name}_asm.h"); 55 print INCLUDE_ASM "$include_asm"; 56 close(INCLUDE_ASM); 57 58 # Poplulate and write the no-asm header. 59 my $include_no_asm = $include_no_asm_tmpl->fill_in( 60 HASH => { asmdir => 'no-asm', 61 incdir => $inc_dir, 62 name => $header_name }); 63 open(INCLUDE_NO_ASM, "> ./${header_name}_no-asm.h"); 64 print INCLUDE_NO_ASM "$include_no_asm"; 65 close(INCLUDE_NO_ASM); 66 } 67} 68