d87a6634d15b809d21dc839eb995eb262e834070
[openssl.git] / util / pl / linux.pl
1 #!/usr/local/bin/perl
2 #
3 # linux.pl - the standard unix makefile stuff.
4 #
5
6 $o='/';
7 $cp='/bin/cp';
8 $rm='/bin/rm -f';
9
10 # C compiler stuff
11
12 $cc='gcc';
13 if ($debug)
14         { $cflags="-g2 -ggdb -DREF_CHECK -DCRYPTO_MDEBUG"; }
15 else
16         { $cflags="-O3 -fomit-frame-pointer"; }
17
18 if (!$no_asm)
19         {
20         $bn_mulw_obj='$(OBJ_D)/bn86-elf.o';
21         $bn_mulw_src='crypto/bn/asm/bn86unix.cpp';
22         $des_enc_obj='$(OBJ_D)/dx86-elf.o $(OBJ_D)/yx86-elf.o';
23         $des_enc_src='crypto/des/asm/dx86unix.cpp crypto/des/asm/yx86unix.cpp';
24         $bf_enc_obj='$(OBJ_D)/bx86-elf.o';
25         $bf_enc_src='crypto/bf/asm/bx86unix.cpp';
26         $cast_enc_obj='$(OBJ_D)/cx86-elf.o';
27         $cast_enc_src='crypto/cast/asm/cx86unix.cpp';
28         $rc4_enc_obj='$(OBJ_D)/rx86-elf.o';
29         $rc4_enc_src='crypto/rc4/asm/rx86unix.cpp';
30         $md5_asm_obj='$(OBJ_D)/mx86-elf.o';
31         $md5_asm_src='crypto/md5/asm/mx86unix.cpp';
32         $sha1_asm_obj='$(OBJ_D)/sx86-elf.o';
33         $sha1_asm_src='crypto/sha/asm/sx86unix.cpp';
34         $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM";
35         }
36
37 $cflags.=" -DTERMIO -DL_ENDIAN -m486 -Wall";
38
39 if ($shlib)
40         {
41         $shl_cflag=" -DPIC -fpic";
42         $shlibp=".so.$ssl_version";
43         $so_shlibp=".so";
44         }
45
46 sub do_shlib_rule
47         {
48         local($obj,$target,$name,$shlib,$so_name)=@_;
49         local($ret,$_,$Name);
50
51         $target =~ s/\//$o/g if $o ne '/';
52         ($Name=$name) =~ tr/a-z/A-Z/;
53
54         $ret.="\$(LIB_D)$o$target: \$(${Name}OBJ)\n";
55         $ret.="\t\$(RM) \$(LIB_D)$o$target\n";
56         $ret.="\tgcc \${CFLAGS} -shared -Wl,-soname,$target -o \$(LIB_D)$o$target \$(${Name}OBJ)\n";
57         ($t=$target) =~ s/(^.*)\/[^\/]*$/$1/;
58         if ($so_name ne "")
59                 {
60                 $ret.="\t\$(RM) \$(LIB_D)$o$so_name\n";
61                 $ret.="\tln -s $target \$(LIB_D)$o$so_name\n\n";
62                 }
63         }
64
65 sub do_link_rule
66         {
67         local($target,$files,$dep_libs,$libs)=@_;
68         local($ret,$_);
69         
70         $file =~ s/\//$o/g if $o ne '/';
71         $n=&bname($target);
72         $ret.="$target: $files $dep_libs\n";
73         $ret.="\t\$(LINK) ${efile}$target \$(LFLAGS) $files $libs\n\n";
74         return($ret);
75         }
76
77 sub do_asm_rule
78         {
79         local($target,$src)=@_;
80         local($ret,@s,@t,$i);
81
82         $target =~ s/\//$o/g if $o ne "/";
83         $src =~ s/\//$o/g if $o ne "/";
84
85         @s=split(/\s+/,$src);
86         @t=split(/\s+/,$target);
87
88         for ($i=0; $i<=$#s; $i++)
89                 {
90                 $ret.="$t[$i]: $s[$i]\n";
91                 $ret.="\tgcc -E -DELF \$(SRC_D)$o$s[$i]|\$(AS) $afile$t[$i]\n\n";
92                 }
93         return($ret);
94         }
95
96 1;