aboutsummaryrefslogtreecommitdiffstats
path: root/util/pl/linux.pl
blob: d24f7b72913cb2f1e23c893b1a7a16f212e28808 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/local/bin/perl
#
# linux.pl - the standard unix makefile stuff.
#

$o='/';
$cp='/bin/cp';
$rm='/bin/rm -f';

# C compiler stuff

$cc='gcc';
if ($debug)
	{ $cflags="-g2 -ggdb -DREF_CHECK -DCRYPTO_MDEBUG"; }
elsif ($profile)
	{ $cflags="-pg -O3"; }
else
	{ $cflags="-O3 -fomit-frame-pointer"; }

if (!$no_asm)
	{
	$bn_asm_obj='$(OBJ_D)/bn86-elf.o';
	$bn_asm_src='crypto/bn/asm/bn86unix.cpp';
	$bnco_asm_obj='$(OBJ_D)/co86-elf.o';
	$bnco_asm_src='crypto/bn/asm/co86unix.cpp';
	$des_enc_obj='$(OBJ_D)/dx86-elf.o $(OBJ_D)/yx86-elf.o';
	$des_enc_src='crypto/des/asm/dx86unix.cpp crypto/des/asm/yx86unix.cpp';
	$bf_enc_obj='$(OBJ_D)/bx86-elf.o';
	$bf_enc_src='crypto/bf/asm/bx86unix.cpp';
	$cast_enc_obj='$(OBJ_D)/cx86-elf.o';
	$cast_enc_src='crypto/cast/asm/cx86unix.cpp';
	$rc4_enc_obj='$(OBJ_D)/rx86-elf.o';
	$rc4_enc_src='crypto/rc4/asm/rx86unix.cpp';
	$rc5_enc_obj='$(OBJ_D)/r586-elf.o';
	$rc5_enc_src='crypto/rc5/asm/r586unix.cpp';
	$md5_asm_obj='$(OBJ_D)/mx86-elf.o';
	$md5_asm_src='crypto/md5/asm/mx86unix.cpp';
	$rmd160_asm_obj='$(OBJ_D)/rm86-elf.o';
	$rmd160_asm_src='crypto/ripemd/asm/rm86unix.cpp';
	$sha1_asm_obj='$(OBJ_D)/sx86-elf.o';
	$sha1_asm_src='crypto/sha/asm/sx86unix.cpp';
	$cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM -DOPENSSL_BN_ASM_PART_WORDS";
	}

$cflags.=" -DTERMIO -DL_ENDIAN -m486 -Wall";

if ($shlib)
	{
	$shl_cflag=" -DPIC -fpic";
	$shlibp=".so.$ssl_version";
	$so_shlibp=".so";
	}

sub do_shlib_rule
	{
	local($obj,$target,$name,$shlib,$so_name)=@_;
	local($ret,$_,$Name);

	$target =~ s/\//$o/g if $o ne '/';
	($Name=$name) =~ tr/a-z/A-Z/;

	$ret.="$target: \$(${Name}OBJ)\n";
	$ret.="\t\$(RM) target\n";
	$ret.="\tgcc \${CFLAGS} -shared -Wl,-soname,$target -o $target \$(${Name}OBJ)\n";
	($t=$target) =~ s/(^.*)\/[^\/]*$/$1/;
	if ($so_name ne "")
		{
		$ret.="\t\$(RM) \$(LIB_D)$o$so_name\n";
		$ret.="\tln -s $target \$(LIB_D)$o$so_name\n\n";
		}
	}

sub do_link_rule
	{
	local($target,$files,$dep_libs,$libs)=@_;
	local($ret,$_);
	
	$file =~ s/\//$o/g if $o ne '/';
	$n=&bname($target);
	$ret.="$target: $files $dep_libs\n";
	$ret.="\t\$(LINK) ${efile}$target \$(LFLAGS) $files $libs\n\n";
	return($ret);
	}

sub do_asm_rule
	{
	local($target,$src)=@_;
	local($ret,@s,@t,$i);

	$target =~ s/\//$o/g if $o ne "/";
	$src =~ s/\//$o/g if $o ne "/";

	@s=split(/\s+/,$src);
	@t=split(/\s+/,$target);

	for ($i=0; $i<=$#s; $i++)
		{
		$ret.="$t[$i]: $s[$i]\n";
		$ret.="\tgcc -E -DELF \$(SRC_D)$o$s[$i]|\$(AS) $afile$t[$i]\n\n";
		}
	return($ret);
	}

1;