| 1 |
rem @echo off |
| 2 |
|
| 3 |
set PCCDIR= |
| 4 |
set PREFIX= |
| 5 |
set usecl= |
| 6 |
set doinstall=false |
| 7 |
|
| 8 |
:parsecommandline |
| 9 |
if '%1' == '/h' goto dispinfo |
| 10 |
if '%1' == '/pcc' goto usepcc |
| 11 |
if '%1' == '/cl' goto usecl |
| 12 |
if '%1' == '/prefix' goto prefix |
| 13 |
if '%1' == '/pccdir' goto pccdir |
| 14 |
if '%1' == '/pccsrcdir' goto pccsrcdir |
| 15 |
if '%1' == '/pcclibssrcdir' goto pcclibssrcdir |
| 16 |
if '%1' == '/install' set doinstall=true |
| 17 |
goto build |
| 18 |
|
| 19 |
:dispinfo |
| 20 |
echo build.bat [/h] { /pcc or /cl } [/prefix -dir-] [/pccdir -dir-] [/pccsrcdir -dir-] [/pcclibssrcdir -dir-] [/install] |
| 21 |
goto end |
| 22 |
|
| 23 |
:prefix |
| 24 |
shift |
| 25 |
set PREFIX=%1 |
| 26 |
shift |
| 27 |
goto parsecommandline |
| 28 |
|
| 29 |
:pccdir |
| 30 |
shift |
| 31 |
set PCCDIR=%1 |
| 32 |
shift |
| 33 |
goto parsecommandline |
| 34 |
|
| 35 |
:pccsrcdir |
| 36 |
shift |
| 37 |
set PCCSRCDIR=%1 |
| 38 |
shift |
| 39 |
goto parsecommandline |
| 40 |
|
| 41 |
:pcclibssrcdir |
| 42 |
shift |
| 43 |
set PCCLIBSSRCDIR=%1 |
| 44 |
shift |
| 45 |
goto parsecommandline |
| 46 |
|
| 47 |
:usecl |
| 48 |
set CC=cl.exe -D__MSC__ |
| 49 |
set CFLAGS=/nologo /Zi /MT /W2 |
| 50 |
set CFLAGS2=/nologo /Zi /MD /Za /Wall /GS- |
| 51 |
set OBJ=obj |
| 52 |
set AR=lib.exe /nologo |
| 53 |
set AR_OUT=/OUT:libpcc.a |
| 54 |
set usecl=true |
| 55 |
shift |
| 56 |
goto parsecommandline |
| 57 |
|
| 58 |
:usepcc |
| 59 |
set CC=pcc.exe |
| 60 |
set CFLAGS=-g |
| 61 |
set CFLAGS2=-fno-stack-protector-all |
| 62 |
set OBJ=o |
| 63 |
set AR=ar.exe |
| 64 |
set AR_OUT=r libpcc.a |
| 65 |
set usecl=false |
| 66 |
shift |
| 67 |
goto parsecommandline |
| 68 |
|
| 69 |
:build |
| 70 |
|
| 71 |
if '%usecl%' == '' goto dispinfo |
| 72 |
|
| 73 |
set PREFIX=###%PREFIX%### |
| 74 |
set PREFIX=%PREFIX:"###=% |
| 75 |
set PREFIX=%PREFIX:###"=% |
| 76 |
set PREFIX=%PREFIX:###=% |
| 77 |
|
| 78 |
set PCCDIR=###%PCCDIR%### |
| 79 |
set PCCDIR=%PCCDIR:"###=% |
| 80 |
set PCCDIR=%PCCDIR:###"=% |
| 81 |
set PCCDIR=%PCCDIR:###=% |
| 82 |
|
| 83 |
set PCCSRCDIR=###%PCCSRCDIR%### |
| 84 |
set PCCSRCDIR=%PCCSRCDIR:"###=% |
| 85 |
set PCCSRCDIR=%PCCSRCDIR:###"=% |
| 86 |
set PCCSRCDIR=%PCCSRCDIR:###=% |
| 87 |
|
| 88 |
set PCCLIBSSRCDIR=###%PCCLIBSSRCDIR%### |
| 89 |
set PCCLIBSSRCDIR=%PCCLIBSSRCDIR:"###=% |
| 90 |
set PCCLIBSSRCDIR=%PCCLIBSSRCDIR:###"=% |
| 91 |
set PCCLIBSSRCDIR=%PCCLIBSSRCDIR:###=% |
| 92 |
|
| 93 |
if not '%PCCDIR%' == '' goto pccdirset |
| 94 |
set PCCDIR=C:\Program Files\pcc |
| 95 |
:pccdirset |
| 96 |
|
| 97 |
if not '%PCCSRCDIR%' == '' goto pccsrcdirset |
| 98 |
set PCCSRCDIR=..\.. |
| 99 |
:pccsrcdirset |
| 100 |
|
| 101 |
if not '%PCCLIBSSRCDIR%' == '' goto pcclibssrcdirset |
| 102 |
set PCCLIBSSRCDIR=..\..\..\pcc-libs |
| 103 |
:pcclibssrcdirset |
| 104 |
|
| 105 |
if '%usecl%' == 'true' goto ccprefixed |
| 106 |
set CC="%PCCDIR%\bin\%CC%" |
| 107 |
set AR="%PCCDIR%\bin\%AR%" |
| 108 |
:ccprefixed |
| 109 |
|
| 110 |
set TARGOS=win32 |
| 111 |
set MACH=i386 |
| 112 |
set LIBEXECDIR="" |
| 113 |
|
| 114 |
set MIPDIR=%PCCSRCDIR%\mip |
| 115 |
set CPPDIR=%PCCSRCDIR%\cc\cpp |
| 116 |
set CCOMDIR=%PCCSRCDIR%\cc\ccom |
| 117 |
set CCDIR=%PCCSRCDIR%\cc\cc |
| 118 |
set OSDIR=%PCCSRCDIR%\os\%TARGOS% |
| 119 |
set MACHDIR=%PCCSRCDIR%\arch\%MACH% |
| 120 |
set BISON_SIMPLE=%OSDIR%\bison.simple |
| 121 |
set CPPFLAGS=-DWIN32 -DGCC_COMPAT -DPCC_DEBUG -DTARGOS="%TARGOS%" -Dos_%TARGOS% -DTARGMACH="%MACH%" -Dmach_%MACH% -DLIBEXECDIR=%LIBEXECDIR% -D_CRT_SECURE_NO_WARNINGS |
| 122 |
|
| 123 |
del *.obj *.o *.exe |
| 124 |
|
| 125 |
%CC% -o pcc.exe %CPPFLAGS% %CFLAGS% -I%CCDIR% -I%OSDIR% -I%MACHDIR% -I%MIPDIR% %CCDIR%\cc.c %MIPDIR%\compat.c |
| 126 |
|
| 127 |
bison -y -t -d --no-lines %CPPDIR%\cpy.y |
| 128 |
rem flex %CPPDIR%\scanner.l |
| 129 |
rem %CC% -o cpp.exe %CPPFLAGS% %CFLAGS% -I%CPPDIR% -I%OSDIR% -I%MACHDIR% -I%MIPDIR% -I. %CPPDIR%\cpp.c %MIPDIR%\compat.c y.tab.c lex.yy.c "C:\Program Files\UnxUtils\usr\local\lib\libfl.lib" |
| 130 |
%CC% -o cpp.exe %CPPFLAGS% %CFLAGS% -I%CPPDIR% -I%OSDIR% -I%MACHDIR% -I%MIPDIR% -I. %CPPDIR%\cpp.c %CPPDIR%\token.c %MIPDIR%\compat.c y.tab.c "C:\Program Files\UnxUtils\usr\local\lib\libfl.lib" |
| 131 |
|
| 132 |
%CC% -o mkext.exe -DMKEXT %CPPFLAGS% %CFLAGS% -I%CCOMDIR% -I%OSDIR% -I%MACHDIR% -I%MIPDIR% %MIPDIR%\mkext.c %MACHDIR%\table.c %MIPDIR%\common.c |
| 133 |
mkext |
| 134 |
bison -y -t -d --no-lines %CCOMDIR%\cgram.y |
| 135 |
move y.tab.c cgram.c |
| 136 |
move y.tab.h cgram.h |
| 137 |
flex %CCOMDIR%\scan.l |
| 138 |
move lex.yy.c scan.c |
| 139 |
|
| 140 |
%CC% -o ccom.exe %CPPFLAGS% %CFLAGS% -I%CCOMDIR% -I%OSDIR% -I%MACHDIR% -I%MIPDIR% -I. %CCOMDIR%\main.c %MIPDIR%\compat.c scan.c cgram.c external.c %CCOMDIR%\optim.c %CCOMDIR%\builtins.c %CCOMDIR%\pftn.c %CCOMDIR%\trees.c %CCOMDIR%\inline.c %CCOMDIR%\symtabs.c %CCOMDIR%\init.c %MACHDIR%\local.c %MACHDIR%\code.c %CCOMDIR%\stabs.c %CCOMDIR%\gcc_compat.c %MIPDIR%\match.c %MIPDIR%\reader.c %MIPDIR%\optim2.c %MIPDIR%\regs.c %MACHDIR%\local2.c %MACHDIR%\order.c %MACHDIR%\table.c %MIPDIR%\common.c "C:\Program Files\UnxUtils\usr\local\lib\libfl.lib" |
| 141 |
|
| 142 |
if not '%PREFIX%' == '' goto prefixset |
| 143 |
set PREFIX=C:\Program Files\pcc |
| 144 |
:prefixset |
| 145 |
|
| 146 |
set PCCDESTDIR=%PREFIX% |
| 147 |
set LIBPCCDESTDIR=%PREFIX%\lib\i386-win32\1.1.0 |
| 148 |
|
| 149 |
set LIBPCCDIR=%PCCLIBSSRCDIR%\libpcc |
| 150 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\_alloca.c |
| 151 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\adddi3.c |
| 152 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\anddi3.c |
| 153 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\ashldi3.c |
| 154 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\ashrdi3.c |
| 155 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\cmpdi2.c |
| 156 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\divdi3.c |
| 157 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\fixdfdi.c |
| 158 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\fixsfdi.c |
| 159 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\fixunsdfdi.c |
| 160 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\fixunssfdi.c |
| 161 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\floatdidf.c |
| 162 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\floatdisf.c |
| 163 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\floatunsdidf.c |
| 164 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\iordi3.c |
| 165 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\lshldi3.c |
| 166 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\lshrdi3.c |
| 167 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\moddi3.c |
| 168 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\muldi3.c |
| 169 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\negdi2.c |
| 170 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\notdi2.c |
| 171 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\qdivrem.c |
| 172 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\ssp.c |
| 173 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\subdi3.c |
| 174 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\ucmpdi2.c |
| 175 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\udivdi3.c |
| 176 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\umoddi3.c |
| 177 |
%CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\xordi3.c |
| 178 |
|
| 179 |
if '%usecl%' == 'false' %CC% -c %CPPFLAGS% %CFLAGS2% -I%LIBPCCDIR% %LIBPCCDIR%\_ftol.c |
| 180 |
if '%usecl%' == 'true' ml /nologo -c %LIBPCCDIR%\_ftol.asm |
| 181 |
|
| 182 |
%AR% %AR_OUT% _ftol.%OBJ% adddi3.%OBJ% anddi3.%OBJ% ashldi3.%OBJ% ashrdi3.%OBJ% cmpdi2.%OBJ% divdi3.%OBJ% fixdfdi.%OBJ% fixsfdi.%OBJ% fixunsdfdi.%OBJ% fixunssfdi.%OBJ% floatdidf.%OBJ% floatdisf.%OBJ% floatunsdidf.%OBJ% iordi3.%OBJ% lshldi3.%OBJ% lshrdi3.%OBJ% moddi3.%OBJ% muldi3.%OBJ% negdi2.%OBJ% notdi2.%OBJ% qdivrem.%OBJ% ssp.%OBJ% subdi3.%OBJ% ucmpdi2.%OBJ% udivdi3.%OBJ% umoddi3.%OBJ% xordi3.%OBJ% |
| 183 |
|
| 184 |
if not '%doinstall%' == 'true' goto end |
| 185 |
|
| 186 |
md "%PCCDESTDIR%" |
| 187 |
md "%PCCDESTDIR%\bin" |
| 188 |
md "%PCCDESTDIR%\libexec" |
| 189 |
md "%PCCDESTDIR%\man" |
| 190 |
md "%PCCDESTDIR%\man\man1" |
| 191 |
md "%LIBPCCDESTDIR%\lib" |
| 192 |
md "%LIBPCCDESTDIR%\include" |
| 193 |
|
| 194 |
copy pcc.exe "%PCCDESTDIR%\bin" |
| 195 |
copy cpp.exe "%PCCDESTDIR%\libexec" |
| 196 |
copy ccom.exe "%PCCDESTDIR%\libexec" |
| 197 |
|
| 198 |
copy libpcc.a "%LIBPCCDESTDIR%\lib" |
| 199 |
copy "%LIBPCCDIR%\include\*.h" "%LIBPCCDESTDIR%\include" |
| 200 |
|
| 201 |
copy "%CCDIR%\cc.1" "%PCCDESTDIR%\man\man1" |
| 202 |
copy "%CPPDIR%\cpp.1" "%PCCDESTDIR%\man\man1" |
| 203 |
copy "%CCOMDIR%\ccom.1" "%PCCDESTDIR%\man\man1" |
| 204 |
|
| 205 |
:end |