unix.pl 1.4 KB

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