@echo OFF

if .==.%1           goto error1
if not exist %1.nap goto error2

if exist %1.tmp     del %1.tmp
if exist %1.c       del %1.c
if exist %1.exe     del %1.exe
if exist %1.out     del %1.out

:init1

rem  Initialize variables if not already done
call \Simulate\Napados\Dos\UserInit.bat

echo ===============================================================================
echo.

echo %1   **** MAC PREPROCESSOR running
\Simulate\Macdos\Dos\Macdos.exe -l -c %1.nap > %1.tmp

if errorlevel 1     goto error0
if not exist %1.tmp goto error0

title [ %1.c ]

echo %1   **** NAPA COMPILER    running

\Simulate\Napados\Dos\Napados.exe %1.tmp -dir /Simulate/Napados -user %OWNER% > %1.c

if errorlevel 1     goto error0
if not exist %1.c   goto error0


echo %1   **** GCC ANSI-C COMPILER  running
     gcc    -s -$(TARG) -D__USE_MINGW_ANSI_STDIO=1 -fopenmp                   -O2 -Wall                         -O %1.c -o %1
rem  gcc -g -s -$(TARG) -D__USE_MINGW_ANSI_STDIO=1 -fopenmp -fstrict-aliasing -O2 -Wall -W -Wmissing-prototypes -O %1.c -o %1

if errorlevel 1     goto error0
if not exist %1.exe goto error0

goto end

:error0

echo.
echo %1   **** ABNORMAL TERMINATION
color FC
title [ Error ]
pause

color F0

goto end

:error1
echo %1   **** Input file is missing. No Processing.

goto end

:error2
echo %1   **** Input file %1.nap does not exist. No Processing.

:end
echo.
