@echo off

REM Version 1.2                                                1997/1/10
REM
REM cygexe.bat : This file is part of the alliance 3.0 patch for OS/2 & WIN32
REM
REM Copyright (C) 1996 Christoph Jaeschke, jaeschke@item.uni-bremen.de
REM
REM This program is free software; you can redistribute it and/or modify
REM it under the terms of the GNU General Public License as published by
REM the Free Software Foundation; either version 2 of the License, or
REM (at your option) any later version.
REM 
REM This program is distributed in the hope that it will be useful,
REM but WITHOUT ANY WARRANTY; without even the implied warranty of
REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
REM GNU General Public License for more details.
REM 
REM You should have received a copy of the GNU General Public License
REM along with this program; if not, write to the Free Software
REM Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

SET loc_SHELLCMD=./
SET loc_REXX_ALLIANCE_BIN=\ALLIANCE\ARCHI\cyg\BIN
SET loc_REXX_ALLIANCE_LIB=\ALLIANCE\ARCHI\cyg\LIB
SET loc_REXX_ALLIANCE_TOOLS=\ALLIANCE\TOOLS
SET loc_ALLIANCE_BIN=/ALLIANCE/ARCHI/cyg/BIN
SET loc_ALLIANCE_TCSHDIR=/ALLIANCE/ARCHI/cyg/BIN/TCSH
SET loc_ALLIANCE_BASHDIR=/ALLIANCE/ARCHI/cyg/BIN/BASH

IF not exist %loc_REXX_ALLIANCE_BIN%\BASH md %loc_REXX_ALLIANCE_BIN%\BASH
IF not exist %loc_REXX_ALLIANCE_BIN%\TCSH md %loc_REXX_ALLIANCE_BIN%\TCSH

echo ******** Compiling C Version of Genlib ********'
echo #define COMPILERNAME "gcc">define.tmp
echo #define CFLAGS1 "">>define.tmp
echo #define CFLAGS2 "">>define.tmp
echo #define CFLAGS3 "">>define.tmp
echo #define ALLIANCE_LIB "-L/alliance/archi/cyg/lib">>define.tmp
echo #define ALLIANCE_INCLUDE "-I/alliance/archi/cyg/include">>define.tmp
echo #define LIBLIST1 "-lMgn322 -lMlu413 -lMpu403 -lMcp402 -lMap405 ">>define.tmp
echo #define LIBLIST2 "-lMmg402 -lMal404 -lMcl408 -lMel406 -lMhl403 ">>define.tmp
echo #define LIBLIST3 "-lMsl611 -lMvl408 -lMph402 -lMlo404 -lMut316">>define.tmp
IF EXIST CFile.c RM CFile.c
cat define.tmp genlibwin32.c > CFile.c
gcc -pipe CFile.c -o %loc_REXX_ALLIANCE_BIN%\genlib.exe
rm CFile.c
rm define.tmp
rm %loc_REXX_ALLIANCE_BIN%\genlib

echo ******** Running sed-script ********

echo s!/bin/rm!rm!g>sed.tmp
echo s!/bin/chmod!chmod!>>sed.tmp
echo s!/bin/sh!bash!>>sed.tmp
echo s!/bin/echo!echo!>>sed.tmp
echo s!/dev/null!nul!>> sed.tmp
echo s/\([^g]\)awk/\1gawk/>>sed.tmp
REM genpat execute
echo s!^\( *\)$LOCAL_RES!\1%loc_SHELLCMD%$LOCAL_RES.exe!>> sed.tmp
REM clean
echo s!$RM -f $LOCAL_RES!$RM -f $LOCAL_RES.exe $LOCAL_RES!>> sed.tmp
REM fpgen execute
echo s!$ROOT $ARGUMENTS!%loc_SHELLCMD%$ROOT.exe $ARGUMENTS!>> sed.tmp
REM clean
echo s/$RM -f $ROOT /$RM -f $ROOT.exe $ROOT />> sed.tmp
REM rest..., not necessary ???
echo s!^frin!%loc_SHELLCMD%frin.exe!>>sed.tmp
echo s!^frout!%loc_SHELLCMD%frout.exe!>>sed.tmp
echo s!^x2y!%loc_SHELLCMD%x2y.exe!>>sed.tmp
echo s!^vticheops!%loc_SHELLCMD%vticheops.exe!>>sed.tmp

