/[projet1]/public/pc/tools/osdk/main/Osdk/_final_/Bin/make.bat
Defence Force logotype

Contents of /public/pc/tools/osdk/main/Osdk/_final_/Bin/make.bat

Parent Directory Parent Directory | Revision Log Revision Log


Revision 70 - (show annotations)
Sun May 24 19:53:20 2009 UTC (10 years, 6 months ago) by dbug
File MIME type: text/plain
File size: 6452 byte(s)
Added the complete source code of the OSDK.
Projects files are available for Visual Studio 6 and .net, plus a Code::Blocks setup (everything works except PictConv that relies on FreeImage - which does not build correctly on mingw)
1 @ECHO OFF
2 ::@ECHO ON
3
4 ::
5 :: Initial checks to verify that everything is fine.
6 ::
7 IF "%OSDK%"=="" GOTO ErCfg
8 IF "%1"=="" GOTO ErNoFile
9
10 ::
11 :: Set the default name for the final executable
12 :: if no name has been specified
13 ::
14 IF NOT "%OSDKNAME%"=="" GOTO Name
15 SET OSDKNAME=OSDK
16 :Name
17
18
19
20 ::
21 :: Set the default assembly adress
22 :: if no adress has been specified
23 ::
24 IF NOT "%OSDKADDR%"=="" GOTO Adress
25 SET OSDKADDR=$600
26 :Adress
27
28 ::
29 :: Set the optimize level to 2
30 :: if no level has been specified
31 ::
32 IF NOT "%OSDKCOMP%"=="" GOTO Comp
33 SET OSDKCOMP=-O2
34 :Comp
35
36
37
38 SET OSDKB=%OSDK%\BIN
39 SET OSDKT=%OSDK%\TMP
40
41 SET TMP=%OSDKT%
42 SET TEMP=%OSDKT%
43 SET OCC=%OSDK%
44 SET LCC65=%OSDK%
45 SET LCC65DIR=%OSDK%
46
47
48 ::
49 :: Create a build directory if it does not exist
50 :: Mike: Seems to fail creating the folder under Wine, resulting in a failed build
51 :: Mike: What about testing for BUILD\. instead ?
52 ::
53 IF EXIST BUILD\NUL GOTO NoBuild
54 MD BUILD
55 :NoBuild
56
57 IF EXIST %OSDKT% GOTO NoTmp
58 MD %OSDKT%
59 :NoTmp
60
61 ::
62 :: Display a compilation message
63 :: Note: Should find a way to disable the adress display for BASIC programs... kind of lame
64 ::
65 ECHO Building the program %OSDKNAME% at adress %OSDKADDR%
66
67
68 ::
69 :: Delete old files.
70 :: This way we are sure nothing remains if the build fails
71 ::
72 IF NOT EXIST BUILD\symbols GOTO NoSymbol
73 DEL BUILD\symbols >NUL
74 :NoSymbol
75
76 IF NOT EXIST BUILD\final.out GOTO NoFinal
77 DEL BUILD\final.out >NUL
78 :NoFinal
79
80 IF NOT EXIST BUILD\xaerr.txt GOTO NoError
81 DEL BUILD\xaerr.txt >NUL
82 :NoError
83
84 IF NOT EXIST BUILD\%OSDKNAME%.tap GOTO NoTape
85 DEL BUILD\%OSDKNAME%.tap >NUL
86 :NoTape
87
88 :: Delete the eventual composite BASIC file
89 IF NOT EXIST %OSDKT%\%OSDKNAME%.bas GOTO NoBas
90 DEL %OSDKT%\%OSDKNAME%.bas >NUL
91 :NoBas
92
93
94 ::
95 :: Create a BATCH file that will be used
96 :: to later link all the part of the program
97 ::
98 ::ECHO *=%OSDKADDR% >%OSDKT%\adress.tmp
99 ::ECHO %OSDKB%\link65.exe %OSDKLINK% -d %OSDK%\lib/ -o %OSDKT%\linked.s -s %OSDKT%\ -f -q %1 %2 %3 %4 %5 %6 %7 %8 %9 >%OSDKT%\link.bat
100 ECHO %OSDKB%\link65.exe %OSDKLINK% -d %OSDK%\lib/ -o %OSDKT%\linked.ss -s %OSDKT%\ -f -q %OSDKFILE% >%OSDKT%\link.bat
101 ECHO %OSDKB%\link65.exe %OSDKLINK% -d %OSDK%\lib/ -o %OSDKT%\linked.s -s %OSDKT%\ -f -q %OSDKFILE% >%OSDKT%\link.bat
102
103
104
105 ::
106 :: Compile/Assemble files
107 :: depending of their type
108 ::
109 :FileLoop
110 IF "%1"=="" GOTO Finished
111
112 ::ECHO %1 >%OSDKT%\linktemp.txt
113 ::COPY /b %OSDKT%\link.bat+%OSDKT%\linktemp.txt %OSDKT%\link.bat
114 ::ECHO %1 >>%OSDKT%\link.bat
115
116 IF EXIST "%1.C" GOTO Compile
117 IF EXIST "%1.S" GOTO Assemble
118 IF EXIST "%1.ASM" GOTO Assemble
119 IF EXIST "%1.BAS" GOTO Basic
120
121 ::
122 :: Outputs a "file not found" error message
123 :: if the file is not a C or S file
124 ::
125 ECHO == ERROR --
126 ECHO The file "%1" is not a C, assembly code or BASIC file (.C/.S/.BAS suffix)
127 ECHO You should specify the name of the files without any extension. The files have
128 ECHO to be all in the same level directory and should not have the same names.
129 ECHO -- ERROR ==
130 IF "%OSDKBRIEF%"=="" PAUSE
131 GOTO End
132
133
134 :Compile
135 IF "%OSDKBRIEF%"=="" ECHO Compiling %1.C
136
137 IF "%OSDKBRIEF%"=="" ECHO - preprocess
138 :: the -DATMOS is for Contiki
139 %OSDKB%\cpp.exe -lang-c++ -I %OSDK%\include -D__16BIT__ -D__NOFLOAT__ -DATMOS -nostdinc %1.c %OSDKT%\%1.c
140
141 IF "%OSDKBRIEF%"=="" ECHO - compile
142 %OSDKB%\compiler.exe -N%1 %OSDKCOMP% %OSDKT%\%1.c >%OSDKT%\%1.c2
143 IF ERRORLEVEL 1 GOTO ErFailure
144
145 IF "%OSDKBRIEF%"=="" ECHO - convert C to assembly code
146 %OSDKB%\cpp.exe -lang-c++ -imacros %OSDK%\macro\macros.h -traditional -P %OSDKT%\%1.c2 %OSDKT%\%1.s
147
148 IF "%OSDKBRIEF%"=="" ECHO - cleanup output
149 ::%OSDKB%\tr < %OSDKT%\%1.s > %OSDKT%\%1
150 %OSDKB%\macrosplitter.exe %OSDKT%\%1.s %OSDKT%\%1
151
152 SHIFT
153 GOTO FileLoop
154
155
156 ::
157 :: This is the sequence of instructions necessary to build an assembly code file.
158 :: Assembler files are just copied over in the temp folder since there is no particular
159 :: modifications to do. Anyway we need to make sure that the directory structure is kept
160 :: at the correct place.
161 ::
162 :Assemble
163 IF "%OSDKBRIEF%"=="" ECHO Assembling %1.S
164
165 :: Create the directory structure
166 XCOPY /Y /T %1.S %OSDKT%
167
168 :: Copy the file
169 COPY %1.S %OSDKT%\%1 /Y >NUL
170 SHIFT
171 GOTO FileLoop
172
173 :Basic
174 IF "%OSDKBRIEF%"=="" ECHO Converting BASIC program %1.BAS
175
176 ECHO #file %1.BAS >> %OSDKT%\%OSDKNAME%.bas
177 TYPE %1.BAS >> %OSDKT%\%OSDKNAME%.bas
178
179 SHIFT
180 GOTO FileLoop
181
182
183
184 ::
185 :: Perform final linking and binary conversion
186 :: of compiled files
187 ::
188 :Finished
189
190 :: Do we have a BASIC program ?
191 IF NOT EXIST %OSDKT%\%OSDKNAME%.bas GOTO Link
192
193 ECHO Generating line numbers
194 %OSDKB%\Labels2Num %OSDKT%\%OSDKNAME%.bas %OSDKT%\%OSDKNAME%.bas2 1 1
195
196 ECHO Generating TAPE file
197 %OSDKB%\Bas2Tap -b2t1 -color1 %OSDKT%\%OSDKNAME%.bas2 build\%OSDKNAME%.tap
198 IF ERRORLEVEL 1 GOTO ErFailure
199 GOTO End
200
201 :Link
202 ECHO Linking
203 CALL %OSDKT%\link.bat
204 IF ERRORLEVEL 1 GOTO ErFailure
205 ::ECHO Optimising size
206 %OSDKB%\opt65.exe %OSDKT%\linked.s > %OSDKT%\linked_optimised.s
207
208
209 ::
210 :: Assemble the big file
211 ::
212 ::%OSDKB%\xa.exe %OSDKT%\linked.s -o final.out -e xaerr.txt -l xalbl.txt
213 ECHO Assembling
214 %OSDKB%\xa.exe %OSDKT%\linked.s -o build\final.out -e build\xaerr.txt -l build\symbols -bt %OSDKADDR%
215 IF NOT EXIST "build\final.out" GOTO ErFailure
216
217 ::
218 :: Append the tape header
219 ::
220 ECHO Creating final program %OSDKNAME%.TAP
221 %OSDKB%\header.exe %OSDKHEAD% build\final.out build\%OSDKNAME%.tap %OSDKADDR%
222 :BuildOk
223 ECHO Build of %OSDKNAME%.tap finished
224
225
226 ::
227 :: Generate the DSK file
228 ::
229 IF "%OSDKDISK%"=="" GOTO EndBuildDisk
230 %OSDK%\bin\tap2dsk.exe %OSDKDISK% build\%OSDKNAME%.tap build\%OSDKNAME%.dsk
231 %OSDK%\bin\old2mfm.exe build\%OSDKNAME%.DSK
232 :EndBuildDisk
233
234 ::
235 :: End of build
236 ::
237 GOTO End
238
239
240 ::
241 :: Outputs a "Unable to create program" error message
242 ::
243 :ErFailure
244 ECHO ERROR : Build failed.
245 IF "%OSDKBRIEF%"=="" PAUSE
246 GOTO End
247
248
249
250 ::
251 :: Outputs a "no files" error message
252 ::
253 :ErNoFile
254 ECHO == ERROR --
255 ECHO This batch file is supposed to compile files.
256 ECHO You should specify one or more files to compile.
257 ECHO -- ERROR ==
258 IF "%OSDKBRIEF%"=="" PAUSE
259 GOTO End
260
261
262 ::
263 :: Outputs a "configuration" error message
264 ::
265 :ErCfg
266 ECHO == ERROR --
267 ECHO The Oric SDK was not configured properly
268 ECHO You should have a OSDK environment variable setted to the location of the SDK
269 ECHO -- ERROR ==
270 IF "%OSDKBRIEF%"=="" PAUSE
271 GOTO End
272
273
274
275
276
277 :End

  ViewVC Help
Powered by ViewVC 1.1.26