@echo off REM ************************************************************ REM * Validate arguments REM ************************************************************ IF "%1" == "" GOTO usage IF "%2" == "" GOTO usage IF "%1" == "tcl" GOTO good_lang IF "%1" == "python" GOTO good_lang IF "%1" == "perl" GOTO good_lang IF "%1" == "ruby" GOTO good_lang IF "%1" == "guile" GOTO good_lang IF "%1" == "mzscheme" GOTO good_lang IF "%1" == "php" GOTO good_lang IF "%1" == "ocaml" GOTO good_lang IF "%1" == "pike" GOTO good_lang IF "%1" == "chicken" GOTO good_lang GOTO bad_lang :good_lang REM ************************************************************ REM * Find SWIG library Directory REM ************************************************************ IF NOT "%swig_lib%" == "" GOTO dirset REM Try autodetection, need to enable command extensions for this SETLOCAL ENABLEEXTENSIONS REM Error out if SETLOCAL failed IF ERRORLEVEL 1 GOTO no_swig_lib REM Error out if command extensions still aren't enabled SET errorlevel= IF [] == [%errorlevel%] GOTO no_swig_lib REM Set SWIG_LIB variable to output of "swig -swiglib" command FOR /F "usebackq delims==" %%i IN (`swig -swiglib`) DO SET swig_lib=%%i :dirset REM ************************************************************ REM * Make sure the SWIG library directory exists REM ************************************************************ IF NOT EXIST "%swig_lib%\common.swg" GOTO bad_swig_lib IF "%swig_lib%" == "" GOTO bad_swig_lib REM ************************************************************ REM * Write SWIG runtime code to file. The sections below are REM * based on SWIG's Runtime\Makefile.in targets REM ************************************************************ GOTO %1 :tcl TYPE "%swig_lib%\common.swg" > %2 TYPE "%swig_lib%\tcl\swigtcl8.swg" >> %2 GOTO success :python ECHO #include "Python.h" > %2 TYPE "%swig_lib%\common.swg" >> %2 TYPE "%swig_lib%\python\pyrun.swg" >> %2 GOTO success :perl TYPE "%swig_lib%\common.swg" > %2 TYPE "%swig_lib%\perl5\perlrun.swg" >> %2 GOTO success :ruby TYPE "%swig_lib%\common.swg" > %2 TYPE "%swig_lib%\ruby\rubyhead.swg" >> %2 TYPE "%swig_lib%\ruby\rubydef.swg" >> %2 GOTO success :guile TYPE "%swig_lib%\guile\guiledec.swg" > %2 TYPE "%swig_lib%\guile\guile.swg" >> %2 GOTO success :mzscheme TYPE %swig_lib%\mzscheme\mzschemedec.swg" > %2 TYPE %swig_lib%\mzscheme\mzscheme.swg" >> %2 GOTO success :php TYPE "%swig_lib%\common.swg" > %2 TYPE "%swig_lib%\php4\php4run.swg" >> %2 GOTO success :ocaml TYPE "%swig_lib%\ocaml\libswigocaml.swg" > %2 GOTO success :pike TYPE "%swig_lib%\common.swg" > %2 TYPE "%swig_lib%\pike\pikerun.swg" >> %2 GOTO success :chicken ECHO #include "chicken.h" > %2 TYPE "%swig_lib%\common.swg" >> %2 TYPE "%swig_lib%\chicken\chickenrun.swg" >> %2 GOTO success :bad_lang ECHO Error: Unknown language "%1" GOTO failure :bad_swig_lib ECHO Error: Invalid location "%SWIG_LIB%" for swig library directory ECHO You can override this by setting the SWIG_LIB environment ECHO variable. GOTO failure :no_swig_lib ECHO Error: Unable to automatically detect swig library directory. ECHO You can work around this by setting the SWIG_LIB environment ECHO variable to directory where your swig library is installed ECHO (i.e. the directory that contains common.swg, swig.swg, and ECHO so on). GOTO failure :usage ECHO Usage: %0 language out.c GOTO failure :failure REM Exit batch file with status 1 EXIT /B 1 REM Above fails on win9x, so exit the whole gosh darn shell EXIT 1 :success