SED -f sed.tmp %loc_REXX_ALLIANCE_BIN%\alc2kh > alc2kh
SED -f sed.tmp %loc_REXX_ALLIANCE_BIN%\fpgen-105 > fpgen-105
SED -f sed.tmp %loc_REXX_ALLIANCE_BIN%\fpgen > fpgen
SED -f sed.tmp %loc_REXX_ALLIANCE_BIN%\genpat > genpat
SED -f sed.tmp %loc_REXX_ALLIANCE_BIN%\kh2alc > kh2alc

echo ******** Moving into bash/tcsh subdir *******

for %%y in (genpat fpgen fpgen-105) do MV %%y %loc_REXX_ALLIANCE_BIN%\BASH
for %%y in (alc2kh kh2alc) do MV %%y %loc_REXX_ALLIANCE_BIN%\TCSH
   
echo ******** Appending exe extension *******

for %%y in (logic graal alligator netoptim genview_cc1 tas dreal rfg desb genview amg) do MV %loc_REXX_ALLIANCE_BIN%\%%y %loc_REXX_ALLIANCE_BIN%\%%y.exe
for %%y in (grog ring GenericGNg rage rsa bsg dpr asimut lynx scr bbr syf proof frin) do MV %loc_REXX_ALLIANCE_BIN%\%%y %loc_REXX_ALLIANCE_BIN%\%%y.exe
for %%y in (x2y druc l2p lvx s2r flatrds lca2vbe frout dlx_asm genview_gcc) do MV %loc_REXX_ALLIANCE_BIN%\%%y %loc_REXX_ALLIANCE_BIN%\%%y.exe

echo ******** Compiling GenericGNg *******

for %%y in (invg buffg nand3g nand2g and3g and2g) do call cygexecl.bat %loc_REXX_ALLIANCE_BIN% %%y GenericGNg
for %%y in (nor3g nor2g or3g or2g xnor2g xor2g) do call cygexecl.bat %loc_REXX_ALLIANCE_BIN% %%y GenericGNg
for %%y in (nand2maskg nor2maskg xnor2maskg constg) do call cygexecl.bat %loc_REXX_ALLIANCE_BIN% %%y GenericGNg
for %%y in (nbuseg buseg nmux2csg mux2csg) do call cygexecl.bat %loc_REXX_ALLIANCE_BIN% %%y GenericGNg
for %%y in (mux3cdg mux3csg mux4csg mux5csg mux6csg) do call cygexecl.bat %loc_REXX_ALLIANCE_BIN% %%y GenericGNg
for %%y in (add2sg nulg npl1g pl1g) do call cygexecl.bat %loc_REXX_ALLIANCE_BIN% %%y GenericGNg
for %%y in (pmsnwg pmsnwqg pmsg pmsqg pmstg pmstqg) do call cygexecl.bat %loc_REXX_ALLIANCE_BIN% %%y GenericGNg
for %%y in (pdffnwg pdffnwqg pdffg pdffrg) do call cygexecl.bat %loc_REXX_ALLIANCE_BIN% %%y GenericGNg
for %%y in (pdffqg pdfftg pdffrtg pdfftqg) do call cygexecl.bat %loc_REXX_ALLIANCE_BIN% %%y GenericGNg
   
echo ******** Compiling bash's *******
   
for %%y in (genpat fpgen fpgen-105) do call cygexecl.bat %loc_REXX_ALLIANCE_BIN% %%y bash

echo ******** Compiling tcsh's *******
   
for %%y in (alc2kh kh2alc) do call cygexecl.bat %loc_REXX_ALLIANCE_BIN% %%y tcsh

RM sed.tmp

:end

SET loc_SHELLCMD=
SET loc_REXX_ALLIANCE_BIN=
SET loc_REXX_ALLIANCE_LIB=
SET loc_REXX_ALLIANCE_TOOLS=
SET loc_ALLIANCE_BIN=
SET loc_ALLIANCE_TCSHDIR=
SET loc_ALLIANCE_BASHDIR=
