@echo off

set _mcdir=%mcdir%
if x%_mcdir% == x set _mcdir=c:\mc
if not exist %_mcdir%\pc86rl_t.obj goto missingMC

set _LIBDIR=%libdir%
if not exist %_LIBDIR%\suppl_s.lib set _LIBDIR=.
if not exist %_LIBDIR%\suppl_s.lib set _LIBDIR=..
if exist %_LIBDIR%\suppl_s.lib goto makeIt
if x%FREEDOS% == x goto missingLIB
set _LIBDIR=%freedos%\src\lib
if not exist %_LIBDIR%\suppl_s.lib set _LIBDIR=%freedos%\src\lib\mc
if not exist %_LIBDIR%\suppl_s.lib set _LIBDIR=%freedos%\source\lib
if not exist %_LIBDIR%\suppl_s.lib set _LIBDIR=%freedos%\source\lib\mc
if not exist %_LIBDIR%\suppl_s.lib goto missingLIB

:makeIt
cc freemcb.c -flop
if errorlevel 1 goto ende

val /com /nci %_mcdir%\pc86rl_t freemcb,freemcb,nul,%_libdir%\suppl_s %_mcdir%\mclib;
if not errorlevel 1 del freemcb.obj >nul
goto ende

:missingMC
echo Missing Micro-C, either set environment variable MCDIR
echo or copy it to C:\MC.
goto ende

:missingLIB
echo Missing supplemental library SUPPL_S.LIB.
echo Please make it, or set environment variable LIBDIR.

:ende
set _MCDIR=
set _LIBDIR=
