(linenum→info "unix/slp.c:2238")

openssl/0.9.8g/util/pl/netware.pl

    1: # Metrowerks Codewarrior for NetWare
    2: #
    3: 
    4: # The import files and other misc imports needed to link
    5: @misc_imports = ("GetProcessSwitchCount", "RunningProcess",  
    6:                  "GetSuperHighResolutionTimer");
    7: if ($LIBC)
    8: {
    9:    @import_files = ("libc.imp");
   10:    @module_files = ("libc");
   11: }
   12: else
   13: {
   14:    # clib build
   15:    @import_files = ("clib.imp");
   16:    @module_files = ("clib");
   17:    push(@misc_imports, "_rt_modu64%16", "_rt_divu64%16");
   18: }
   19: if (!$BSDSOCK)
   20: {
   21:    push(@import_files, "ws2nlm.imp");
   22: }
   23:                  
   24: 
   25: # The "IMPORTS" environment variable must be set and point to the location
   26: # where import files (*.imp) can be found.
   27: # Example:  set IMPORTS=c:\ndk\nwsdk\imports
   28: $import_path = $ENV{"IMPORTS"} || die ("IMPORTS environment variable not set\n");
   29: 
   30: 
   31: # The "PRELUDE" environment variable must be set and point to the location
   32: # and name of the prelude source to link with ( nwpre.obj is recommended ).
   33: # Example: set PRELUDE=c:\codewar\novell support\metrowerks support\libraries\runtime\nwpre.obj
   34: $prelude = $ENV{"PRELUDE"} || die ("PRELUDE environment variable not set\n");
   35: 
   36: #$ssl=   "ssleay32";
   37: #$crypto="libeay32";
   38: 
   39: $o='\\\\';
   40: $cp='copy >nul:';
   41: $rm='del';
   42: 
   43: # C compiler
   44: $cc="mwccnlm";
   45: 
   46: # Linker
   47: $link="mwldnlm";
   48: 
   49: # librarian
   50: $mklib="mwldnlm";
   51: 
   52: # assembler 
   53: if ($nw_nasm) 
   54: {
   55:    $asm="nasmw -s -f coff";
   56:    $afile="-o ";
   57:    $asm.=" -g" if $debug;
   58: }
   59: elsif ($nw_mwasm) 
   60: {
   61:    $asm="mwasmnlm -maxerrors 20";
   62:    $afile="-o ";
   63:    $asm.=" -g" if $debug;
   64: }
   65: elsif ($nw_masm)
   66: {
   67: # masm assembly settings - it should be possible to use masm but haven't 
   68: # got it working.
   69: # $asm='ml /Cp /coff /c /Cx';
   70: # $asm.=" /Zi" if $debug;
   71: # $afile='/Fo';
   72:    die("Support for masm assembler not yet functional\n");
   73: }
   74: else 
   75: {
   76:    $asm="";
   77:    $afile="";
   78: }
   79: 
   80: 
   81: 
   82: # compile flags
   83: #
   84: # NOTES: Several c files in the crypto subdirectory include headers from
   85: #        their local directories.  Metrowerks wouldn't find these h files
   86: #        without adding individual include directives as compile flags
   87: #        or modifying the c files.  Instead of adding individual include
   88: #        paths for each subdirectory a recursive include directive
   89: #        is used ( -ir crypto ).
   90: #
   91: #        A similar issue exists for the engines and apps subdirectories.
   92: #
   93: #        Turned off the "possible" warnings ( -w nopossible ).  Metrowerks
   94: #        complained a lot about various stuff.  May want to turn back
   95: #        on for further development.
   96: $cflags="-ir crypto -ir engines -ir apps -msgstyle gcc -align 4 -processor pentium \\
   97:          -char unsigned -w on -w nolargeargs -w nopossible -w nounusedarg \\
   98:          -w noimplicitconv -relax_pointers -nosyspath -DL_ENDIAN \\
   99:          -DOPENSSL_SYSNAME_NETWARE -U_WIN32 -maxerrors 20 ";
  100: 
  101: # link flags
  102: $lflags="-msgstyle gcc -zerobss -stacksize 32768 -nostdlib -sym internal ";
  103: 
  104: 
  105: # additional flags based upon debug | non-debug
  106: if ($debug)
  107: {
  108:    $cflags.=" -opt off -g -sym internal -DDEBUG";
  109: }
  110: else
  111: {
  112: # CodeWarrior compiler has a problem with optimizations for floating
  113: # points - no optimizations until further investigation
  114: #   $cflags.=" -opt all";
  115: }
  116: 
  117: # If LibC build add in NKS_LIBC define and set the entry/exit
  118: # routines - The default entry/exit routines are for CLib and don't exist
  119: # in LibC
  120: if ($LIBC)
  121: {
  122:    $cflags.=" -DNETWARE_LIBC";
  123:    $lflags.=" -entry _LibCPrelude -exit _LibCPostlude -flags pseudopreemption";
  124: }
  125: else
  126: {
  127:    $cflags.=" -DNETWARE_CLIB";
  128:    $lflags.=" -entry _Prelude -exit _Stop";
  129: }
  130: 
  131: # If BSD Socket support is requested, set a define for the compiler
  132: if ($BSDSOCK)
  133: {
  134:    $cflags.=" -DNETWARE_BSDSOCK";
  135: }
  136: 
  137: 
  138: # linking stuff
  139: # for the output directories use the mk1mf.pl values with "_nw" appended
  140: if ($shlib)
  141: {
  142:    if ($LIBC)
  143:    {
  144:       $out_def.="_nw_libc_nlm";
  145:       $tmp_def.="_nw_libc_nlm";
  146:       $inc_def.="_nw_libc_nlm";
  147:    }
  148:    else  # NETWARE_CLIB
  149:    {
  150:       $out_def.="_nw_clib_nlm";
  151:       $tmp_def.="_nw_clib_nlm";
  152:       $inc_def.="_nw_clib_nlm";
  153:    }
  154: }
  155: else
  156: {
  157:    $libp=".lib";
  158:    $shlibp=".lib";
  159:    $lib_flags="-nodefaults -type library";
  160:    if ($LIBC)
  161:    {
  162:       $out_def.="_nw_libc";
  163:       $tmp_def.="_nw_libc";
  164:       $inc_def.="_nw_libc";
  165:    }
  166:    else  # NETWARE_CLIB 
  167:    {
  168:       $out_def.="_nw_clib";
  169:       $tmp_def.="_nw_clib";
  170:       $inc_def.="_nw_clib";
  171:    }
  172: }
  173: 
  174: # used by mk1mf.pl
  175: $obj='.obj';
  176: $ofile='-o ';
  177: $efile='';
  178: $exep='.nlm';
  179: $ex_libs='';
  180: 
  181: if (!$no_asm)
  182: {
  183:    $bn_asm_obj="crypto${o}bn${o}asm${o}bn-nw.obj";
  184:    $bn_asm_src="crypto${o}bn${o}asm${o}bn-nw.asm";
  185:    $des_enc_obj="crypto${o}des${o}asm${o}d-nw.obj crypto${o}des${o}asm${o}y-nw.obj";
  186:    $des_enc_src="crypto${o}des${o}asm${o}d-nw.asm crypto${o}des${o}asm${o}y-nw.asm";
  187:    $bf_enc_obj="crypto${o}bf${o}asm${o}b-nw.obj";
  188:    $bf_enc_src="crypto${o}bf${o}asm${o}b-nw.asm";
  189:    $cast_enc_obj="crypto${o}cast${o}asm${o}c-nw.obj";
  190:    $cast_enc_src="crypto${o}cast${o}asm${o}c-nw.asm";
  191:    $rc4_enc_obj="crypto${o}rc4${o}asm${o}r4-nw.obj";
  192:    $rc4_enc_src="crypto${o}rc4${o}asm${o}r4-nw.asm";
  193:    $rc5_enc_obj="crypto${o}rc5${o}asm${o}r5-nw.obj";
  194:    $rc5_enc_src="crypto${o}rc5${o}asm${o}r5-nw.asm";
  195:    $md5_asm_obj="crypto${o}md5${o}asm${o}m5-nw.obj";
  196:    $md5_asm_src="crypto${o}md5${o}asm${o}m5-nw.asm";
  197:    $sha1_asm_obj="crypto${o}sha${o}asm${o}s1-nw.obj";
  198:    $sha1_asm_src="crypto${o}sha${o}asm${o}s1-nw.asm";
  199:    $rmd160_asm_obj="crypto${o}ripemd${o}asm${o}rm-nw.obj";
  200:    $rmd160_asm_src="crypto${o}ripemd${o}asm${o}rm-nw.asm";
  201:    $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM -DRMD160_ASM";
  202: }
  203: else
  204: {
  205:    $bn_asm_obj='';
  206:    $bn_asm_src='';
  207:    $des_enc_obj='';
  208:    $des_enc_src='';
  209:    $bf_enc_obj='';
  210:    $bf_enc_src='';
  211:    $cast_enc_obj='';
  212:    $cast_enc_src='';
  213:    $rc4_enc_obj='';
  214:    $rc4_enc_src='';
  215:    $rc5_enc_obj='';
  216:    $rc5_enc_src='';
  217:    $md5_asm_obj='';
  218:    $md5_asm_src='';
  219:    $sha1_asm_obj='';
  220:    $sha1_asm_src='';
  221:    $rmd160_asm_obj='';
  222:    $rmd160_asm_src='';
  223: }
  224: 
  225: # create the *.def linker command files in \openssl\netware\ directory
  226: sub do_def_file
  227: {
  228:    # strip off the leading path
  229:    my($target) = bname(@_);
  230:    my($def_file);
  231:    my($mod_file);
  232:    my($i);
  233: 
  234:    if ($target =~ /(.*).nlm/)
  235:    {
  236:       $target = $1;
  237:    }
  238: 
  239:    # special case for openssl - the mk1mf.pl defines E_EXE = openssl
  240:    if ($target =~ /E_EXE/)
  241:    {
  242:       $target = "openssl";
  243:    }
  244: 
  245:    # Note: originally tried to use full path ( \openssl\netware\$target.def )
  246:    # Metrowerks linker choked on this with an assertion failure. bug???
  247:    #
  248:    $def_file = "netware\\$target.def";
  249: 
  250:    open(DEF_OUT, ">$def_file") || die("unable to open file $def_file\n");
  251: 
  252:    print( DEF_OUT "# command file generated by netware.pl for Metrowerks build\n" );
  253:    print( DEF_OUT "#\n");
  254:    print( DEF_OUT "DESCRIPTION \"$target\"\n");
  255:    
  256:    foreach $i (@misc_imports)
  257:    {
  258:       print( DEF_OUT "IMPORT $i\n");
  259:    }
  260:    
  261:    foreach $i (@import_files)
  262:    {
  263:       print( DEF_OUT "IMPORT \@$import_path\\$i\n");
  264:    }
  265:    
  266:    foreach $i (@module_files)
  267:    {
  268:       print( DEF_OUT "MODULE $i\n");
  269:    }
  270: 
  271:    close(DEF_OUT);
  272:    return($def_file);
  273: }
  274: 
  275: sub do_lib_rule
  276: {
  277:    my($objs,$target,$name,$shlib)=@_;
  278:    my($ret);
  279: 
  280:    $ret.="$target: $objs\n";
  281:    if (!$shlib)
  282:    {
  283:       $ret.="\t\@echo Building Lib: $name\n";
  284:       $ret.="\t\$(MKLIB) $lib_flags -o $target $objs\n";
  285:       $ret.="\t\@echo .\n"
  286:    }
  287:    else
  288:    {
  289:       die( "Building as NLM not currently supported!" );
  290:    }
  291: 
  292:    $ret.="\n";
  293:    return($ret);
  294: }
  295: 
  296: sub do_link_rule
  297: {
  298:    my($target,$files,$dep_libs,$libs)=@_;
  299:    my($ret);
  300:    my($def_file);
  301: 
  302:    $def_file = do_def_file($target);
  303: 
  304:    # special case for openssl - the mk1mf.pl defines E_EXE = openssl
  305: 
  306:    # NOTE:  When building the test nlms no screen name is given
  307:    #  which causes the console screen to be used.  By using the console
  308:    #  screen there is no "<press any key to continue>" message which
  309:    #  requires user interaction.  The test script ( tests.pl ) needs to be
  310:    #  able to run the tests without requiring user interaction.
  311:    #
  312:    #  However, the sample program "openssl.nlm" is used by the tests and is
  313:    #  a interactive sample so a screen is desired when not be run by the
  314:    #  tests.  To solve the problem, two versions of the program are built:
  315:    #    openssl2 - no screen used by tests
  316:    #    openssl - default screen - use for normal interactive modes
  317:    #
  318:    if ($target =~ /E_EXE/)
  319:    {
  320:       my($target2) = $target;
  321: 
  322:       $target2 =~ s/\(E_EXE\)/\(E_EXE\)2/;
  323: 
  324:       $ret.="$target: $files $dep_libs\n";
  325: 
  326:          # openssl
  327:       $ret.="\t\$(LINK) \$(LFLAGS) -screenname openssl -commandfile $def_file $files \"$prelude\" $libs -o $target\n";
  328:          # openssl2
  329:       $ret.="\t\$(LINK) \$(LFLAGS) -commandfile $def_file $files \"$prelude\" $libs -o $target2\n";
  330:    }
  331:    else
  332:    {
  333:       $ret.="$target: $files $dep_libs\n";
  334:       $ret.="\t\$(LINK) \$(LFLAGS) -commandfile $def_file $files \"$prelude\" $libs -o $target\n";
  335:    }
  336: 
  337:    $ret.="\n";
  338:    return($ret);
  339: }
  340: 
  341: 1;
Syntax (Markdown)