Fix (hopefully) some oversights in recent Bison cleanup patch.
[PostgreSQL.git] / src / tools / msvc / pgbison.bat
blob22502658234357de4cafd2be450c5a8a27c69129
1 @echo off
2 REM $PostgreSQL$
4 IF NOT EXIST src\tools\msvc\buildenv.pl goto nobuildenv
5 perl -e "require 'src/tools/msvc/buildenv.pl'; while(($k,$v) = each %ENV) { print qq[\@SET $k=$v\n]; }" > bldenv.bat
6 CALL bldenv.bat
7 del bldenv.bat
8 :nobuildenv 
10 SET BV=
11 for /F "tokens=4 usebackq" %%f in (`bison -V`) do if "!BV!"=="" SET BV=%%f
12 if "%BV%"=="" goto novarexp
13 if %BV% EQU 1.875 goto bisonok
14 if %BV% GEQ 2.2 goto bisonok
15 goto nobison
16 :bisonok
18 if "%1" == "src\backend\parser\gram.y" call :generate %1 src\backend\parser\gram.c src\backend\parser\gram.h
19 if "%1" == "src\backend\bootstrap\bootparse.y" call :generate %1 src\backend\bootstrap\bootparse.c
20 if "%1" == "src\pl\plpgsql\src\gram.y" call :generate %1 src\pl\plpgsql\src\pl_gram.c src\pl\plpgsql\src\pl_gram.h
21 if "%1" == "src\interfaces\ecpg\preproc\preproc.y" call :generate %1 src\interfaces\ecpg\preproc\preproc.c src\interfaces\ecpg\preproc\preproc.h
22 if "%1" == "contrib\cube\cubeparse.y" call :generate %1 contrib\cube\cubeparse.c
23 if "%1" == "contrib\seg\segparse.y" call :generate %1 contrib\seg\segparse.c
25 echo Unknown bison input: %1
26 exit 1
28 :generate
29 SET fn=%1
30 SET cf=%2
31 bison.exe -d %fn% -o %cf%
32 if errorlevel 1 exit 1
33 SET hf=%cf:~0,-2%.h
34 if not "%hf%"=="%3" (
35         copy /y %hf% %3
36         if errorlevel 1 exit 1
37         del %hf%
39 exit 0
42 :novarexp
43 echo pgbison must be called with cmd /V:ON /C pgbison to work!
44 exit 1
46 :nobison
47 echo WARNING! Bison install not found, or unsupported Bison version.
48 echo Attempting to build without.
49 exit 0