@echo off
rem $Id: mklib.bat 1.2 1992/11/30 11:59:53 karl Exp $
set M=%2
set PLLPTH=%3
if "%1" == "s" goto valid_model
if "%1" == "m" goto valid_model
if "%1" == "l" goto valid_model
if "%1" == "c" goto valid_model
if "%2" == "e" goto valid_model
if "%2" == "7" goto valid_model
if "%2" == "a" goto valid_model
goto usage
:valid_model
if "%PLLPTH%" == "" goto no_path
goto path_supplied
:no_path
set PLLPTH=.
:path_supplied
set PLLLIB=%1libc%M%.lib
if exist %PLLPTH%\%PLLLIB% goto lib_exists
set PLLLIB=%1libc%M%r.lib
if exist %PLLPTH%\%PLLLIB% goto lib_exists
goto error1
:lib_exists
if not exist %1libp%M%.lib goto targ_no_exist
echo * Warning: File "%1libp%M%.lib" already exists and will be overwritten.
echo *          Press Ctrl-C to Abort ...
pause
del %1libp%M%.lib
:targ_no_exist
lib %1libp%M%.lib; > nul
if not exist %1libp%M%.lib goto error4
copy tmp51%1.lib %1libp%M%.lib
rem
rem Extract OBJs from MS libraries
rem
lib %PLLPTH%\%PLLLIB% @extmods.lbc
if errorlevel 1 goto error2
rem
rem Create new library
rem
lib %1libp%M% @insmods.lbc
if errorlevel 1 goto error3
rem
rem Delete intermediate object files
rem
call remobjs.bat
del %1libp%M%.bak
echo *
echo *	Library "%1libp%M%.lib" created successfully.
echo *
goto end
:usage
echo Usage: MKLIB [smlc] [7ea] [dir path]
echo The first two parameters are letters that determine which library
echo to extract files from:
echo	  s : Small Model 
echo	  m : Medium Model 
echo	  l : Large Model 
echo	  c : Compact Model 
echo	  e : Emulation Libraries
echo	  7 : 80x87 Libraries 
echo	  a : Alternate Math Libraries
echo The third parameter is the path to the DIRECTORY (e.g. c:\lib )
echo that contains the Microsoft (R) C Optimizing Compiler library
echo files. The new library will be created in the current directory.
echo Sample Usage:
echo MKLIB s e c:\msc\lib      (creates library sLIBPe.LIB)
goto end
:error1
echo *
echo *  ERROR: Library "%PLLPTH%\%1libc%M%.lib" Not Found.
echo *
goto end
:error2
echo *
echo *	ERROR: Could Not Extract Modules from library "%PLLLIB%".
echo *
goto end
:error3
echo *
echo *	ERROR: Could Not Create New Library "%1libp%M%.lib".
echo *
goto end
:error4
echo *
echo *	ERROR: Could Not Invoke Librarian "lib.exe"
echo *
goto end
:end
set PLLPTH=
set PLLLIB=
rem Microsoft (R) is a registered trademark of Microsoft Corporation.
