Move to REF_DEBUG, for consistency.
[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_DEBUG"; }
15 elsif ($profile)
16         { $cflags="-pg -O3"; }
17 else
18         { $cflags="-O3 -fomit-frame-pointer"; }
19
20 if (!$no_asm)
21         {
22         $bn_asm_obj='$(OBJ_D)/bn86-elf.o';
23         $bn_asm_src='crypto/bn/asm/bn86unix.cpp';
24         $bnco_asm_obj='$(OBJ_D)/co86-elf.o';
25         $bnco_asm_src='crypto/bn/asm/co86unix.cpp';
26         $des_enc_obj='$(OBJ_D)/dx86-elf.o $(OBJ_D)/yx86-elf.o';
27         $des_enc_src='crypto/des/asm/dx86unix.cpp crypto/des/asm/yx86unix.cpp';
28         $bf_enc_obj='$(OBJ_D)/bx86-elf.o';
29         $bf_enc_src='crypto/bf/asm/bx86unix.cpp';
30         $cast_enc_obj='$(OBJ_D)/cx86-elf.o';
31         $cast_enc_src='crypto/cast/asm/cx86unix.cpp';
32         $rc4_enc_obj='$(OBJ_D)/rx86-elf.o';
33         $rc4_enc_src='crypto/rc4/asm/rx86unix.cpp';
34         $rc5_enc_obj='$(OBJ_D)/r586-elf.o';
35         $rc5_enc_src='crypto/rc5/asm/r586unix.cpp';
36         $md5_asm_obj='$(OBJ_D)/mx86-elf.o';
37         $md5_asm_src='crypto/md5/asm/mx86unix.cpp';
38         $rmd160_asm_obj='$(OBJ_D)/rm86-elf.o';
39         $rmd160_asm_src='crypto/ripemd/asm/rm86unix.cpp';
40         $sha1_asm_obj='$(OBJ_D)/sx86-elf.o';
41         $sha1_asm_src='crypto/sha/asm/sx86unix.cpp';
42         $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM -DOPENSSL_BN_ASM_PART_WORDS";
43         }
44
45 $cflags.=" -DTERMIO -DL_ENDIAN -m486 -Wall";
46
47 if ($shlib)
48         {
49         $shl_cflag=" -DPIC -fpic";
50         $shlibp=".so.$ssl_version";
51         $so_shlibp=".so";
52         }
53
54 sub do_shlib_rule
55         {
56         local($obj,$target,$name,$shlib,$so_name)=@_;
57         local($ret,$_,$Name);
58
59         $target =~ s/\//$o/g if $o ne '/';
60         ($Name=$name) =~ tr/a-z/A-Z/;
61
62         $ret.="$target: \$(${Name}OBJ)\n";
63         $ret.="\t\$(RM) target\n";
64         $ret.="\tgcc \${CFLAGS} -shared -Wl,-soname,$target -o $target \$(${Name}OBJ)\n";
65         ($t=$target) =~ s/(^.*)\/[^\/]*$/$1/;
66         if ($so_name ne "")
67                 {
68                 $ret.="\t\$(RM) \$(LIB_D)$o$so_name\n";
69                 $ret.="\tln -s $target \$(LIB_D)$o$so_name\n\n";
70                 }
71         }
72
73 sub do_link_rule
74         {
75         local($target,$files,$dep_libs,$libs)=@_;
76         local($ret,$_);
77         
78         $file =~ s/\//$o/g if $o ne '/';
79         $n=&bname($target);
80         $ret.="$target: $files $dep_libs\n";
81         $ret.="\t\$(LINK) ${efile}$target \$(LFLAGS) $files $libs\n\n";
82         return($ret);
83         }
84
85 sub do_asm_rule
86         {
87         local($target,$src)=@_;
88         local($ret,@s,@t,$i);
89
90         $target =~ s/\//$o/g if $o ne "/";
91         $src =~ s/\//$o/g if $o ne "/";
92
93         @s=split(/\s+/,$src);
94         @t=split(/\s+/,$target);
95
96         for ($i=0; $i<=$#s; $i++)
97                 {
98                 $ret.="$t[$i]: $s[$i]\n";
99                 $ret.="\tgcc -E -DELF \$(SRC_D)$o$s[$i]|\$(AS) $afile$t[$i]\n\n";
100                 }
101         return($ret);
102         }
103
104 1;