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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1356 - (hide annotations)
Sun Jan 17 20:36:06 2016 UTC (3 years, 10 months ago) by dbug
File MIME type: text/plain
File size: 8787 byte(s)
OSDK 1.8
1 dbug 70 @ECHO OFF
2 dbug 1243 ::ECHO ON
3 dbug 70
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 dbug 1002 ::
19     :: Set the default tape name for the final executable
20     :: if no name has been specified
21     ::
22     IF NOT "%OSDKTAPNAME%"=="" GOTO TapName
23     SET OSDKTAPNAME=OSDK
24     :TapName
25 dbug 70
26     ::
27     :: Set the default assembly adress
28     :: if no adress has been specified
29     ::
30     IF NOT "%OSDKADDR%"=="" GOTO Adress
31     SET OSDKADDR=$600
32     :Adress
33    
34     ::
35     :: Set the optimize level to 2
36     :: if no level has been specified
37     ::
38     IF NOT "%OSDKCOMP%"=="" GOTO Comp
39     SET OSDKCOMP=-O2
40     :Comp
41    
42    
43    
44     SET OSDKB=%OSDK%\BIN
45     SET OSDKT=%OSDK%\TMP
46 dbug 1356 SET OSDKLINKLIST=
47 dbug 70 SET TMP=%OSDKT%
48     SET TEMP=%OSDKT%
49     SET OCC=%OSDK%
50     SET LCC65=%OSDK%
51     SET LCC65DIR=%OSDK%
52    
53     ::
54     :: Create a build directory if it does not exist
55     :: Mike: Seems to fail creating the folder under Wine, resulting in a failed build
56     :: Mike: What about testing for BUILD\. instead ?
57     ::
58     IF EXIST BUILD\NUL GOTO NoBuild
59     MD BUILD
60     :NoBuild
61    
62 dbug 1002
63     ::
64     :: Make sure that temp folder is entirelly empty before attempting a new build
65     :: Will guarantee we do not have side effects between builds
66     ::
67     ::ECHO ON
68     RMDIR /s /q %OSDKT%\ >NUL
69     MD %OSDKT% >NUL
70     ::IF EXIST %OSDKT%\NUL GOTO NoTmp
71     ::MD %OSDKT%
72 dbug 70 :NoTmp
73 dbug 1002 ::ECHO OFF
74 dbug 70
75 dbug 1002
76 dbug 70 ::
77     :: Display a compilation message
78     :: Note: Should find a way to disable the adress display for BASIC programs... kind of lame
79     ::
80     ECHO Building the program %OSDKNAME% at adress %OSDKADDR%
81    
82    
83     ::
84     :: Delete old files.
85     :: This way we are sure nothing remains if the build fails
86     ::
87     IF NOT EXIST BUILD\symbols GOTO NoSymbol
88     DEL BUILD\symbols >NUL
89     :NoSymbol
90    
91     IF NOT EXIST BUILD\final.out GOTO NoFinal
92     DEL BUILD\final.out >NUL
93     :NoFinal
94    
95     IF NOT EXIST BUILD\xaerr.txt GOTO NoError
96     DEL BUILD\xaerr.txt >NUL
97     :NoError
98    
99     IF NOT EXIST BUILD\%OSDKNAME%.tap GOTO NoTape
100     DEL BUILD\%OSDKNAME%.tap >NUL
101     :NoTape
102    
103     :: Delete the eventual composite BASIC file
104     IF NOT EXIST %OSDKT%\%OSDKNAME%.bas GOTO NoBas
105     DEL %OSDKT%\%OSDKNAME%.bas >NUL
106     :NoBas
107    
108 dbug 1002 :: Delete eventual compressed files
109     IF NOT EXIST BUILD\*.pak GOTO NoPak
110     DEL BUILD\*.pak >NUL
111     :NoPak
112 dbug 70
113 dbug 1002 IF NOT EXIST BUILD\%OSDKPACK%.* GOTO NoPakFiles
114     DEL BUILD\%OSDKPACK%.* >NUL
115     :NoPakFiles
116    
117    
118 dbug 70 ::
119     :: Create a BATCH file that will be used
120     :: to later link all the part of the program
121     ::
122     ::ECHO *=%OSDKADDR% >%OSDKT%\adress.tmp
123     ::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
124 dbug 1002 ::ECHO %OSDKB%\link65.exe %OSDKLINK% -d %OSDK%\lib/ -o %OSDKT%\linked.ss -s %OSDKT%\ -f -q %OSDKFILE% >%OSDKT%\link.bat
125 dbug 1356 ::ECHO %OSDKB%\link65.exe %OSDKLINK% -d %OSDK%\lib/ -o %OSDKT%\linked.s -s %OSDKT%\ -f -q %OSDKFILE% >%OSDKT%\link.bat
126 dbug 70
127    
128     ::
129     :: Compile/Assemble files
130     :: depending of their type
131     ::
132     :FileLoop
133     IF "%1"=="" GOTO Finished
134    
135     ::ECHO %1 >%OSDKT%\linktemp.txt
136     ::COPY /b %OSDKT%\link.bat+%OSDKT%\linktemp.txt %OSDKT%\link.bat
137     ::ECHO %1 >>%OSDKT%\link.bat
138    
139     IF EXIST "%1.C" GOTO Compile
140     IF EXIST "%1.S" GOTO Assemble
141     IF EXIST "%1.ASM" GOTO Assemble
142     IF EXIST "%1.BAS" GOTO Basic
143    
144     ::
145     :: Outputs a "file not found" error message
146     :: if the file is not a C or S file
147     ::
148     ECHO == ERROR --
149     ECHO The file "%1" is not a C, assembly code or BASIC file (.C/.S/.BAS suffix)
150     ECHO You should specify the name of the files without any extension. The files have
151     ECHO to be all in the same level directory and should not have the same names.
152     ECHO -- ERROR ==
153     IF "%OSDKBRIEF%"=="" PAUSE
154     GOTO End
155    
156    
157     :Compile
158     IF "%OSDKBRIEF%"=="" ECHO Compiling %1.C
159    
160     IF "%OSDKBRIEF%"=="" ECHO - preprocess
161     :: the -DATMOS is for Contiki
162 dbug 1288 %OSDKB%\cpp.exe -lang-c++ -I %OSDK%\include -D__16BIT__ -D__NOFLOAT__ -DATMOS -DOSDKNAME_%OSDKNAME% -nostdinc %1.c %OSDKT%\%1.c
163 dbug 70
164     IF "%OSDKBRIEF%"=="" ECHO - compile
165     %OSDKB%\compiler.exe -N%1 %OSDKCOMP% %OSDKT%\%1.c >%OSDKT%\%1.c2
166     IF ERRORLEVEL 1 GOTO ErFailure
167    
168     IF "%OSDKBRIEF%"=="" ECHO - convert C to assembly code
169     %OSDKB%\cpp.exe -lang-c++ -imacros %OSDK%\macro\macros.h -traditional -P %OSDKT%\%1.c2 %OSDKT%\%1.s
170    
171     IF "%OSDKBRIEF%"=="" ECHO - cleanup output
172     ::%OSDKB%\tr < %OSDKT%\%1.s > %OSDKT%\%1
173     %OSDKB%\macrosplitter.exe %OSDKT%\%1.s %OSDKT%\%1
174 dbug 1356 SET OSDKLINKLIST=%OSDKLINKLIST% %OSDKT%\%1
175 dbug 70 SHIFT
176     GOTO FileLoop
177    
178    
179     ::
180     :: This is the sequence of instructions necessary to build an assembly code file.
181     :: Assembler files are just copied over in the temp folder since there is no particular
182     :: modifications to do. Anyway we need to make sure that the directory structure is kept
183     :: at the correct place.
184     ::
185     :Assemble
186     IF "%OSDKBRIEF%"=="" ECHO Assembling %1.S
187    
188     :: Create the directory structure
189 dbug 1002 XCOPY /Y /T %1.S %OSDKT%\
190 dbug 70
191     :: Copy the file
192 dbug 1356 COPY %1.S %OSDKT%\%1.s /Y >NUL
193     SET OSDKLINKLIST=%OSDKLINKLIST% %1.s
194 dbug 70 SHIFT
195     GOTO FileLoop
196    
197     :Basic
198     IF "%OSDKBRIEF%"=="" ECHO Converting BASIC program %1.BAS
199    
200     ECHO #file %1.BAS >> %OSDKT%\%OSDKNAME%.bas
201     TYPE %1.BAS >> %OSDKT%\%OSDKNAME%.bas
202    
203     SHIFT
204     GOTO FileLoop
205    
206    
207    
208     ::
209     :: Perform final linking and binary conversion
210     :: of compiled files
211     ::
212     :Finished
213    
214     :: Do we have a BASIC program ?
215     IF NOT EXIST %OSDKT%\%OSDKNAME%.bas GOTO Link
216    
217 dbug 1002 ::ECHO Generating line numbers
218     ::%OSDKB%\Labels2Num %OSDKT%\%OSDKNAME%.bas %OSDKT%\%OSDKNAME%.bas2 1 1
219 dbug 70
220     ECHO Generating TAPE file
221 dbug 1002 %OSDKB%\Bas2Tap -b2t1 -color1 %OSDKT%\%OSDKNAME%.bas build\%OSDKNAME%.tap
222    
223 dbug 70 IF ERRORLEVEL 1 GOTO ErFailure
224     GOTO End
225    
226     :Link
227 dbug 1356 ::
228     :: Create a BATCH file that will be used
229     :: to later link all the part of the program
230     ::
231 dbug 70 ECHO Linking
232 dbug 1356 ::ECHO %OSDKLINKLIST%
233     cd
234     ECHO %OSDKB%\link65.exe %OSDKLINK% -d %OSDK%\lib/ -o %OSDKT%\linked.s -f -q %OSDKLINKLIST% >%OSDKT%\link.bat
235     ::ECHO %OSDKB%\link65.exe %OSDKLINK% -d %OSDK%\lib/ -o %OSDKT%\linked.s -s %OSDKT%\ -f -q %OSDKFILE% >%OSDKT%\link.bat
236     ::pause
237 dbug 70 CALL %OSDKT%\link.bat
238     IF ERRORLEVEL 1 GOTO ErFailure
239     ::ECHO Optimising size
240 dbug 1002 ::%OSDKB%\opt65.exe %OSDKT%\linked.s > %OSDKT%\linked_optimised.s
241 dbug 70
242    
243     ::
244     :: Assemble the big file
245 dbug 1356 :: (-W -C are meant to disallow the 65816 and 65c02 instructions)
246 dbug 70 ::%OSDKB%\xa.exe %OSDKT%\linked.s -o final.out -e xaerr.txt -l xalbl.txt
247     ECHO Assembling
248 dbug 1356 %OSDKB%\xa.exe -W -C %OSDKT%\linked.s -o build\final.out -e build\xaerr.txt -l build\symbols -bt %OSDKADDR% -DASSEMBLER=XA -DOSDKNAME_%OSDKNAME%
249 dbug 70 IF NOT EXIST "build\final.out" GOTO ErFailure
250    
251 dbug 1002
252 dbug 70 ::
253 dbug 1002 :: Executable compression test
254     ::
255     IF "%OSDKPACKADDR%"=="" GOTO EndPack
256    
257     IF "%OSDKBRIEF%"=="" ECHO Compressing
258     %OSDK%\bin\FilePack -p0 build\final.out %OSDKT%\final.pak
259    
260     IF "%OSDKBRIEF%"=="" ECHO - Converting binary to text format
261     %OSDK%\bin\bin2txt -s1 -f2 %OSDKT%\final.pak %OSDKT%\final_pak.s _PackedStart >NUL
262    
263     IF "%OSDKBRIEF%"=="" ECHO - Appending depacking code
264     COPY %OSDKT%\final_fp.s+%OSDKB%\unpack.s+%OSDKT%\final_pak.s %OSDKT%\pak_linked.s >NUL
265    
266     IF "%OSDKBRIEF%"=="" ECHO - Assembling
267     %OSDKB%\xa.exe %OSDKT%\pak_linked.s -o build\final.out -e %OSDKT%\xaerr.txt -l %OSDKT%\symbols -bt %OSDKPACKADDR%
268     IF NOT EXIST "build\final.out" GOTO ErFailure
269    
270     :: The new start address is the packed executable load address
271     set OSDKADDR=%OSDKPACKADDR%
272    
273     :EndPack
274    
275    
276     ::
277 dbug 70 :: Append the tape header
278     ::
279     ECHO Creating final program %OSDKNAME%.TAP
280     %OSDKB%\header.exe %OSDKHEAD% build\final.out build\%OSDKNAME%.tap %OSDKADDR%
281 dbug 1002 %OSDKB%\taptap.exe ren build\%OSDKNAME%.tap %OSDKTAPNAME% 0
282    
283 dbug 70 :BuildOk
284     ECHO Build of %OSDKNAME%.tap finished
285    
286    
287     ::
288 dbug 1002 :: Generate the DSK file. If OSDKFILE is empty we assume (hm hmmm) that the caller is packaging itself with floppybuilder. (WIP)
289 dbug 70 ::
290     IF "%OSDKDISK%"=="" GOTO EndBuildDisk
291 dbug 1002 IF "%OSDKFILE%"=="" GOTO EndBuildDisk
292    
293 dbug 1156 ::%OSDK%\bin\DskTool.exe -n%OSDKDNAME% -i%OSDKINIST% %OSDKDISK% build\%OSDKNAME%.tap build\%OSDKNAME%.dsk
294 dbug 1341 %OSDK%\bin\tap2dsk.exe -n%OSDKDNAME% -i%OSDKINIST% %OSDKDISK% build\%OSDKNAME%.tap build\%OSDKNAME%.dsk
295 dbug 70 %OSDK%\bin\old2mfm.exe build\%OSDKNAME%.DSK
296 dbug 1002
297 dbug 70 :EndBuildDisk
298    
299     ::
300     :: End of build
301     ::
302     GOTO End
303    
304    
305     ::
306     :: Outputs a "Unable to create program" error message
307     ::
308     :ErFailure
309     ECHO ERROR : Build failed.
310     IF "%OSDKBRIEF%"=="" PAUSE
311     GOTO End
312    
313    
314    
315     ::
316     :: Outputs a "no files" error message
317     ::
318     :ErNoFile
319     ECHO == ERROR --
320     ECHO This batch file is supposed to compile files.
321     ECHO You should specify one or more files to compile.
322     ECHO -- ERROR ==
323     IF "%OSDKBRIEF%"=="" PAUSE
324     GOTO End
325    
326    
327     ::
328     :: Outputs a "configuration" error message
329     ::
330     :ErCfg
331     ECHO == ERROR --
332     ECHO The Oric SDK was not configured properly
333     ECHO You should have a OSDK environment variable setted to the location of the SDK
334     ECHO -- ERROR ==
335     IF "%OSDKBRIEF%"=="" PAUSE
336     GOTO End
337    
338    
339    
340    
341    
342     :End

  ViewVC Help
Powered by ViewVC 1.1.26