@echo off
rem $Id: mklib.bat 1.5 1992/11/30 11:05:33 karl Exp $
set M=%2
set PLLPTH=%3
if "%1" == "m" goto valid_model
if "%1" == "l" 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=%1libf%M%.lib
if exist %PLLPTH%\%PLLLIB% goto lib_exists
set PLLLIB=%1libf%M%r.lib
if exist %PLLPTH%\%PLLLIB% goto lib_exists
goto error1
:lib_exists
if not exist %1libfp%M%.lib goto targ_no_exist
echo * Warning: File "%1libfp%M%.lib" already exists and will be overwritten.
echo *          Press Ctrl-C to Abort ...
pause
del %1libfp%M%.lib
:targ_no_exist
lib %1libfp%M%.lib; >nul
if not exist %1libfp%M%.lib goto error4
copy tmp50%1.lib %1libfp%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 %1libfp%M% @insmods.lbc
if errorlevel 1 goto error3
rem
rem Delete intermediate object files
rem
call remobjs.bat
del %1libfp%M%.bak
echo *
echo *	Library "%1libfp%M%.lib" created successfully.
echo *
goto end
:usage
echo Usage: MKLIB [ml] [7ea] [dir path]
echo The first two parameters are letters that determine which library
echo to extract files from:
echo	  m : Medium Model 
echo	  l : Large 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:\for\lib)
echo that contains the Microsoft (R) Fortran Compiler library
echo files. The new library will be created in the current directory.
echo Sample Usage:
echo MKLIB m e c:\for\lib      (creates library mLIBFPe.LIB)
goto end
:error1
echo *
echo *  ERROR: Library "%PLLPTH%\%PLLLIB%" 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 "%1libfp%M%.lib".
echo *
goto end
:error4
echo *
echo *	ERROR: Could Not Invoke Librarian "lib.exe"
echo *
:end
set PLLPTH=
set PLLLIB=
rem Microsoft (R) is a registered trademark of Microsoft Corporation.
