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

  ViewVC Help
Powered by ViewVC 1.1.26