@@ -37,6 +37,7 @@ set COMPILER=cl.exe
37
37
set O = obj
38
38
set ARCH = x64
39
39
set DEBUG = N
40
+ set DIRENT = Y
40
41
41
42
if exist maintMakefile (
42
43
set MAINT = Y
@@ -49,6 +50,7 @@ if "%1" == "--debug" goto SetDebug
49
50
if " %1 " == " --without-guile" goto NoGuile
50
51
if " %1 " == " --x86" goto Set32Bit
51
52
if " %1 " == " gcc" goto SetCC
53
+ if " %1 " == " tcc" goto SetTCC
52
54
if " %1 " == " " goto DoneSW
53
55
goto Usage
54
56
@@ -77,10 +79,18 @@ echo - Building with GCC
77
79
shift
78
80
goto ParseSW
79
81
82
+ :SetTCC
83
+ set COMPILER = tcc
84
+ set O = o
85
+ echo - Building with TinyC
86
+ shift
87
+ goto ParseSW
88
+
80
89
:DoneSW
81
90
if " %MAINT% " == " Y" echo - Enabling maintainer mode
82
91
83
92
if " %COMPILER% " == " gcc" goto FindGcc
93
+ if " %COMPILER% " == " tcc" goto FindTcc
84
94
85
95
:: Find a compiler. Visual Studio requires a lot of effort to locate :-/.
86
96
%COMPILER% > nul 2 >& 1
@@ -172,6 +182,7 @@ goto Build
172
182
set OUTDIR = .\GccRel
173
183
set LNKOUT = ./GccRel
174
184
set OPTS = -O2
185
+ set DIRENT = N
175
186
if " %DEBUG% " == " Y" set OPTS = -O0
176
187
if " %DEBUG% " == " Y" set OUTDIR = .\GccDebug
177
188
if " %DEBUG% " == " Y" set LNKOUT = ./GccDebug
@@ -183,6 +194,21 @@ if not ERRORLEVEL 1 goto Build
183
194
echo No %COMPILER% found.
184
195
exit 1
185
196
197
+ :FindTcc
198
+ set OUTDIR = .\TccRel
199
+ set LNKOUT = ./TccRel
200
+ set OPTS = -O2
201
+ if " %DEBUG% " == " Y" set OPTS = -O0
202
+ if " %DEBUG% " == " Y" set OUTDIR = .\TccDebug
203
+ if " %DEBUG% " == " Y" set LNKOUT = ./TccDebug
204
+ if " %MAINT% " == " Y" set " OPTS = %OPTS% -DMAKE_MAINTAINER_MODE"
205
+ :: Show the compiler version that we found
206
+ echo .
207
+ %COMPILER% -v
208
+ if not ERRORLEVEL 1 goto Build
209
+ echo No %COMPILER% found.
210
+ exit 1
211
+
186
212
:Build
187
213
:: Clean the directory if it exists
188
214
if exist %OUTDIR% \nul rmdir /S /Q %OUTDIR%
@@ -246,7 +272,8 @@ call :Compile lib/fnmatch
246
272
call :Compile lib/glob
247
273
call :Compile lib/getloadavg
248
274
249
- if not " %COMPILER% " == " gcc" call :Compile src\w32\compat\dirent
275
+ :: Compile dirent unless it is supported by compiler library (like with gcc).
276
+ if " %DIRENT% " == " Y" call :Compile src\w32\compat\dirent
250
277
251
278
call :Link
252
279
@@ -272,6 +299,7 @@ set EXTRAS=
272
299
if " %2 " == " GUILE" set " EXTRAS = %GUILECFLAGS% "
273
300
if exist " %OUTDIR% \%1 .%O% " del " %OUTDIR% \%1 .%O% "
274
301
if " %COMPILER% " == " gcc" goto GccCompile
302
+ if " %COMPILER% " == " tcc" goto TccCompile
275
303
276
304
:: MSVC Compile
277
305
echo on
@@ -284,6 +312,14 @@ goto CompileDone
284
312
echo on
285
313
%COMPILER% -mthreads -Wall -std=gnu99 -gdwarf-2 -g3 %OPTS% -I%OUTDIR% /src -I./src -I%OUTDIR% /lib -I./lib -I./src/w32/include -DWINDOWS32 -DHAVE_CONFIG_H %EXTRAS% -o %OUTDIR% /%1 .%O% -c %1 .c
286
314
@ echo off
315
+ goto CompileDone
316
+
317
+ :TccCompile
318
+ :: TCC Compile
319
+ echo on
320
+ %COMPILER% -mthreads -Wall -std=c11 %OPTS% -I%OUTDIR% /src -I./src -I%OUTDIR% /lib -I./lib -I./src/w32/include -D_cdecl= -D_MSC_VER -DWINDOWS32 -DHAVE_CONFIG_H %EXTRAS% -o %OUTDIR% /%1 .%O% -c %1 .c
321
+ @ echo off
322
+ goto CompileDone
287
323
288
324
:CompileDone
289
325
if not exist " %OUTDIR% \%1 .%O% " exit 1
@@ -293,6 +329,7 @@ goto :EOF
293
329
echo .
294
330
echo Linking %LNKOUT% /%MAKE% .exe
295
331
if " %COMPILER% " == " gcc" goto GccLink
332
+ if " %COMPILER% " == " tcc" goto TccLink
296
333
297
334
:: MSVC Link
298
335
echo %GUILELIBS% kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib >> %OUTDIR% \link.sc
@@ -309,6 +346,14 @@ echo %GUILELIBS% -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -l
309
346
@ echo off
310
347
goto :EOF
311
348
349
+ :TccLink
350
+ :: TCC Link
351
+ echo on
352
+ echo %GUILELIBS% -lkernel32 -luser32 -lgdi32 -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lodbc32 -lodbccp32 >> %OUTDIR% \link.sc
353
+ %COMPILER% -mthreads %OPTS% -o %LNKOUT% /%MAKE% .exe @ %LNKOUT% /link.sc
354
+ @ echo off
355
+ goto :EOF
356
+
312
357
:ConfigSCM
313
358
echo Generating config from SCM templates
314
359
sed -n " s/^AC_INIT(\[GNU make\],\[\([^]]\+\)\].*/s,%% VERSION%% ,\1,g/p" configure.ac > %OUTDIR% \src\config.h.W32.sed
@@ -375,12 +420,14 @@ if ERRORLEVEL 1 exit /b 1
375
420
goto :EOF
376
421
377
422
:Usage
378
- echo Usage: %0 [options] [gcc]
423
+ echo Usage: %0 [options] [gcc] OR [tcc]
379
424
echo Options:
380
425
echo . --without-guile Do not compile Guile support even if found
381
426
echo . --debug Make a Debug build--default is Release
382
427
echo . --x86 Make a 32bit binary--default is 64bit
383
428
echo . --help Display these instructions and exit
429
+ echo .
430
+ echo . " gcc" means compile with GCC, " tcc" means compile with Tiny C's TCC
384
431
goto :EOF
385
432
386
433
:Reset
0 commit comments