@echo off
setlocal
REM @(#) /42 1.14 12/12/96 10:20:32 [12/16/96 14:57:04]
REM COMPONENT_NAME: some
REM
REM ORIGINS: 27
REM
REM
REM  25H7912  (C)  COPYRIGHT International Business Machines Corp. 1992,1994,1996 
REM All Rights Reserved
REM Licensed Materials - Property of IBM
REM US Government Users Restricted Rights - Use, duplication or
REM disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
REM

REM SOM Toolkit 2.0 - Create a new Emitter.

REM Make sure we have at least 2 args
if not "%2"=="" goto cont1
    echo "usage: newemit [-C | -C++] <className> <stem>"
    goto done
:cont1

set targetlang=C
if  "%1"=="-C"  goto setc
if  "%1"=="-c"  goto setc
goto cont2
:setc
    set targetlang=C
    shift
:cont2

if "%1"=="-C++" goto setCC
if "%1"=="-c++" goto setCC
goto cont3
:setCC
    set targetlang=C++
    shift
:cont3

if "%2"=="" goto err1
if "%3"=="" goto cont4
:err1
    echo "usage: newemit [-C | -C++] <className> <stem>"
    goto done
:cont4

set class=%1
set stem=%2

echo interface %class% {}; > %stem%.idl

echo %stem%.idl:
sc -aemitfile=_%stem%.idl -adeffile=gen_idl.efw -sgen -mnochk %stem%.idl
del %stem%.idl
rename _%stem%.idl %stem%.idl

if not "%targetlang%" == "C" goto else1
   echo %stem%.c:
   sc -aemitfile=%stem%.c -adeffile=gen_c.efw -sgen -mnochk %stem%.idl
   goto fi1
:else1
   echo %stem%.cpp:
   sc -aemitfile=%stem%.cpp -adeffile=gen_cpp.efw -sgen -mnochk %stem%.idl
:fi1

if not "%targetlang%" =="C" goto else2
   echo emit%stem%.c:
   sc -aemitfile=emit%stem%.c -adeffile=gen_emit.efw -sgen -mnochk %stem%.idl
   goto fi2
:else2
   echo emit%stem%.cpp:
   sc -aemitfile=emit%stem%.cpp -adeffile=gen_emit.efx -sgen -mnochk %stem%.idl
:fi2


echo Makefile:
if not "%targetlang%" == "C"  goto else0
   sc -aemitfile=Makefile -adeffile=gen_make.efw -sgen -mnochk %stem%.idl
   goto fi0
:else0
   sc -aemitfile=Makefile -adeffile=gen_make.efx -sgen -mnochk %stem%.idl
:fi0

echo %stem%.def
sc -aemitfile=emit%stem%.def -adeffile=gen_def.efw -sgen -mnochk %stem%.idl

if exist makefile.nt rename makefile.nt makefile.bak

echo makefile.nt:
if not "%targetlang%" == "C" goto else3
   sc -aemitfile=makefile.nt -adeffile=gen_mknt.efw -sgen -mnochk %stem%.idl
   goto fi3
:else3
   sc -aemitfile=makefile.nt -adeffile=gen_mknt.efx -sgen -mnochk %stem%.idl
:fi3

echo %stem%.nid:
sc -aemitfile=emit%stem%.nid -adeffile=gen_nid.efw -sgen -mnochk %stem%.idl

echo Makefile.32:
if not "%targetlang%" == "C" goto else4
   sc -aemitfile=Makefile.32 -adeffile=gen_mk32.efw -sgen -mnochk %stem%.idl
:else4
   sc -aemitfile=Makefile.32 -adeffile=gen_mk32.efx -sgen -mnochk %stem%.idl
:fi4

echo %stem%.efw:
if not exist %SOMBASE%\include\gen_temp.efw goto else5
    copy %SOMBASE%\include\gen_temp.efw %stem%.efw
    goto fi5
:else5
if not exist %SOMBASE%\include\gen_temp.efw goto fi5
    copy %SOMBASE%\include\gen_temp.efw %stem%.efw
:fi5

:done
endlocal
