-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Make.bat
65 lines (54 loc) · 1.52 KB
/
Make.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
echo off
set PROG=tictactoe
set GBDK_N=..\gbdk-n
set CC=%GBDK_N%\bin\gbdk-n-compile.bat
set LD=%GBDK_N%\bin\gbdk-n-link.bat
set MR=%GBDK_N%\bin\gbdk-n-make-rom.bat
:: Clean
if "%1" == "clean" (
del src\*.rel
del src\*.lst
del src\*.sym
del src\*.asm
del %PROG%.gb
del %PROG%.ihx
del %PROG%.map
del %PROG%.sym
del %PROG%.noi
del %PROG%.lk
goto end
)
:: Check that gbdk-n is available
if not exist %GBDK_N% (
echo "gbdk-n folder not found at '%GBDK_N%'."
pause
goto end
)
:: Check that gbdk-n is compiled
if not exist %GBDK_N%\lib\gb.lib (
echo "gbdk-n library is not yet compiled. Please go to the '%GBDK_N%' directory and run 'Make.bat' to build it."
pause
goto end
)
:: Compile (*.c -> *.res)
for %%A in (src\*.c) do (
if exist %%~nA.rel del %%~nA.rel
echo Compiling: %%~nxA
call %CC% -c src\%%~nA.c -o src\%%~nA.rel
if not exist src\%%~nA.rel echo. && echo "Build failed!" && echo. && pause && goto end
)
:: Link (*.rel -> prog.ihx)
setlocal enabledelayedexpansion
set REL_LIST=
for %%A in (src\*.rel) do set REL_LIST=!REL_LiST! %%A
if exist %PROG%.ihx del %PROG%.ihx
echo Linking: %PROG%.ihx
call %LD% -o %PROG%.ihx %REL_LIST%
if not exist %PROG%.ihx echo. && echo "Build failed!" && echo. && pause && goto end
:: Build the ROM (prog.ihx -> prog.gb)
if exist %PROG%.gb del %PROG%.gb
echo Building ROM: %PROG%.gb
call %MR% %PROG%.ihx %PROG%.gb
if not exist %PROG%.gb echo. && echo "Build failed!" && echo. && pause && goto end
echo "Build succeded!"
:end