Update from 0.9.8-stable.
[openssl.git] / util / pl / unix.pl
1 #!/usr/local/bin/perl
2 #
3 # unix.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 if ($gcc)
13         {
14         $cc='gcc';
15         if ($debug)
16                 { $cflags="-g2 -ggdb"; }
17         else
18                 { $cflags="-O3 -fomit-frame-pointer"; }
19         }
20 else
21         {
22         $cc='cc';
23         if ($debug)
24                 { $cflags="-g"; }
25         else
26                 { $cflags="-O"; }
27         }
28 $obj='.o';
29 $ofile='-o ';
30
31 # EXE linking stuff
32 $link='${CC}';
33 $lflags='${CFLAGS}';
34 $efile='-o ';
35 $exep='';
36 $ex_libs="";
37
38 # static library stuff
39 $mklib='ar r';
40 $mlflags='';
41 $ranlib=&which("ranlib") or $ranlib="true";
42 $plib='lib';
43 $libp=".a";
44 $shlibp=".a";
45 $lfile='';
46
47 $asm='as';
48 $afile='-o ';
49 $bn_asm_obj="";
50 $bn_asm_src="";
51 $des_enc_obj="";
52 $des_enc_src="";
53 $bf_enc_obj="";
54 $bf_enc_src="";
55
56 sub do_lib_rule
57         {
58         local($obj,$target,$name,$shlib)=@_;
59         local($ret,$_,$Name);
60
61         $target =~ s/\//$o/g if $o ne '/';
62         $target="$target";
63         ($Name=$name) =~ tr/a-z/A-Z/;
64
65         $ret.="$target: \$(${Name}OBJ)\n";
66         $ret.="\t\$(RM) $target\n";
67         $ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n";
68         $ret.="\t\$(RANLIB) $target\n\n";
69         }
70
71 sub do_link_rule
72         {
73         local($target,$files,$dep_libs,$libs)=@_;
74         local($ret,$_);
75         
76         $file =~ s/\//$o/g if $o ne '/';
77         $n=&bname($target);
78         $ret.="$target: $files $dep_libs\n";
79         $ret.="\t\$(LINK) ${efile}$target \$(LFLAGS) $files $libs\n\n";
80         return($ret);
81         }
82
83 sub which
84         {
85         my ($name)=@_;
86         my $path;
87         foreach $path (split /:/, $ENV{PATH})
88                 {
89                 if (-x "$path/$name")
90                         {
91                         return "$path/$name";
92                         }
93                 }
94         }
95
96 1;