handle USER_INCLUDES via the CPPFLAGS
[AROS.git] / tools / fd2pragma / fd2pragma.guide
blob4fa8dc39f144aed7a2adf922903692d36a145636
1 @database fd2pragma.guide
2 @$VER: fd2pragma.guide 1.64 (21.01.2004)
3 @index Index
4 @node Main "fd2pragma - the programmers file generator"
5 fd2pragma - the programmers file generator
7     @{"About the program" LINK About}           What this program is able to do
8     @{"About this documentation" LINK Docs}    Read this!
10     @{"Beginner" LINK Beginner}                    Easy start for beginners
11     @{"Options" LINK Options}                     What options may be used to control it
12     @{"Useful example calls" LINK Examples}        Most useful calls
13      @{"The important options" LINK OptionAll}      Main options for everyone
14      @{"The advanced options" LINK OptionAdvanced}       Options for more detailed control
15     @{"About includes" LINK Includes}              What C includes are useful and required
17     Some words about
18      @{"Default names" LINK Names}              The default output file names
19      @{"Link libraries" LINK LinkLib}             Generated link library files
20      @{"Proto files" LINK Proto}                Generated proto files
21      @{"Include definitions" LINK IncludeDefs}        Overview of supported definitions
22      @{"Local library base files" LINK Local}   C includes for local library base support
24      @{"Header scan" LINK HeaderScan}                The way the HEADER option works
25      @{"Tag-functions" LINK TagFuncs}              The way tag-functions are found
26      @{"fd2pragma.types" LINK TypesFile}            The fd2pragma.types definition file
27      @{"FPU usage" LINK  FPUusage}                  Functions using FPU registers
28      @{"PowerUP" LINK PowerUP}                    Phase 5 PowerUP files
29      @{"VBCC" LINK VBCC}                       VBCC compiler files
31     @{"Important words" LINK Words}             Explanation of words and phrases used
32     @{"Bugs and Problems" LINK Bugs}           Known bugs and problems
34     @{"Library design" LINK LibDesign}              Short words on how to design your own libraries
35     @{"Pragma design" LINK PragmaDesign}               Design description of pragmas
36     @{"XML file design" LINK XMLDesign}             Design description of XML-IDL files
37     @{"SFD file design" LINK SFDDesign}             Design description of SFD files
38     @{"FD file design" LINK FDDesign}              Design description of FD files
39     @{"Register usage" LINK Registers}              Usage of 680x0 registers
41     @{"Scripts" LINK Scripts}                     Useful scripts to generate needed files
42     @{"usefd2pragma" LINK usefd2pragma}                Useful script interface
44     @{"The End - Last words" LINK Last}        Greetings, author's address ,...
45     @{"Index" LINK Index}                       Index of important phrases
47 Calling the program seems to be (is) very difficult, but it offers you a
48 large set of functions. A lot of options need a lot of abilities to turn
49 them on/off! The program has an internal help, which can be accessed by the
50 standard method: First call "fd2pragma ?" to get the synopsis and afterwards
51 enter ? again to get the argument description. Nobody can remember all the
52 SPECIAL options without that!
54 Read this documentation very carefully, because there are some notes you
55 may not see on fast reading, but which will help you a lot. (for example
56 HEADER option and "" filename)
57 @endnode
59 @remark ********************************************************************
60 @node About
61 This is a utility to create:
62   - the following pragma statements for certain C compilers: amicall,
63     libcall, flibcall, tagcall, and syscall
64   - proto files for C compilers
65   - offset (LVO) files for assembler programs
66   - stub functions for either tag-functions or all library functions
67   - stub functions as assembler text
68   - stub functions as usable link library file
69   - FD files out of pragma files
70   - stubs for C++ compilers (SPECIAL 11, 12, and CLIB)
71   - the files with your own headers inserted
72   - files for using local pointers for shared library bases in compilers
73     which do not normally support this
74   - stub functions for Pascal compilers
75   - inline files for GCC
76   - inline, pragma, and stub libraries using FPU registers
77   - files needed to develop for Phase5's PowerUP boards
78   - unit texts for FPC Pascal compiler
79   - BMAP files for AmigaBASIC and MaxonBASIC
80   - VBCC assembler inline files
81   - VBCC WOS stub texts and link library
82   - VBCC PowerUP stub texts and link library
83   - VBCC MorphOS stub texts and link library
84   - Modules for AmigaE
85   - FD files
86   - CLIB files
87   - SFD files
88   - auto library open files for VBCC
89   - MorphOS files
90   - OS4 XML files
91   - OS4 cross-call code stubs
93 Therefor only the FD file giving the library information is needed. For
94 some SPECIAL options you may additionally supply the CLIB keyword (or you
95 need to supply it) giving fd2pragma the prototypes file in clib directory.
96 Better is to supply the all-in-one SFD format as input.
98 Special option 200 does the opposite of the usual: it converts pragma to FD!
100 Please tell me if something is missing. I do not know all the possibilities
101 of different compiler systems that I do not have, so maybe I disabled some
102 stuff (e.g. entries for PPC), which could be produced normally.
104 Commodore had a special program called sfd, which created FD files, pragmas,
105 stub libs, clib includes, and fd files out of a special sfd file format.
106 Because this format was never released to the public we need to use a
107 program like fd2pragma which uses FD and clib files as input. It is able to
108 create all needed files as well. As fd2pragma is a lot newer than the
109 Commodore tool it can do some more stuff (inline files, Storm files, VBCC
110 files, GCC files, link libraries, C++ names). I got finally the rights to
111 include and release the SFD format, so fd2pragma now also supports this
112 definition files. Thanks a lot to Olaf Barthel for making this possible.
114 I suggest using SFD instead of FD in the future, as it is much better
115 usable and covers all required information in one file. And it means your
116 files are equal to the system development files. OS4 introduces yet another
117 new format, which reduces the SFD format to the parts relevant for OS4 and
118 which uses a standard XML container. fd2pragma does not yet support this
119 format as input source.
120 @endnode
122 @remark ********************************************************************
123 @node Docs
124 This documentation is a collection of nearly all the necessary information
125 about development files related to library creation.
127 It describes the program fd2pragma, its options, the resulting files, the
128 source files, and all the data formats. It also covers a lot of tips and
129 suggestions for designing your own libraries and for designing the
130 development material.
132 If something is missing or unclear, contact me and I will fix the stuff.
134 Greetings go to Gary Goldberg for reading the whole document and fixing lots
135 of errors.
136 @endnode
138 @remark ********************************************************************
139 @node Beginner
140 To make using fd2pragma much easier I collected some example calls, which
141 maybe useful when suing fd2pragma seldom.
143 All the example are based on dos.library files. Replace intuition with
144 the library you want to create files for. Also use the directories which
145 are used on you system.
147 If you have the newer SFD files installed, replace all
148 "fd/dos_lib.fd CLIB clib/dos_protos.h" with "sfd/dos_lib.sfd".
150 If these examples do not fit your needs try different numbers for SPECIAL
151 or start using the additional options.
153 *******************
154 Users of MaxonC++ or StormC++ up to Version V3:
156 1) Create the correct pragma files:
157    fd2pragma fd/dos_lib.fd CLIB clib/dos_protos.h TO pragma SPECIAL 6
159 2) Create the correct proto files:
160    fd2pragma fd/dos_lib.fd CLIB clib/dos_protos.h TO proto SPECIAL 35
162 *******************
163 Users of SAS-C
165 1) Create the correct pragma files:
166    fd2pragma fd/dos_lib.fd CLIB clib/dos_protos.h TO pragma SPECIAL 6
168 2) Create the correct proto files:
169    fd2pragma fd/dos_lib.fd CLIB clib/dos_protos.h TO proto SPECIAL 35
171 *******************
172 Users of Storm V4
174 1) Create the correct inline files:
175    fd2pragma fd/dos_lib.fd CLIB clib/dos_protos.h TO inline SPECIAL 43
177 2) Create the correct proto files:
178    fd2pragma fd/dos_lib.fd CLIB clib/dos_protos.h TO proto SPECIAL 39
180 *******************
181 Users of GCC
183 1) Create the correct inline files:
184    fd2pragma fd/dos_lib.fd CLIB clib/dos_protos.h TO inline SPECIAL 40
186 2) Create the correct proto files:
187    fd2pragma fd/dos_lib.fd CLIB clib/dos_protos.h TO proto SPECIAL 35
189 *******************
190 Users of VBCC (when using inlines)
192 1) Create the correct inline files:
193    fd2pragma fd/dos_lib.fd CLIB clib/dos_protos.h TO inline SPECIAL 70
195 2) Create the correct proto files:
196    fd2pragma fd/dos_lib.fd CLIB clib/dos_protos.h TO proto SPECIAL 38
198 *******************
199 All systems
201 1) Create pragmas to proto redirect:
202    fd2pragma fd/dos_lib.fd CLIB clib/dos_protos.h TO pragmas SPECIAL 80
204 @endnode
206 @remark ********************************************************************
207 @node Options
208 You get the command template with fd2pragma ? .
210 FROM=INFILE/A,SPECIAL/N,MODE/N,TO/K,ABI/K,CLIB/K,COPYRIGHT/K,HEADER/K,
211 HUNKNAME/K,BASENAME/K,LIBTYPE/K,LIBNAME/K,PRIORITY/N/K,PREFIX/K,
212 SUBPREFIX/K,PREMACRO/K,COMMENT/S,EXTERNC/S,FPUONLY/S,NEWSYNTAX/S,NOFPU/S,
213 NOPPC/S,NOPPCREGNAME/S,NOSYMBOL/S,ONLYCNAMES/S,OPT040/S,PPCONLY/S,
214 PRIVATE/S,SECTION/S,SMALLCODE/S,SMALLDATA/S,SORTED/S,SYSTEMRELEASE/S,
215 USESYSCALL/S,VOIDBASE/S:
217 In this position you may press <?> again and you get the following text!
218 Remember that! I myself need this whenever I call the program, as nobody
219 can remember all these options.
220 Be careful, because this text is longer than one normal high-resolution
221 screen, so it is useful to press a key in the middle of the text to stop
222 the output.
224 INFILE:  the input file which should be used
225 SPECIAL:
226 *OBSOL*  1 - Aztec compiler (xxx_lib.h,     MODE 2, AMICALL)
227 *OBSOL*  2 - DICE compiler  (xxx_pragmas.h, MODE 3, LIBCALL)
228 *OBSOL*  3 - SAS compiler   (xxx_pragmas.h, MODE 3, LIBCALL,LIBTAGS)
229 *OBSOL*  4 - MAXON compiler (xxx_lib.h,     MODE 1, AMICALL)
230 *OBSOL*  5 - STORM compiler (xxx_lib.h,     MODE 1, AMITAGS,AMICALL)
231          6 - pragma for all compilers [default]
232 *OBSOL*  7 - all compilers with pragma to inline redirect for GCC
233         10 - stub-functions for C - C text
234 *OBSOL* 11 - stub-functions for C - assembler text
235         12 - stub-functions for C - link library
236         13 - defines and link library for local library base (register call)
237         14 - defines and link library for local library base (stack call)
238 *OBSOL* 15 - stub-functions for Pascal - assembler text
239         16 - stub-functions for Pascal - link library
240         17 - BMAP file for AmigaBASIC and MaxonBASIC
241         18 - module for AmigaE
242         20 - assembler lvo _lvo.i file
243         21 - assembler lvo _lib.i file
244         22 - assembler lvo _lvo.i file no XDEF
245         23 - assembler lvo _lib.i file no XDEF
246         24 - assembler lvo link library
247 *OBSOL* 30 - proto file with pragma/..._lib.h call
248 *OBSOL* 31 - proto file with pragma/..._pragmas.h call
249 *OBSOL* 32 - proto file with pragmas/..._lib.h call
250 *OBSOL* 33 - proto file with pragmas/..._pragmas.h call
251 *OBSOL* 34 - proto file with local/..._loc.h call
252         35 - proto file for all compilers (VBCC stubs)
253 *OBSOL* 36 - proto file for GNU-C compiler only
254 *OBSOL* 37 - proto file without lib definitions
255         38 - proto file for all compilers (VBCC inline)
256 *OBSOL* 39 - proto file with special PPC related checks
257         40 - GCC inline file (preprocessor based)
258         41 - GCC inline file (old type - inline based)
259         42 - GCC inline file (library stubs)
260         43 - GCC inline file (new style - macro)
261         44 - GCC inline file (new style - inline)
262         45 - GCC inline file (new style - inline with include lines)
263         46 - GCC inline file (preprocessor based, direct)
264         47 - GCC inline file (new style, direct)
265         48 - GCC inline file (preprocessor based, direct, StormGCC)
266         50 - GCC inline files for PowerUP (preprocessor based)
267         51 - GCC inline files for PowerUP (old type - inline based)
268         52 - GCC inline files for PowerUP (library stubs)
269         53 - SAS-C include file for PowerUP
270         54 - Proto file for PowerUP
271         60 - FPC pascal unit text
272         70 - VBCC inline files
273 *OBSOL* 71 - VBCC WOS stub-functions - assembler text
274 *OBSOL* 72 - VBCC WOS stub-functions - assembler text (libbase)
275         73 - VBCC WOS stub-functions - link library
276         74 - VBCC WOS stub-functions - link library (libbase)
277 *OBSOL* 75 - VBCC PowerUP stub-functions - assembler text
278         76 - VBCC PowerUP stub-functions - link library
279         77 - VBCC WOS inline files
280         78 - VBCC MorphOS stub-functions - link library
281 *OBSOL* 79 - VBCC old inline files
282         80 - pragma/proto redirect (xxx_pragmas.h, SAS/Dice)
283         81 - pragma/proto redirect (xxx_lib.h, Aztec/Maxon/Storm)
284         82 - pragma/proto redirect (xxx.h, GCC)
285         83 - pragma/proto redirect (xxx_protos.h, VBCC)
286         90 - stub-functions for C - assembler text (multiple files)
287         91 - VBCC PowerUP stub-functions - assembler text (multiple files)
288         92 - VBCC WOS stub-functions - assembler text (multiple files)
289         93 - VBCC MorphOS stub-functions - assembler text (multiple files)
290        100 - PPC assembler lvo file
291        101 - PPC assembler lvo file no XDEF
292        102 - PPC assembler lvo ELF link library
293        103 - PPC assembler lvo EHF link library
294        104 - PPC V.4-ABI assembler file
295        105 - PPC V.4-ABI assembler file no XDEF
296        106 - PPC V.4-ABI assembler lvo ELF link library
297        107 - PPC V.4-ABI assembler lvo EHF link library
298        110 - FD file
299        111 - CLIB file
300        112 - SFD file
301        120 - VBCC auto libopen files (C source)
302        121 - VBCC auto libopen files (m68k link library)
303        122 - VBCC MorphOS inline files
304        130 - GCC inline files for MorphOS (preprocessor based)
305        131 - GCC inline files for MorphOS (old type - inline based)
306        132 - GCC inline files for MorphOS (library stubs)
307        133 - GCC inline files for MorphOS (library stubs, direct varargs)
308        134 - MorphOS gate stubs
309        135 - MorphOS gate stubs (prelib)
310        136 - MorphOS gate stubs (postlib)
311        137 - MorphOS gate stubs (reglib, prelib)
312        138 - MorphOS gate stubs (reglib, postlib)
313        140 - OS4 XML file
314        141 - OS4 PPC->M68K cross-call stubs
315        142 - OS4 M68K->PPC cross-call stubs
316        200 - FD file (source is a pragma file!)
317 MODE:          SPECIAL 1-7:
318                  1: _INCLUDE_PRAGMA_..._LIB_H definition method [default]
319                  2: _PRAGMAS_..._LIB_H definition method
320                  3: _PRAGMAS_..._PRAGMAS_H definition method
321                  4: no definition
322                SPECIAL 11-14,40-45,50-53,70-76,78,90-91,111-112,122,
323                        130-138,141:
324                  1: all functions, normal interface
325                  2: only tag-functions, tagcall interface
326                  3: all functions, normal and tagcall interface [default]
327 TO:            the destination directory (self creation of filename)
328 ABI:           set ABI type (m68k|ppc|ppc0|ppc2)
329 CLIB:          name of the prototypes file in clib directory
330 COPYRIGHT:     the copyright text for CLIB files
331 HEADER:        inserts given file into header of created file ("" is scan)
332 HUNKNAME:      use this name for HUNK_NAME instead of default 'text'
333 BASENAME:      name of library base without '_'
334 LIBNAME:       name of the library (.e.g. dos.library)
335 LIBTYPE:       type of base library structure
336 PRIORITY:      priority for auto open files
337 PREFIX:        MorphOS gate prefix
338 SUBPREFIX:     MorphOS gate sub prefix
339 PREMACRO:      MorphOS gate file start macro
340 Switches:
341 AUTOHEADER     add the typical automatic generated header
342 COMMENT:       copy comments found in input file
343 EXTERNC:       add a #ifdef __cplusplus ... statement to pragma file
344 FPUONLY:       work only with functions using FPU register arguments
345 NEWSYNTAX:     uses new Motorola syntax for asm files
346 NOFPU:         disable usage of FPU register arguments
347 NOPPC:         disable usage of PPC-ABI functions
348 NOPPCREGNAME:  do not add 'r' to PPC register names
349 NOSYMBOL:      prevents creation of SYMBOL hunks for link libraries
350 ONLYCNAMES:    do not create C++ or ASM names
351 OPT040:        optimize for 68040, do not use MOVEM for stubs
352 PPCONLY:       only use PPC-ABI functions
353 PRIVATE:       includes private declared functions
354 SECTION:       add section statements to asm texts
355 SMALLCODE:     generate small code link libraries or assembler text
356 SMALLDATA:     generate small data link libraries or assembler text
357 SMALLTYPES:    allow 8 and 16 bit types in registers
358 SORTED:        sort generated files by name and not by bias value
359 SYSTEMRELEASE: special handling of comments for system includes
360 USESYSCALL:    uses syscall pragma instead of libcall SysBase
361 VOIDBASE:      library bases are of type void *
362 @endnode
364 @remark ********************************************************************
365 @node Examples
366 Useful examples (with intuition.library):
368 1) fd2pragma <FD file> TO <pragma dir>
370    fd2pragma FD:intuition_lib.fd TO INCLUDE:pragma/
372         Creates a pragma file for all C compilers and copies it to the
373         given directory.
375 2) fd2pragma <FD file> CLIB <clib file> SPECIAL 12 TO <lib dir>
377    fd2pragma FD:intuition_lib.fd CLIB INCLUDE:clib/intuition_protos.h
378      SPECIAL 12 TO LIB:
380         Creates a link library holding stub functions to call tag-functions
381         from compilers which do not support them (MaxonC++).
383 3) fd2pragma <FD file> CLIB <clib file> SPECIAL 13 MODE 3
385    fd2pragma FD:intuition_lib.fd CLIB INCLUDE:clib/intuition_protos.h
386      SPECIAL 13 MODE 3
388         Creates a link library and an include file which allow you to call
389         library functions with local base variables in compilers which do
390         not support that (MaxonC++). See @{"below" LINK Local} how to handle these files.
392 4) fd2pragma <FD file> SPECIAL 34 TO <proto dir>
394    fd2pragma FD:intuition_lib.fd SPECIAL 34 TO INCLUDE:proto/
396         Creates a proto file for the local library base file include, which
397         was created in example 3 and copies it to the given directory.
399 5) fd2pragma <FD file> SPECIAL 35 TO <proto dir>
401    fd2pragma FD:intuition_lib.fd SPECIAL 35 TO INCLUDE:proto/
403         Creates a proto file for all C compilers and copies it to the
404         given directory.
406 6) fd2pragma <FD file> CLIB <clib file> SPECIAL 40
408    fd2pragma FD:intuition_lib.fd CLIB INCLUDE:clib/intuition_protos.h
409      SPECIAL 40
411         Creates inline include for GCC. This is used by GCC instead of
412         pragma files for other compilers.
413 @endnode
415 @remark ********************************************************************
416 @node OptionAll "Option explanation of all user options"
417 INFILE is the always needed source file, which describes the library. This
418        maybe an FD file (usually together with CLIB file) or an SFD file.
420 SPECIAL option:
422 (create a pragma file)
423   1: Creates a pragma file for the Aztec compiler; you will see in
424      the brackets above what this means.
425      *OBSOLETE*
426   2: Same as 1 for DICE compiler.
427      *OBSOLETE*
428   3: Same as 1 for SAS compiler.
429      *OBSOLETE*
430   4: Same as 1 for MAXON compiler.
431      *OBSOLETE*
432   5: Same as 1 for STORM compiler.
433      *OBSOLETE*
434   6: This option creates a pragma file usable for nearly all compilers.
435      This is the default when no other mode is given.
436   7: same as 6, but redirects file to inline directory for GCC.
437      *OBSOLETE*
439 (link libraries and their assembler code)
440  10: Creates stub functions in correct C code which handle the varargs
441      feature. CLIB parameter is useful with this to get correct functions.
442      The only problem with these files is that there is space wasted when
443      not all functions are used.
445  11: Same as 11, but the result as plain Assembler text.
446      *OBSOLETE*
448  12: Creates STUB functions for C compilers which are unable to call a
449      library directly (the result is a link library, which can be used by
450      the C compiler directly), and accepts option CLIB to create additional
451      function names for C++ compilers like MaxonC++.
453  13: Creates two files (a link library and a C include) which allows you to
454      use local library base variables also in compilers, which do normally
455      not support them (MaxonC++). Usually time it is useful to set option
456      MODE to 3 or 1. This options needs CLIB keyword for correct results.
458  14: Same as 13, but parameters are passed on stack.
460  15: Same as 16, but the result as plain Assembler text.
461      *OBSOLETE*
463  16: Creates STUB functions for PCQ Pascal compilers. The tagcall function
464      names are ignored, as they cannot be used with Pascal. The result is
465      link library. The resulting code is the same as for C compilers, but
466      the args are taken from the stack in reverse order. (C and Pascal
467      normally pass arguments on stack. C passes the last argument first
468      (= highest position, stack is filled backwards) and first argument last
469      (lowest position). Pascal is the other way round. So Pascal stubs are
470      C stubs with the argument order reversed.
472  17: Creates BMAP files used by certain BASIC variants (e.g. AmigaBASIC,
473      MaxonBASIC).
475  18: Creates Module for AmigaE.
477 (assembler LVO files)
478  20: Creates lvo file for an assembler.
479  21: Same as 20, but with another name.
480  22: Same as 20, but there are no XDEF statements in the resulting file.
481  23: Same as 22, but with another name.
482  24: Creates lvo defintion file as link library (like in amiga.lib)
484 (proto files - no prototypes)
485  30,31,32,33,34: Creates proto files for the C compiler (the difference is
486      in the name of the called file).
487      *OBSOLETE*
488  35: Creates proto file which calls inline files for GNU-C and
489      pragma/xxx_lib.h for all the others. VBCC calls no files but uses
490      the stubs. See also SPECIAL 38.
491  36: Creates proto file for GNU-C. This differs from SPECIAL 35 only by
492      define __CONSTLIBBASEDECL__ and removed pragma and VBCC call.
493      *OBSOLETE*
494  37: Creates proto file, which only calls CLIB and defines library base.
495  38: Like 35, but includes <inline/xxx_protos.h> for VBCC. This is turned
496      off for standard mode 35. This type is useful for m68k and MorphOS
497      compiler variants which have inline files (See type 122 and 70).
498  39: Like 35, but with special PPC related checks
499      *OBSOLETE*
500  fd2pragma knows the correct library base structures for some libraries.
501  All the other libraries get 'struct Library' as default.
503 (GCC inline files)
504  40: Creates new style GCC inline files.
505  41: Creates old style GCC inline files.
506  42: Same as 41, but no "extern" keyword before functions.
507  43: New style macro based GCC definitions. Format suggested by Bernardo
508      Innocenti. It is still better to use types 40-42, as at the moment it
509      produces code which is less optimized. But this type can be used to
510      prevent some errors and shortcomings in types 40-42.
511  44: Like 43, but uses inline functions instead of macros.
512  45: Like 44, but also copies include lines form clib file
513  46: Like 40, but needs no macro include and also fixes some problems.
514  47: A new style of Inlines designed by Gunther Nikl. Solves some problems
515      but probably introduces some new.
516  48: The same as 46 with a special fix for StormGCC and functions with
517      really lots of arguments. Will be equal to SPECIAL 46 in most cases.
519 (Phase5 PowerUP files)
520  50: Creates files like 40, but for PowerUP.
521  51: Creates files like 41, but for PowerUP.
522  52: Creates files like 42, but for PowerUP.
523  53: Creates SAS-C include file for PowerUP (named as pragma files in
524      PowerUP files for no logical reason).
525  54: Creates a proto file for PowerUP (usable for GNU-C and SAS).
527 (Pascal stuff)
528  60: This creates a unit text file for FPC Pascal compiler.
530 (VBCC stuff)
531  70: This creates inline files for VBCC C compiler.
532  71: This is an assembler stub for VBCC-WOS C compiler.
533      *OBSOLETE*
534  72: Same as 71, but first argument (r3) is library base (-l of fd2libWOS).
535      *OBSOLETE*
536  73: VBCC-WOS link library in EHF format.
537  74: Like 73,  but first argument (r3) is library base (-l of fd2libWOS).
538  75: This is an assembler stub for VBCC-PowerUP C compiler.
539      *OBSOLETE*
540  76: VBCC-PowerUP link library in ar format.
541  77: This creates inline files for VBCC C compiler WOS functions.
542  78: VBCC-MorphOS link library in ar format.
543  79: This is like type 70, but uses the old style with library base as last
544      argument. It does not support variable arguments functions and should
545      not be used at all. This is for compatibility (better fix your code).
546      *OBSOLETE*
548 (redirect files)
549  80: Redirects the call to proto file. Has the name of SAS or DICE pragma
550      file. Should be copied to pragmas.
551  81: Equal to 80. Has the name of Aztec, Maxon or Storm. Should be copied
552      to pragmas (Aztec redirect) or pragma.
553  82: Equal to 80. Has the name of GCC inline file. Should be copied to
554      inline.
555  83: Equal to 80. Has the name of VBCC inline file. Should be copied to
556      inline.
557 Install only redirects for files/compilers you do not have or you will
558 overwrite real pragmas or inlines.
560 (multiple files)
561  90: Creates STUB functions for C compilers which are unable to call a
562      library directly (the result are ASM source codes), and accepts
563      option CLIB to create additional function names for C++ compilers
564      like MaxonC++.
565  91: These are assembler stubs for VBCC-PowerUP C compiler.
566  92: These are assembler stubs for VBCC-WOS C compiler.
567  93: These are assembler stubs for VBCC-MorphOs C compiler.
569 (PPC assembler LVO files)
570 100: Creates lvo file for an PPC assembler.
571 101: Same as 101, but there are no XDEF statements in the resulting file.
572 102: Creates lvo defintion file as ELF link library.
573 103: Creates lvo defintion file as EHF link library.
574 104: Same as 20, but names without '_'.
575 105: Same as 21, but names without '_'.
576 106: Same as 22, but names without '_'.
577 107: Same as 23, but names without '_'.
579 (source file recreation)
580 110: Produce an FD file.
581 111: Produce an CLIB file.
582 112: Produce an SFD file.
584 (auto library open files for VBCC)
585 120: Produce 2 C code files for auto library opening. Note option
586      PRIORITY and LIBNAME for these types.
587 121: Produce 1 m68k assembler link library for auto library opening.
588 122: This creates inline files for VBCC C compiler MorphOS variant.
590 (MorphOS files)
591 130: Creates new style GCC inline files for MorphOS.
592 131: Creates old style GCC inline files for MorphOS.
593 132: Creates GCC library stubs for MorphOS.
594 133: Creates GCC library stubs for MorphOS with direct varargs.
595 134: Creates MorphOS gate stubs.
596 135: Creates MorphOS gate stubs with prefixed library base.
597 136: Creates MorphOS gate stubs with postfixed library base.
598 137: Like 135, but with register base.
599 138: Like 136, but with register base.
601 (OS4 files)
602 140: Create new OS4 description format @{"XML file" LINK XMLDesign}.
603 141: Create new stubs for OS4 PPC->M68K cross-calls.
604 142: Create new stubs for OS4 M68K->PPC cross-calls. May produce one
605      assembler and one C file.
607 (FD file)
608 200: This creates a FD file! The option INFILE has to be a pragma file
609      here!
610 @endnode
612 @remark ********************************************************************
613 @node OptionAdvanced "Options for detailed control"
614 MODE:
615 1) given with SPECIAL 1 to 7:
616    - Defines, which #ifdef ...\n#define ... statement is used in the pragma
617      file. Option 1 is default.
619 2) given with SPECIAL 11 to 14, 40 to 45, 50 to 53, 70 to 76, 78, 90 to 93,
620    111 to 112, 122, 130 to 138:
621    - Defines, which functions should be created. Option 3 is default.
622      1 - all functions are taken in normal way with normal name
623      2 - only tag-functions are taken with tagcall method and tag name
624      3 - means 1 and 2 together
626 TO: Here you specify the destination directory. The internal names are used,
627    but the file(s) will be in the given directory.
629 ABI: Allows to set initial ABI type for FD file to any of the supported
630 types "m68k, ppc, ppc0, ppc2". This is equal to ##abi statement.
632 CLIB: Supply name of the prototypes file in clib directory. If this option
633 is given together with SPECIAL 11 and 12, additional functions names
634 with C++ names are created. fd2pragma knows all standard parameter types
635 defined in exec/types.h and dos/dos.h, all structures and some more types.
636 All other #typedef's bring a warning. Do not use them in prototypes files!
637 This parameter is needed by option SPECIAL 10, 12, 13, 40 to 42 and 50 to
638 53. It may be required for options 71 to 74 (depending on data).
639 You may define unknown types using the @{"fd2pragma.types" LINK TypesFile} file.
641 COPYRIGHT: The copyright text, which is used for CLIB production.
643 HEADER: This option gives you the ability to specify a file, which should
644 be inserted after the normal headers and before the clib call of standard
645 headers (in LVO and ASM files too). If you give "" (empty string) or \@ as
646 filename, the destination file (if already exists) will be scanned for an
647 existing header. This is useful for updating files. See @{"HeaderScan" LINK "HeaderScan"}
648 to find out how a header must be built to be recognized.
650 HUNKNAME: This allows to set the HUNK_NAME to any desired value. Default is
651 'text'.
653 BASENAME: This allows to overwrite the library basename. The string must be
654 without leading '_'.
656 LIBNAME: The name of the library (e.g. dos.library).
658 LIBTYPE: This allows to define the structure name of base library. The program
659 knows some types internally and uses "Library" for all the others. Specify the
660 type here, if it is unknown to fd2pragma.
661 Example: "LIBTYPE DosLibrary" for dos_lib.fd (is known by fd2pragma).
663 PRIORITY: Priority for types 120 and 121.
665 AUTOHEADER: Adds a header line
666 "Automatically generated header! Do not edit!" as header. This will conflict
667 with own headers with undefined results.
669 COMMENT: Comments which are in the FD file are copied to the pragma or LVO
670 file, when this option is given! When SORTED is given, this option is
671 disabled.
673 EXTERNC: This options adds an #ifdef __cplusplus ... statement to the
674 pragma file. This option is useful for C compilers running in C++ mode, but
675 it seems, that they do not really need this statement. Only useful with
676 SPECIAL option 1-7, 13, and 14.
678 FPUONLY: This options is the opposite to NOFPU. It forces fd2pragma to
679 ignore all functions not using FPU registers for passing arguments.
680 It is really useless to both specify FPUONLY and NOFPU.
682 NEWSYNTAX: Produce new Motorola syntax for ASM output.
684 NOFPU: This disables usage of FPU arguments. Functions using FPU arguments
685 are not converted with this option (as e.g. Maxon does not support amicall
686 with FPU args). You get a warning for every line containing FPU arguments.
687 It is really useless to both specify NOFPU and FPUONLY.
689 NOPPC: This disables use of PPC functions. These function are totally
690 ignored now. You get no warning.
691 It is really useless to both specify NOPPC and PPCONLY.
693 NOPPCREGNAME: If your PPC assembler does not support the "r" before register
694 names, use this switch and only the register number will be printed.
696 NOSYMBOL: Does not create symbol hunks for link libraries.
698 ONLYCNAMES: If CLIB keyword is supplied, but C++ names are not wanted, this
699 keyword prevents creation of these additional names. Also the ASM names are
700 no longer created
702 OPT040: Optimizes stub functions for 68040, by replacing MOVEM by MOVE's.
704 PPCONLY: This disables use of all non-PPC functions. These function are
705 ignored totally now. You get no warning.
706 It is really useless to both specify PPCONLY and NOPPC.
708 PREFIX: MorphOS gate function prefix.
710 PREMACRO: MorphOS gate function prefix macro.
712 PRIVATE: Also gives you the pragmas or LVO's of private functions.
713 Normally these functions should never be used!
715 SECTION: Adds sections statements to assembler texts. Only useful with
716 options creating stub files.
718 SMALLCODE: Forces function references to use (PC) relative addressing instead
719 of absolute addressing.
721 SMALLDATA: Normally the large data model references the library base as a
722 global variable. In the small data model the reference is relative to
723 register A4 instead. This option is useful for stub texts and link
724 libraries.
726 SMALLTYPES: When converting SFD files, all the 8 and 16 bit types are
727 converted to LONG or ULONG as does the SFD tool. This argument disables this
728 behaviour and takes the types, as they are.
730 SORTED: This option sorts generated files by name and not by bias value.
731 This is only for visibility and does not change the use of the files.
733 SUBPREFIX: MorphOS gate function subprefix.
735 SYSTEMRELEASE: Some special comment handling for system release include
736 files.
738 USESYSCALL: Instructs fd2pragma to use the syscall pragma instead of a
739 libcall SysBase. This is useful only, when using a SPECIAL option with
740 LIBCALL and converting exec_lib.fd. I think only SAS compiler supports
741 this statement.
743 VOIDBASE: Very seldom it may be useful to use generic type "void *" instead of
744 the correct base type for some file types. This keyword allows to do so.
745 @endnode
747 @remark ********************************************************************
748 @node Includes
749 Useful include system for C compilers:
751 After programming a long time I arranged my includes in a way that all my
752 C compilers are able to use the system includes in one directory.
754 I copied all Amiga system includes to one directory and added some files
755 created with fd2pragma. These are the system includes you get, for example,
756 on the Amiga Developer CD.
758  - New directory 'pragma' contains xxx_lib.h pragma files for every
759    library. These files were created with SPECIAL option 6.
760  - New directory 'proto' contains xxx.h proto files which were created with
761    with SPECIAL option 35.
762  - New directory 'inline' contains xxx.h inline files for GCC. These files
763    were created with SPECIAL option 40.
764  Directories like 'pragmas' were deleted, when they exist. Only
765  'clib', 'pragma', 'proto', and library-specific directories (like 'dos',
766  'exec', 'libraries' and 'utility') should remain.
768 All the others (ISO-C stuff, compiler specials) were copied to another
769 directory. In S:User-StartUp I use 'Assign ADD' to join the two
770 directories, so that the compiler may access both.
771 @endnode
773 @remark ********************************************************************
774 @node Names "The default output file names"
775 fd2pragma automatically produces the names for output files.
777 If the input file is called xxx_lib.fd or xxx_lib.sfd the xxx is used as
778 name base, else the basename of ##base statement is used. The "Base" at
779 the end is stripped.
781 List of used names:
782 *******************
784 "xxx_cstub.h"    stub functions in C code
785  SPECIAL 10
787 "xx_gates.h"     MorphOS gates
788  SPECIAL 134-138
790 "xxx_lib.h"      C compiler pragma files
791  SPECIAL 1, 4 - 7, 81
793 "xxx_lib.i"      LVO definitions for Assembler
794  SPECIAL 21, 23, 100-101, 104-105
796 "xxx_loc.h"      Local library base definition file for C compilers
797  SPECIAL 13, 14
799 "xxx_lvo.i"      LVO definitions for Assembler
800  SPECIAL 20, 22
802 "xxx_pragmas.h"  C compiler pragma files
803  SPECIAL 2, 3, 8, 53, 80
805 "xxx_protos.h"   VBCC inline files
806  SPECIAL 70, 79, 83, 122
808 "xxx_stub.s"     stub functions as Assembler text (68K, PPC)
809  SPECIAL 11, 15, 71, 72, 75
811 "libxxx.a"       ar object file archive (link library)
812  SPECIAL 76,78
814 "xxx.bmap"       BASIC definition file for function calls
815  SPECIAL 17
817 "xxx.h"          C compiler proto or inline files
818  SPECIAL 30 - 48, 50 - 52, 54, 82, 130-133
820 "xxx.lib"        link library (68K, PPC)
821  SPECIAL 12, 16, 73, 74
823 "xxxlvo.o"       link library lvo entries (68K, PPC)
824  SPECIAL 24, 103, 107
826 "xxxlvo.o"       link library lvo entries (PowerUP)
827  SPECIAL 102, 106
829 ""xxx.m"         E module
830  SPECIAL 18
832 "xxx.pas"        FPC unit text file
833  SPECIAL 60
835 "xxx_lib.fd"     FD file
836  SPECIAL 110, 200
838 "xxx_protos.h"   CLIB file
839  SPECIAL 111
841 "xxx_lib.sfd"    SFD file
842  SPECIAL 112
844 "xxx.xml"        XML file
845  SPECIAL 140
847 "xxx.c"          C Source
848  SPECIAL 141
850 "xxx_68k.s"      Assembler source for OS4 cross-calls
851  SPECIAL 142
853 "xxx_68k.c"      C Source for OS4 cross-calls
854  SPECIAL 142
856 List of used single-file names:
857 *******************************
859 The xxx in these files is the funtion name.
861 "xxx.s"          stub function as Assembler text (68K, PPC)
862  SPECIAL 90-93
864 @endnode
866 @remark ********************************************************************
867 @node LinkLib "link libraries"
868 About created link libraries (SPECIAL Option 12-14):
870 The created link libraries are relatively large compared to other link
871 libraries. The size of the link library has nothing to do with the size of
872 the resulting program you create. The code part of my link libraries is
873 relatively short, but fd2pragma defines a lot of texts (which are NOT copied
874 to the executable program created). These texts are for easier
875 identification and every function also gets different names:
877   1) the normal asm name:  <name>               (e.g.  CopyMem)
878   2) the normal C name:   _<name>               (e.g. _CopyMem)
879   3) the normal C++ name:  <name>_<params>      (e.g.  CopyMem_PvPvUj)
880   4) when a function parameter is STRPTR, a second C++ name is created
881   5) string 3 with different register spec (only func-ptr args with reg-params)
882   6) string 4 with different register spec (only func-ptr args with reg-params)
884 Forms 3-6 occur only, when you use CLIB keyword. Forms 5 and 6 should nearly
885 never occur! With SPECIAL options 13 and 14 the number of strings is doubled.
886 The different names give a lot more flexibility and only make the link library
887 bigger. These names are only visible to the linker program. The resulting
888 executable usually is a lot smaller than the link library!
890 If ONLYCNAMES is given the number of names is reduced to 1 (type 2).
892 I think the code part of the link libraries is totally optimized. I do not
893 know of any possible improvement to make it shorter.
895 If you join all the link libraries made with SPECIAL 12 and join it with
896 small.lib from Developer kit, you get a replacement for amiga.lib.
897 @endnode
899 @remark ********************************************************************
900 @node Proto "proto files"
901 fd2pragma is able to generate different proto files, but I suggest using
902 only the file generated with SPECIAL option 35.
904 For system libraries and some others the correct base structure is used.
905 Other unknown basenames get "struct Library *" as default. You may change
906 that in the created proto files when another structure is correct.
908 The proto files support following define:
910  __NOLIBBASE__
912 When this is set before calling the proto file, the declaration of the
913 global library base is skipped, so that can be done in source-code. This
914 define is also used for GCC.
916 The file created with SPECIAL 36 supports an additionally define:
918   __CONSTLIBBASEDECL__
920 When this is set to "const" the library base is handled as const. This may
921 shorten the produced code, but you need a sourcefile without this define
922 to initialize the base variable.
923 @endnode
925 @remark ********************************************************************
926 @node IncludeDefs "defines used in include files"
927 The first #ifdef/#define statements of created C includes:
929 fd2pragma has a set of different define names for different include files.
930 These names are internal to allow double-inclusion of one include files
931 without getting errors. Standard system includes use the same system.
933 The normal names are: (example intuition.library)
934  proto files:                           _PROTO_INTUITION_H
935  local library base files:              _INCLUDE_PROTO_INTUITION_LOC_H
936  standard pragma files:                 _INCLUDE_PRAGMA_INTUITION_LIB_H
937  C stubs files:                         _INCLUDE_INTUITION_CSTUB_H
938  inline files for GCC                   _INLINE_INTUITION_H
939  PPC inline files for GCC               _PPCINLINE_INTUITION_H
940  SAS-C PPC pragma files                 _PPCPRAGMA_INTUITION_H
941  vbcc inline files                      _VBCCINLINE_INTUITION_H
942  MorphOS gate files                     _GATESTUBS_INTUITION_H
943  clib files                             CLIB_INTUITION_PROTOS_H
945 Non-fd2pragma names are:
946  other includes (path_name_extension)   INTUITION_INTUITION_H
948 These names should never be used in other files or sources! This rule is
949 broken for some standard system includes, but is generally true. Compiling
950 may be a few seconds faster when you check these names before the #include
951 line, but in this case the names must be standard and they are not!
953 Some defines allow the user to change the behaviour of the includes:
955   __NOLIBBASE__
956 This is used in proto files. See @{"Proto files" LINK Proto} for more information.
958   NO_INLINE_STDARG or NO_PPCINLINE_STDARG
959 For GCC inline files a lot of defines exist, but this seems to be the most
960 important. It disables the creation of varags/tagcall functions.
961 For other inline defines check the created inline files.
963   NO_OBSOLETE
964 This is used in SPECIAL 7 and 80-83 redirect files. If it is used, the
965 compiler will return an error instead of using the redirect.
967   <library>_BASE_NAME
968 Function definitions in the inline files refer to the library base variable
969 through the <library>_BASE_NAME symbol (e.g. INTUITION_BASE_NAME). At the
970 top of the inline file, this symbol is redefined to the appropriate library
971 base variable name (e.g., IntuitionBase), unless it has been already
972 defined. This way, you can make the inlines use a field of a structure as
973 a library base, for example.
974 @endnode
976 @remark ********************************************************************
977 @node Local "local library base files"
978 When using SPECIAL options 13 and 14 you get two files called libname_loc.h
979 and libname_loc.lib. The second one is a link library and should be passed
980 to the compiler with program settings or in makefile. The first one is a C
981 header file and should be used as a replacement for files in clib, pragma,
982 proto and pragmas directories. Always use the libname_loc.h file instead of
983 these files and not together with them! Do not mix them.
984 I suggest copying the header file into a directory called "local".
986 This file holds prototypes like those in the clib directory, but with
987 struct Library * as the first parameter and the name prefix LOC_. Together
988 with the prototypes there are some defines redefining the function name to
989 the old one and passing the library base as first parameter. These defines
990 allow you to use the local library bases as normal as global bases. For
991 tag-functions and some exceptions these defines do not work and you have
992 to call the LOC_ function directly and pass the library base as first
993 parameter.
995 Use need the CLIB keyword together with SPECIAL option 13 and 14.
996 @endnode
998 @remark ********************************************************************
999 @node HeaderScan "How the header scan works"
1000 Giving the HEADER option lets fd2pragma insert the file (you have to give
1001 a filename with HEADER option) at the start of the LVO/Pragma/Proto/stub
1002 file. When you pass "" or \@ as filename, fd2pragma scans the destination
1003 file (if it already exists) for a header and copies this header to the new
1004 file.
1006 How scanning is done:
1007 fd2pragma scans for a block of comment lines. So when a line starting with
1008 '*', ';' or '//' is found, this line is the first header line. The header
1009 ends before the first line not starting this way. Additionally, when
1010 fd2pragma finds first a line starting with '/*' it scans until a line holds
1011 '*/'. This then is the last line of header. Same is done for Pascal
1012 comments using '(*' and '*)' or '{' and '}'.
1014 C and ASM files are scanned the same way, so sometimes fd2pragma may get a
1015 wrong header.
1016 @endnode
1018 @remark ********************************************************************
1019 @node TagFuncs "Method of tag-function handling"
1020 The tag-functions are supported by certain comments. Note that the
1021 official includes from the Native Developer Update Kit do not have these
1022 comments included. Let's look at an excerpt from the FD file
1023 muimaster_lib.fd:
1025 MUI_NewObjectA(class,tags)(a0,a1)
1026 *tagcall
1027 MUI_DisposeObject(obj)(a0)
1028 MUI_RequestA(app,win,flags,title,gadgets,format,params)(d0,d1,d2,a0,a1,a2,a3)
1029 *tagcall
1030 MUI_AllocAslRequest(type,tags)(d0,a0)
1031 *tagcalltags
1033 The comments tell us that MUI_NewObjectA, MUI_RequestA, and
1034 MUI_AllocAslRequest should have stub routines. The respective names are
1035 MUI_NewObject, MUI_Request, (as the comment has just the word tagcall) and
1036 MUI_AllocAslRequestTags (as the comment has the word tags included).
1038 Another possibility would be to write something like
1040 SystemTagList(command,tags)(d1/d2)
1041 *tagcall-TagList+Tags
1043 This would create a stub routine or tagcall pragma SystemTags (dropping
1044 the word TagList, adding the word Tags).
1046 fd2pragma is also able to create the names automatically. Most times this
1047 should be enough, so you do not have to use the abovementioned method.
1048 In case you really use the above method, I suggest using always the one
1049 with '+' and '-' signs!
1051 Tag-functions in standard Amiga includes differ a bit in their naming
1052 conventions, so it is easy to find them:
1054 normal function name            tag-function name
1056 xxxA                            xxx
1057 xxxTagList                      xxxTags
1058 xxxArgs                         xxx
1060 Also the arguments given in the FD file may define a function as a tag-
1061 function. If the last argument is one of the words "tags", "taglist" or
1062 "args", then the function has a tag-function named xxxTags or xxxArgs.
1064 There are some exceptions to these rules (some dos.library and
1065 utility.library functions) which are handled automatically.
1067 Sometimes fd2pragma detects functions as tag-functions which are no tag-
1068 functions. This is a problem of the detection, which is based on function
1069 name. Not all programmers follow the unofficial guidelines and thus
1070 fd2pragma produces wrong stuff. If you detect such functions, inform me and
1071 I will remove that behaviour. In any case you may add the line:
1073 *notagcall
1075 as next line in FD file and the detection is turned off for that function.
1076 @endnode
1078 @remark ********************************************************************
1079 @node TypesFile "fd2pragma.types definition file"
1080 This file allows you to define unknown types so that correct C++ names can
1081 be build and also created inline files are valid. The file must be in
1082 current directory or in program directory. If no file can be read, the
1083 internal version is used.
1085 When fd2pragma does not recognize a type you get a warning, telling you
1086 the line number and argument number. Argument number 0 means the return
1087 value of the function. Check the type and add it to the list and fd2pragma
1088 will know it afterwards.
1090 Lines starting with * are seen as a comment and are ignored.
1091 The description format is one 'unknown type : known type' in every line.
1093 Unknown type: A type fd2pragma does not know. It consists of only
1094 one word. All other stuff like C keywords and * is handled internally and
1095 cannot be supplied here.
1097 Known type: The type which is hidden behind the unknown one. It consists of
1098 struct + name, enum + name, union + name, signed, unsigned, const, long
1099 (32 bit), short (16 bit), char (8 bit), int, double and float.
1100 For nameless structs or enums set ? as name.
1102 Structs without a name, but used by a typedef (like: typedef struct {...}
1103 name) get a ! as name.
1105 Also register definitions in style of "register __d0 long" can be used.
1107 The character "*" is a pointer indicator as for C. Multiple of them
1108 represent multiple pointer levels (like in C code).
1110 See already-added example types in the supplied file and send me new types
1111 whenever you get one. It's best to send the definition file also, so I can
1112 check the definitions myself.
1113 @endnode
1115 @remark ********************************************************************
1116 @node FPUusage "Functions using FPU registers"
1117 There may be FD files containing functions with FPU register arguments.
1119 You may use NOFPU keyword to disable processing of these functions.
1121 For link library stub creation of such functions the clib file is
1122 required to determine if argument is double (64 bit) or float/single
1123 (32 bit). An warning message appears when it was not possible to get the
1124 correct type. In this case float is used always.
1125 Extended format is currently not supported.
1127 fd2pragma creates amicall and flibcall pragmas for these functions, but
1128 some compilers cannot use them (e.g. MaxonC).
1129 @endnode
1131 @remark ********************************************************************
1132 @node PowerUP "Files used and created for Phase5's PowerUP boards"
1133 It is very hard to tell something about these as I myself do not know very
1134 much about it. Maybe that is caused by missing documentation.
1136 fd2pragma creates needed files with SPECIAL options starting at number 50.
1137 fd2pragma produces nearly the same files as are made by the special
1138 fd2inline version 1.12 (by Ralph Schmidt). I fixed the protos a bit and
1139 arranged files to follow my general style, but changed nothing in the way
1140 they work.
1142 There are also PowerUp files for @{"VBCC" LINK VBCC}. See the related
1143 chapter for more information.
1145 The files need following directory structure
1146 PPCINLUDE:
1147   powerup
1148     gcclib              support files
1149     ppcinline           GCC inline files (SPECIAL 50)
1150     ppclib              support files
1151     ppcpragmas          SAS-C function definitions (SPECIAL 53)
1152   proto                 proto files for GCC/SAS-C (SPECIAL 54)
1154 Using this SMakeFile with SAS-C I had not yet larger problems:
1156 SCOPTS = RESOPT PARAMETERS=REGISTERS NOSTACKCHECK STRINGMERGE OPTIMIZE \\
1157 OPTIMIZERINLINELOCAL MEMORYSIZE=HUGE OPTIMIZERTIME
1158 SLOPTS = SMALLCODE STRIPDEBUG NOICONS
1160 PROGRAM = # enter name here
1162 ALL: ELF PPC
1163 ELF: $(PROGRAM).elf
1164 PPC: $(PROGRAM).ppc
1166 $(PROGRAM).ppc: $(PROGRAM).ppc.o
1167   slinkppc $(SLOPTS) PPC FROM LIB:c.o $? LIB LIB:scppc.lib TO $@
1168   StripHunks $@  # *** Aminet/util/misc/StripHunks.lha ***
1170 $(PROGRAM).ppc.o: $(PROGRAM).c
1171   scppc $(SCOPTS) $? HUNKOBJ OBJNAME=$@ DEFINE=AMIGA
1173 # *************************** GCC stuff needs ADE 2 CD
1175 PPCLD    = ADE-2:AmigaOS/ready-to-run/bin/ppc-amigaos-ld
1176 PPCSTRIP = ADE-2:AmigaOS/ready-to-run/bin/ppc-amigaos-strip
1178 $(PROGRAM).elf: $(PROGRAM).elf.o
1179   $(PPCLD) -r -s -o $@ lib:c_ppc.o $? lib:scppc.a lib:end.o
1180   $(PPCSTRIP) --strip-unneeded $@
1181   Protect $@ rwed
1183 $(PROGRAM).elf.o: $(PROGRAM).c
1184   scppc $(SCOPTS) $? OBJNAME=$@ DEFINE=AMIGA
1185 @endnode
1187 @remark ********************************************************************
1188 @node VBCC "VBCC compiler files"
1189 SPECIAL 70: inline files
1191   Inline functions to define the Amiga OS calls without stubs.
1193 SPECIAL 73-74: stub link libs for VBCC-WOS
1195  These are normal stub libraries in EHF format. Mode 74 is equivalent to
1196  the argument -l of fd2libWOS and says that the first argument (r3) is the
1197  library base. These files do not support the small data model.
1199 SPECIAL 75: stubs for VBCC-PowerUP
1201  These are normal stub libraries as Assembler text. These files support
1202  the small data model and thus the SMALLDATA argument.
1204 SPECIAL 76: stub link library for VBCC-PowerUP
1206  This is a normal stub library in ar format. This file supports the small
1207  data model and thus the SMALLDATA argument.
1209 SPECIAL 77: WarpOS inline files
1211   WarpOS Inline functions to define the WarpOS only Amiga OS calls without
1212   stubs.
1214 SPECIAL 78: stub link library for VBCC-MorphOS
1216  This is a normal stub library in ar format. This file supports the small
1217  data model and thus the SMALLDATA argument.
1219 SPECIAL 91: stubs for VBCC-PowerUP
1221  These are normal stub libraries as multiple files Assembler text. These
1222  files support the small data model and thus the SMALLDATA argument.
1224 SPECIAL 92: stubs for VBCC-WOS
1226  These are normal stub libraries as multiple files Assembler text. These
1227  files do not support the small data model.
1229 SPECIAL 93: stubs for VBCC-MorphOS
1231  These are normal stub libraries as multiple files Assembler text. These
1232  files support the small data model and thus the SMALLDATA argument.
1234 SPECIAL 122: MorphOSinline files
1236   MorphOS Inline functions to define the Amiga OS calls without stubs.
1238 @endnode
1240 @remark ********************************************************************
1241 @node Words "Words and phrases"
1242 clib-files, prototypes:
1243  For Amiga C functions the prototypes needed in C compilers are stored in
1244  a directory called clib. The files are named libname_protos.h. The CLIB
1245  option needs the name of such a file as a parameter. These files are needed
1246  by fd2pragma to create correct data with some options.
1248 data models:
1249  Most C compilers offer 2 different data models called large and small
1250  data (or far and near).
1251  Large data means all data is stored in a HUNK_DATA as a normal variable,
1252  which is accessed by its address. One access normally needs 4 bytes of
1253  space in program code and 4 bytes as relocation entry.
1254  The small data model needs less space. Here the data is stored as one
1255  structure. At the program start the compiler adds an instruction, which
1256  loads the structure address into register A4. In the following program the
1257  data is always accessed related to the register A4. One access now only
1258  needs 2 bytes in program code and no relocation entry (saving 6 bytes for
1259  each access).
1260  But this model has some problems:
1261  - Data size may not exceed 64KB (32KB for older compilers), as relative
1262    information uses only 2 bytes.
1263  - When program code is called from outside the program (e.g. hook code),
1264    it is not guaranteed that the A4 register still holds the base reference.
1265    So these functions need to be __saveds (SAS-C) or call functions like
1266    GetBaseReg() (Maxon-C++) to reload A4 register.
1268 inline system calls:
1269  GNU-C (GCC) uses a different system to call Amiga system functions. The
1270  needed files are stored in a directory called inline. Starting with
1271  version 2.45 this program is able to produce inline files as well. Before,
1272  you needed to use fd2inline program. I suggest using the proto file you
1273  can create with SPECIAL 35 instead calling inline files directly.
1275 .lib file, link library:
1276  A link library is a file containing functions which are added to the final
1277  executable at linking time. The other method are runtime or shared
1278  libraries (#?.library) which are called in runtime and thus take no space
1279  in the executable program.
1281 pragma:
1282  C allows non-standard (compiler private) definitions called pragmas. Most
1283  Amiga compilers use them to define system library calls. There exists 5
1284  different @{"#pragma" LINK PragmaDesign} statements, which are used by different compilers.
1285  I suggest using the proto file you can create with SPECIAL 35 instead
1286  of calling pragma files directly.
1288 proto file:
1289  C compilers like SAS have a special directory called proto with files in
1290  it calling the pragma and prototypes files. This is useful, because
1291  different compilers store their pragma files in different directories (or
1292  use other methods to define system calls), but all use one proto file. I
1293  did not use them for a long time and called the pragma files directly, but
1294  this makes it harder to switch to another compiler. So now I use proto
1295  always.
1297 stub, stub function:
1298  A stub function is a function, which converts between different inter-
1299  faces. For example C supplies function parameters on stack, but Amiga
1300  libraries get them in registers. A stub function for that gets the
1301  arguments on stack copies them into the registers and calls the Amiga
1302  function. Newer C compilers have #pragmas to do that internally, but some
1303  calling mechanisms are not supported by all compilers. MaxonC++ for
1304  example does not support the tagcall.
1306 tag-functions:
1307  C allows functions to get a variable number of parameters
1308  everytime they are called. These varargs functions have in their
1309  prototypes "..." at the end (e.g. printf). Amiga system libraries use this
1310  mechanism for supplying so-called tags. (See Amiga programmers
1311  documentation for that.)
1312  The name tag-functions is not the best, because there are also some
1313  functions getting variable args which are not tags (e.g. Printf), but it
1314  expresses well what is meant.
1315 @endnode
1317 @remark ********************************************************************
1318 @node Bugs "Known bugs and problems"
1319 - Pragma creation with cia_lib.fd fails with no ##basename error. This is
1320   desired by Amiga OS programmers to allow passing the library base as
1321   the first argument. In this case the C compiler function call does not
1322   work. You may add a ##basename statement to the FD file and get a working
1323   pragma file, but this file will not work together with
1324   clib/cia_protos.h file. Using option 14 or 15 instead generates a valid
1325   link file to use with the clib file. The created text file is of no use
1326   and can be deleted. When using created proto file (e.g. SPECIAL 35), you
1327   may remove the lines calling the pragma file.
1329 - mathieeedoubtrans_lib.fd and mathieeedoubbas_lib.fd both use 2 registers
1330   for one double value. fd2pragma creates only link libraries and
1331   definition files for them. Certain types do not support such behaviour
1332   and aren't created.
1334 - mathieesingtrans_lib.fd, mathieeesingbas_lib.fd, mathffp_lib.fd and
1335   mathtrans_lib.fd use float arguments in normal data registers. The PPC
1336   data types will produce invalid code for this library. As there is
1337   really no sense in using these libraries from PPC this is not really a
1338   problem.
1340 - The redefines of SPECIAL 13 and 14 are illegal when a function has the
1341   same name as a structure (e.g. DateStamp of dos.library). You have to
1342   remove the #define line for that function.
1344 - When clib file contains more than one function with the same name,
1345   fd2pragma always takes the first one, which may not always be the right
1346   one. For good include files this should never happen.
1348 - The return register is D0 for all functions. Also, flibcall always uses D0
1349   as the return register. All the pragma types normally support other return
1350   registers in their design, but I never saw any pragmas really using that
1351   and I think some compilers (e.g. MaxonC++) do not even accept such
1352   pragmas.
1354 Include file errors (in Includes release 45.1):
1355 - Using created graphics pragma brings an error on GetOutlinePen. This is
1356   not my fault, but an include error. Remove the line
1357     #define GetOutlinePen(rp) GetOPen(rp)
1358   in graphics/gfxmacros.h or turn it around to
1359     #define GetOPen(rp) GetOutlinePen(rp)
1360   as this works ok.
1362 Always use the newest Include files!
1364 * Automatically-created files may not always be fully correct (it may happen
1365 * rarely, but it sometimes happens). When you find such a condition (if not
1366 * mentioned above), please contact me, and when useful and possible I will
1367 * include a fix in the program.
1368 * There are so many exceptions in the official include files. How many are
1369 * in non-default system include files?
1370 @endnode
1372 @remark ********************************************************************
1373 @node LibDesign "How self-made libraries should be designed"
1374 As the main author of xpkmaster.library packer interface system and include
1375 creator for other libraries (and, not to forget, the author of fd2pragma) I
1376 gained some experience in how library functions should be designed.
1378 Expanding the possibilities of functions usually brings certain problems.
1379 Some ways you can reduce these problems:
1380 - Design your functions as tag-functions. For these it is really easy to
1381   implement new functionality. Believe me, it was a hard lesson for me
1382   to learn. :-)
1383 - It is always a good idea to add an "AllocStructures" function, which
1384   allocates all structures which are needed by your library system. Force
1385   the user to ALWAYS use this function. Future additions to the structures
1386   are then really easy. A "FreeStructures" function frees the stuff later.
1387   The "AllocStructures" may get an ULONG type and tags as argument. The
1388   tags allow to change initialisation behaviour.
1389 - Structures should use pointers instead of byte-arrays (for texts) or
1390   other directly included structures. This makes expansion possible, but is
1391   a little more complicated.
1392 - The function name should reflect your library name; for example, xpkmaster
1393   functions all start with "Xpk" and xfdmaster functions start with "xfd".
1394 - D0-D7, A0-A3 @{"registers" LINK Registers} are always available, but you should not use
1395   more than 8 of them in one function (except in very special cases).
1396   Usually, it is better to move lots of the arguments into an argument
1397   structure passed in one of the address registers. This also allows easy
1398   future additions as described above. Also, tag systems allow reduction of
1399   the argument count (and the user does not need to pass default values for
1400   unused arguments).
1402 A bit about how you should design names to make the work of utilities like
1403 fd2pragma possible:
1404 - Tag-functions should always receive the tagitem array (struct TagItem *)
1405   as last element.
1406 - The normal function should end in a big 'A', the tag-function has same
1407   name without 'A'. @{"Other methods" LINK TagFuncs} are described in that document, but this
1408   seems to be the best.
1409 - Pointers should be in A-registers, data should be in D-registers. The
1410   tagitem array pointer should always be in an address register.
1411 - Try to sort your registers in a order so that MOVEM.L can be used to get
1412   them from stack into registers: D0,...,D7,A0,...A3(,A4,A5)
1413   This affects autodocs, prototype files, and FD files. Assembler
1414   programmers have no problems with argument order, but it is useful for C.
1415 - Do not use A6 and A7 registers for arguments (which is nearly impossible).
1416 - Try not to use A4 and A5 register. Some C compilers store data in these
1417   registers. There may be problems with functions using these (e.g. inline
1418   creation has some restrictions).
1419 - The return value should always be in D0 (and only there). It is really
1420   complicated to access multi-return functions from C programs.
1422 How to design @{"FD files" LINK FDDesign}:
1423 - For tag-functions the last element in the FD file should be named 'tags'.
1424 - The argument names should not be the same for different arguments as
1425   these names are used for certain files by fd2pragma and other utilities.
1426 - If you do not follow the above-mentioned name convention for
1427   tag-functions, use the @{"tagcall comments" LINK TagFuncs} to define tag-function names.
1428 - For separating registers, you may use a "," or a "/". In standard system
1429   FD files, the "/" is used to separate these arguments that are in
1430   correct order to be used with MOVEM.L call (see above). It is not
1431   important which separator you use, as fd2pragma and nearly all other
1432   tools accept both, but I suggest either using "," only or the standard
1433   style.
1434 - The file should be named <library>_lib.fd, as fd2pragma interprets the
1435   file name and uses the first part (before _lib.fd) to generate the
1436   destination filename. If the file does not end in _lib.fd the defined
1437   basename is used.
1439 For plain assembler programmers: contact a experienced C programmer to get
1440 a fine interface (or learn C :-).
1441 @endnode
1443 @remark ********************************************************************
1444 @node PragmaDesign "Design description of varargs pragmas"
1445 Pragmas are a method to implement compiler-specific behaviour in C language
1446 programs. Refer to the ISO-C standard to find out what this means.
1448 Most Amiga compilers use the pragma system to implement calls to the Amiga
1449 shared libraries. Since there exist different compilers, there are different
1450 pragmas also, so I describe the design of these here:
1452 The used format descriptors:
1453   base          Name of the library base (e.g. IntuitionBase)
1454   function      Name of the function (e.g. OpenWindowTagList)
1455   hexoffest     Bias value of the library (e.g. 25E)
1456   offset        Bias value of the library (e.g. 0x25E or 606)
1457   retret        return register (e.g. d0)
1458   reglist       used registers (e.g. a0,a1), maybe empty
1459   magic         magic value, see below how this is build
1460   fmagic        magic value for floating point
1462 pragma libcall (SAS-C, DICE, supported by Storm):
1463  Normal call method for shared libraries.
1465  #pragma libcall base function hexoffset magic
1466  #pragma libcall IntuitionBase OpenWindowTagList 25E 9802
1468 pragma flibcall (SAS-C, supported by Storm):
1469  Call method, when arguments are passed in FPU registers (maybe mixed with
1470  CPU arguments).
1472  #pragma flibcall base function hexoffset fmagic
1473  #pragma flibcall mesamainBase glAlphaFunc 3C 10000002
1475 pragma syscall (SAS-C, supported by Storm):
1476  Special method to call exec.library function without a Sysbase, but
1477  directly with address 4.W.
1479  #pragma syscall function hexoffset magic
1480  #pragma syscall AllocMem C6 1002
1482 pragma tagcall (SAS-C, supported by Storm):
1483  This type allows to call shared library functions with variable argument
1484  lists (useful for tag-functions or e.g. Printf).
1486  #pragma tagcall base function hexoffset magic
1487  #pragma tagcall IntuitionBase OpenWindowTags 25E 9802
1489 pragma amicall (Aztec-C, Maxon++, Storm, [SAS-C supports this with errors]):
1490  Same as libcall for other compilers. fd2pragma can produce amicall pragmas
1491  containing FPU arguments (FP0..FP7), but Storm seems to be the only
1492  compiler accepting these.
1494  #pragma amicall(base, offset,[retreg=]function(reglist))
1495  #pragma amicall(IntuitionBase,0x25E,d0=OpenWindowTagList(a0,a1))
1497  Most compilers do not support the return register place (and fd2pragma
1498  also does not), so this really is:
1500  #pragma amicall(base, offset,function(reglist))
1501  #pragma amicall(IntuitionBase,0x25E,OpenWindowTagList(a0,a1))
1503 pragma tagcall (Storm):
1504  This type allows calling shared library functions with variable argument
1505  lists (useful for tag-functions or e.g. Printf).
1507  #pragma tagcall(base, offset,function(reglist))
1508  #pragma tagcall(IntuitionBase,0x25E,OpenWindowTags(a0,a1))
1510 The magic value:
1511 First think of every register as one hexadecimal number:
1512 d0..d7,a0..a7,fp0..fp7  -->     0..7,8..F,10..17
1514 Now the magic value is built in the following form:
1515   <reglist><retreg><numregs>
1516 The reglist is built in reverse order, so the first argument is last entry:
1518 OpenWindowTags(a0, a1): returns in d0, has 2 arguments
1519 arguments in reverse order:     98
1520 return register:                0
1521 number of arguments:            2
1522 result:                         9802
1524 A void function thus gets:      00
1526 The magic value for flibcall is like that, but with 2 spaces for EVERY
1527 entry:
1529 glAlphaFunc(d0,fp0): returns in d0, has 2 arguments
1530 arguments in reverse order:     1000
1531 return register:                00
1532 number of arguments:            02
1533 result:                         10000002
1534 @endnode
1536 @remark ********************************************************************
1537 @node SFDDesign "Design description of SFD files"
1538 The sfd fileformat holds nearly all the information needed to create developer
1539 files for library programming. It consists of command lines, comment lines and
1540 function descriptions.
1542 The commands always start with "==". Comment lines start with "*" sign.
1544 Following commands exist for file start:
1546 ==id        Describes the RCS-ID string for the SFD file. This is ALWAYS the
1547             first line!
1548             ==id $Id: fd2pragma.guide,v 1.2 2004/10/19 13:53:29 stoecker Exp $
1550 ==base      This defines the name of the library base. Normally starts with
1551             an "_" and ends in "Base". Required always.
1552             ==base _xadMasterBase
1554 ==basetype  This allows to define the type of the library base structure.
1555             It defaults to "struct Library *". It starts with "struct" and
1556             ends with pointer sign "*". Should be used, if not "struct
1557             Library".
1558             ==basetype struct xadMasterBase *
1560 ==libname   This allows to define the name of the library.
1561             By default this is created from the basename of the library by
1562             removing base extension, converting it to lower and adding
1563             ".library". Should be used, if this default does not work.
1564             ==libname xadmaster.library
1566 ==include   To get #include lines generated in clib file, you need to specify
1567             this keyword. You can use as much of them as necessary. This data
1568             normally starts with "<" and ends in ">" (normal C style.
1569             ==include <exec/types.h>
1571 ==bias      This defines the function offset the function starts. The values
1572             are always multiple of 6. For libraries it starts with 30, devices
1573             normally starts with 42. Required always.
1574             ==bias 30
1576 ==copyright This was introduced with OS3.9 includes and holds the Copyright
1577             text, which is then used in clib-file.
1578             ==copyright Copyright Â© 2001 Dirk Stöcker
1580 Now some commands which may be used in whole file:
1581             
1582 ==varargs   This introduces an varargs alias name. The following function
1583             definition keeps the bias of the previous one.
1584             There are mainly 2 types of varargs funtions:
1585             1) Using  one instance of the varargs parameter followed by ...
1586                struct Menu *CreateMenusA(struct NewMenu *newmenu,
1587                  struct TagItem *taglist) (A0,A1)
1588                ==varargs
1589                struct Menu *CreateMenus(struct NewMenu *newmenu,
1590                  Tag tag1, ...) (A0,A1)
1591             2) Using only ... 
1592                LONG VFPrintf(BPTR fh, UBYTE *format, LONG *argarray)
1593                  (d1,d2,d3)
1594                ==varargs
1595                LONG FPrintf(BPTR fh, UBYTE *format, ...) (d1,d2,d3)
1597             The first type is used for functions, which need at least one
1598             parameter, like all the functions using TagItem structure.
1600             The second type is needed for functions like Printf(), which
1601             can be called without any additional variable data.
1603             NOTE: The register list of varargs functions equals the list
1604             of corresponding function always! The arguments are equal as
1605             well except for the last argument.
1607 ==alias     To allow backwards compatibility it is sometimes necessary to
1608             define multiple names for one function. Using this command you
1609             can define a new additional name. This function has same bias
1610             as the previous one! You can specify an alias for varargs as
1611             well, if you added an varargs definition before. Always think
1612             of correct order
1614             LONG DoPkt(struct MsgPort *port, LONG action, LONG arg1,
1615               LONG arg2, LONG arg3, LONG arg4) (d1,d2,d3,d4,d5,d6)
1616             ==alias
1617             LONG DoPkt1(struct MsgPort *port, LONG action, LONG arg1)
1618               (d1,d2,d3)
1620             NOTE: The register and argument lists may be shorter than the
1621             lists for corresponding function, but the registers and arguments
1622             must be equal.
1624 ==reserve   This allows to skip function slots which are internal, obsolete
1625             or should not be visible for any other reason. The command is
1626             followed by the number of slots to reserve.
1627             ==reserve 2
1629 ==private   This allows to declare entries as private. Programs parsing SFD
1630             normally handle following lines as if declared with ==reserve.
1631             With another call they are handled as normal functions. This
1632             allows to create private use definition files and release files,
1633             which do not have internal function definitions.
1634             ==private
1636 ==public    This is the opposite to ==private and turns back normal
1637             behaviour. It is always a good idea to place this at the top of
1638             SFD file.
1639             ==public
1641 ==version   To describe the version of the module that subsequent functions
1642             appear in. This causes comments to be generated in output files.
1643             ==version 5
1645 ==end       Required always at end of file.
1646             ==end
1648 ==abi       Like Frank Wille did for FD file I extended this format to
1649             support PPC function descriptions also. To specify normal Amiga
1650             functions, the command
1651             ==abi M68k
1652             must be used. To specify PPC functions PPC, PPC0 or PPC2 must be
1653             used.
1654             Differences of PPC ABI types:
1655              PPC   gets librarybase in r3, other arguments follow
1656              PPC2  gets librarybase in r2
1657              PPC0  no librarybase passed
1659             The register part of function definition contains empty brackets
1660             for PPC ABI's!
1662 Function definitions:
1664 Anything that is not an sfd command or a comment must be part of a function
1665 definition. A function definition consists of three parts:
1666  - the return value/function part,
1667  - the parameter definition,
1668  - and the register definition:
1669 <return/function>(<parameters>)(<registers>)
1671 All three parts must be present. They may cross lines. A particular function
1672 definition is terminated by the second close paranthesis. A function
1673 definition must start on a fresh line.
1675 Examples:
1676 VOID OpenIntuition() ()
1678  - Even an empty parameter list needs an empty register list.
1679  - The C types void, unsigned, int, short, char, float and double are not
1680    recommended. Use types of <exec/types.h>.
1681  - Don't put a VOID in an empty parameter list.
1683 PLANEPTR AllocRaster(UWORD width, UWORD height) (D0,D1)
1685  - The parameter list must contain typed variables.
1686  - The register list is generally delimited by commas.
1688 DOUBLE IEEEDPDiv(DOUBLE dividend, DOUBLE divisor) (d0-d1,d2-d3)
1690  - DOUBLE registers must be delimited by a dash.
1691  - The register list may use either capital or lower case.
1693 struct Layer *CreateUpfrontLayer(struct Layer_Info *li,
1694 struct BitMap *bm, LONG x0, LONG y0, LONG x1, LONG y1,
1695 LONG flags, [struct BitMap *bm2]) (A0,A1,D0,D1,D2,D3,D4,A2)
1697  - The function definition can cross lines, but one argument should be
1698    unbroken (e.g. break after "," or ")" signs).
1699  - Optional parameters are indicated by being enclosed in braces.
1700    This currently has no effect, but may be supported in future programs.
1702 struct Window *OpenWindowTagList(struct NewWindow *newWindow,
1703 struct TagItem *tagList) (A0,A1)
1704 ==varargs
1705 struct Window *OpenWindowTags(struct NewWindow *newWindow,
1706 ULONG tag1Type, ...) (A0,A1)
1708  - The only time "..." may appear is for a varargs definition.
1709 @endnode
1711 @remark ********************************************************************
1712 @node XMLDesign "Design description of XML-IDL files"
1713 The XML-IDL fileformat holds all the information needed to create developer
1714 files for OS4 library programming. It is a standard XML file. The XML syntax
1715 descriptions are not subject of this text, so the necessary decriptions
1716 cover only a minimum.
1718 The general file layout can be seen in following example:
1720 <?xml version="1.0" encoding="iso-8859-1"?>
1721 <!DOCTYPE library SYSTEM "library.dtd">
1722 <library name="graphics" basename="GfxBase" openname="graphics.library"
1723 basetype="XXXBase">
1724   <include>exec/types.h</include>
1725   <interface name="main" version="1.0" struct="XXXIFace" prefix="_XXX_"
1726   asmprefix="IXXX" global="IXXX">
1727     <method name="Obtain" result="ULONG"/>
1728     <method name="Release" result="ULONG"/>
1729     <method name="Expunge" result="void" status="unimplemented"/>
1730     <method name="Clone" result="struct Interface *" status="unimplemented"/>
1731     <method name="MyFunc" result="ULONG">
1732       <arg name="font" type="struct Data *"/>
1733       <vararg name="tags" type="Tag"/>
1734     </method>
1735   </interface>
1736 </library>
1738 See @{"DTD file" LINK DTD} for the definition file.
1740 Description of Elements and their parameters and sub elements:
1742 "library":
1743   This is the general type of the file and always the outermost tag. It has
1744   different parameters to describe the library:
1745   "name":     The name of the library.
1746   "basename": The name of The library base variable.
1747   "openname": The name used when doing an OpenLibrary call. This is optional.
1748   "basetype": This is optional and specifies the base variable structure name.
1749               If not specified, the type "Library" is assumed.
1750   The library type supports 2 sub-types, which are "include" and "interface".
1751   Includes should be the first sub elements.
1753 "include":
1754   This type allows to specify include file names, which are required.
1756 "interface":
1757   Describes an interface of the library. Most libraries will have only one
1758   interface. Following parameters can be used:
1759   "name":      The name of the interface (e.g. main).
1760   "version":   The interface version. Will be 1.0.
1761   "flags":     Some flags:
1762     "private":    A private function.
1763     "protected":  A protected function.
1764     "not native": A non-native function.
1765   "struct":    Structure name.
1766   "prefix":    Function-Prefix for C code.
1767   "global":    Global name.
1768   "asmprefix": Function-Prefix for ASM code.
1769   The interface element allows sub types "description" and "method". The
1770   order of the method types is relevant.
1772 "description":
1773   A comment.
1775 "method":
1776   Describes one function interface. Following parameters can be used:
1777   "name":   The function name.
1778   "result": The result type (specified in C language).
1779   "status": Implementation status.
1780     "implemented":   The function really exists.
1781     "unimplemented": The function is planned.
1782   This element allows the sub-types "arg" and "vararg". The order of the
1783   elements is relevant.
1785 "arg":
1786   Describes one function argument.
1787   "name": The argument name. Should not conflict with any C or C++ language
1788           features as well as system definitions.
1789   "type": The argument type (specified in C language).
1791 "vararg":
1792   Describes one variable function argument. This is always the last after a
1793   line of none or more "arg" element. It is used to give the interface for
1794   functions with a variable number of elements.
1795   "name": The argument name. Should not conflict with any C or C++ language
1796           features as well as system definitions.
1797   "type": The argument type (specified in C language).
1798 @endnode
1800 @remark ********************************************************************
1801 @node DTD "Document Type definition fo XML-IDL"
1802 <?xml version="1.0" encoding="iso-8859-1"?>
1803 <!ELEMENT library (include*, interface+)>
1804 <!ATTLIST library
1805     basename    CDATA   #REQUIRED
1806     basetype    CDATA   "Library"
1807     name        CDATA   #REQUIRED
1808     openname    CDATA   "none"
1811 <!ELEMENT include (#PCDATA)>
1813 <!ELEMENT interface (description?, method+)>
1814 <!ATTLIST interface
1815     asmprefix   CDATA   "none"
1816     flags       (protected|private|none|not native) "none"
1817     global      CDATA   "none"
1818     name        CDATA   #REQUIRED
1819     prefix      CDATA   "_impl_"
1820     struct      CDATA   #REQUIRED
1821     version     CDATA   "1.0"
1824 <!ELEMENT description (#PCDATA)>
1826 <!ELEMENT method (arg*,description?,vararg?)>
1827 <!ATTLIST method
1828     name        CDATA   #REQUIRED
1829     result      CDATA   "void"
1830     status      CDATA   "implemented"
1833 <!ELEMENT arg EMPTY>
1834 <!ATTLIST arg
1835     name        CDATA   #REQUIRED
1836     type        CDATA   #REQUIRED
1839 <!ELEMENT vararg EMPTY>
1840 <!ATTLIST vararg
1841     name        CDATA   #REQUIRED
1842     type        CDATA   #REQUIRED
1843 >    
1844 @endnode
1846 @remark ********************************************************************
1847 @node FDDesign "Design description of FD files"
1848 FD files are a standard way to describe the interface for Amiga shared
1849 libraries. This format consists of 3 main line types:
1851 1) Commands - always start with ##
1852 2) Comments - always start with *
1853 2a) Plain comments - describe the contents for the user
1854 2b) Command comments - add some @{"functionality" LINK TagFuncs} (like *tagcall or *notagcall)
1855 3) Function descriptions - provide the main information
1858 Know commands are:
1859   ##abi         define Application Binary Interface
1860                 Allowed types: M68k, PPC, PPC0, PPC2
1861   ##base        Define the library base name, always starts with a "_"
1862   ##bias        Define a bias value, minimum value is 30, always a sum of 6
1863   ##end         Always in last line, finishes the file
1864   ##public      Declare the following functions as public
1865   ##private     Declare the following functions as private
1867 Normally a FD file is build this way:
1868 ##base _IntuitionBase
1869 ##bias 30
1870 ##public
1871 ....
1872 ##end
1874 Frank Wille extended this format to support PPC function descriptions
1875 also. He introduced the ##abi command. To specify normal Amiga functions,
1876 the command
1877 ##abi M68k
1878 must be used. To specify PPC functions PPC, PPC0 or PPC2 must be used.
1879 Differences of PPC ABI types:
1880  PPC   gets librarybase in r3, other arguments follow
1881  PPC2  gets librarybase in r2
1882  PPC0  no librarybase passed
1884 The register part of function definition contains empty brackets for PPC
1885 ABI's!
1888 Comments always start with a * and are normally ignored (except when
1889 they are "Command comments". Check the @{"description" LINK TagFuncs} of these to know what
1890 this means.
1893 A function description is build always like that:
1894 name(argnames)(registers)
1896 e.g. OpenWindowTagList(newWindow,tagList)(a0/a1)
1898 For void functions argnames and registers are both empty. Registers are
1899 separated by "," or "/". See @{"library design" LINK LibDesign} to find out the difference.
1900 fd2pragma accepts registers d0..d7,a0..a7,fp0..fp7.
1901 If the last argument is "tags", "taglist" or "args", fd2pragma creates
1902 additionally a varargs or tag-function. See @{"tag-function" LINK TagFuncs} section to learn
1903 about that.
1905 In the file you may add ##bias lines, when you want to skip some internal
1906 functions, or ##private lines, when you want some functions not to be used
1907 in normal case. The ##public keyword can be used to enable the normal
1908 system again.
1910 There is an incompatible FD file format addition created by
1911 Haage&Partner for their Storm compiler. It supports an additional
1912 command ##shadow.
1914  The format is:
1915  function description
1916  ##shadow
1917  tag-function description
1919  The first line is like above a normal function description. The ##shadow
1920  command sets back the bias to the same value as before and accepts the next
1921  line as a tag-function!
1923  example:
1924  OpenWindowTagList(newWindow,tagList)(a0/a1)
1925  ##shadow
1926  OpenWindowTags(newWindow,tagList)(a0/a1)
1928  Do not use that format!
1929 @endnode
1931 @remark ********************************************************************
1932 @node Registers "How 680x0 processor registers are used"
1933 On Amiga computers there exist some conventions about how registers of
1934 680x0 processors are used:
1936 1) Register A7 either holds "user stack pointer" USP or "supervisor stack
1937    "pointer" SSP. The second should not be important for the normal Amiga
1938    user. The stack is used to store variables, return addresses and, for
1939    some compiler languages (e.g. C), to store function arguments.
1940 2) Register A6 holds a pointer to the library base when you call a
1941    library function. In front of the library base is a jump table, which
1942    has an entry for every library function. The function itself is reached
1943    by jumping into the corresponding entry, which is specified by the base
1944    value in FD file (always negative).
1945 3) Registers D0, D1, A0, A1 are scratch registers. This means after
1946    calling a library function the contents of these registers is no longer
1947    valid! The contents of all the other registers is preserved.
1948 4) Register D0 normally contains the return value of a called function.
1949 5) Register A4 holds the data base pointer when you use C compiler in the
1950    small data model. You should not use this register for argument passing.
1951 6) Register A5 is used by C compilers to store a pointer to a field (part
1952    of the stack) for local variables. You should not use this register for
1953    argument passing.
1955 This means altogether you have 8 free data registers and 4 free address
1956 registers for passing arguments to functions. See how to @{"design libraries" LINK LibDesign},
1957 if you need more than 4 address registers or altogether more than 8
1958 arguments.
1959 @endnode
1961 @remark ********************************************************************
1962 @node Scripts "Scripts for automatic file creation"
1963 In the directory Scripts there are some scripts which allow you to generate
1964 necessary files automatic.
1965 NOTE: The scripts are not updated and maybe outdated!
1967 MakeInline - Generates inline files for standard system libraries, which
1968 can be used with GCC compiler:
1969  Options:
1970   FDPATH     This is the path where your system FD files are stored. The
1971              path must end in ':' or '/'.
1972   CLIBPATH   This is the path where your system prototype files are
1973              stored. The path must end in ':' or '/'.
1974   INLINEPATH This is the path where created files should be stored. It
1975              must already exist and should be empty.
1977 MakePragma - Generates pragma files for standard system libraries which
1978 can be used with all compilers:
1979  Options:
1980   FDPATH     This is the path where your system FD files are stored. The
1981              path must end in ':' or '/'.
1982   PRAGMAPATH This is the path where created files should be stored. It
1983              must already exists and should be empty.
1985 MakeStubLib - Generates a stub link library for all standard system
1986 libraries like amiga.lib (but with C++ name support). This library only
1987 holds stubs and none of the additional amiga.lib stuff. The result is
1988 a file called stubs.lib in the current directory. When you join this with
1989 small.lib distributed in NDK, you get a complete replacement for
1990 amiga.lib and you need not to modify clib files for C++.
1991 You need a Join command, which supports patterns matching like
1992 "Aminet/util/sys/JoinReplace.lha" to get this script to work.
1993  Options:
1994   FDPATH     This is the path where your system FD files are stored. The
1995              path must end in ':' or '/'.
1996   CLIBPATH   This is the path where your system prototype files are
1997              stored. The path must end in ':' or '/'.
1999 MakeProto - Generates proto files for standard system libraries which
2000 can be used with all compilers:
2001  Options:
2002   FDPATH     This is the path where your system FD files are stored. The
2003              path must end in ':' or '/'.
2004   PROTOPATH  This is the path where created files should be stored. It
2005              must already exist and should be empty.
2007 MakeUnit - Generates FPC Pascal compiler unit text files for standard
2008 system libraries:
2009  Options:
2010   FDPATH     This is the path where your system FD files are stored. The
2011              path must end in ':' or '/'.
2012   CLIBPATH   This is the path where your system prototype files are
2013              stored. The path must end in ':' or '/'.
2014   UNITPATH   This is the path where created files should be stored. It
2015              must already exist and should be empty.
2017 I added another Shell script called 'MakeStuff', which allows you to
2018 generate all the needed files for a single library. This is mostly useful
2019 for library programmers, who need to release include files for these
2020 libraries.
2022 It gets 3 arguments:
2023  FDFILE   The FD file, which normally is named 'xxx_lib.fd'.
2024  CLIBFILE The prototypes file, which normally is called 'xxx_protos.h'.
2025  DEST     The destination directory, which must already exist and should
2026           be empty.
2028 In the destination path all needed directories are created, the FD and
2029 prototypes file are copied and inline, lvo, pragma and proto files are
2030 created. You only need to copy your library include files and the include
2031 stuff is complete.
2033 MakePPCStuff  - has the same arguments, creates needed directories, but does
2034 not copy the clib and FD file. It produces the files needed to support PPC
2035 PowerUP system.
2037 MakeVBCC - has the same arguments as MakeStuff. It produces link libraries
2038 for VBCC (68k, WOS, PPC).
2039 @endnode
2041 @remark ********************************************************************
2042 @node usefd2pragma "Useful script interface"
2043 usefd2pragma is a shell script file which asks you some questions and
2044 creates the related files afterwards. The command called is printed to
2045 the window which appears so you can use it afterwards for batch processing.
2047 This script allows use of nearly all possible options of fd2pragma.
2048 NOTE: The script is not updated and maybe outdated!
2049 @endnode
2051 @remark ********************************************************************
2052 @node Last "Greetings, last words, and author's address"
2053 Everyone using this program should tell me in a brief message which options
2054 he uses and if there are some problems. It took me many of hours to make
2055 fd2pragma as powerful as it is now. So please tell me if you are using it!
2057 This program is in the public domain. Use it as you want, but WITHOUT ANY
2058 WARRANTY!
2060 The program is compiled using SAS-C 6.58 and has additionally been tested
2061 with MaxonC++, GCC, and StormC. Any other ISO-C compiler should be
2062 sufficient as well.
2064 Because fd2pragma is very complex, it may be that there are some errors
2065 (even serious ones) in the code. So if you find one, please tell me!
2066 I will also be glad if someone tells me what can be improved in the
2067 program! I will add new options but there will never be a GUI because this
2068 utility is for experts, and they do not need a GUI to create the files
2069 needed :-) Besides, a GUI would really make a lot of work, increase the
2070 file size greatly and reduce portability a lot.
2072 Please contact me at:
2074 *********************************************************************
2075 * snail-mail:                  * e-mail:                            *
2076 *   Dirk Stoecker              *   doc@dstoecker.de                 *
2077 *   Geschwister-Scholl-Str. 10 * world wide web:                    *
2078 *   01877 Bischofswerda        *   http://www.dstoecker.de/         *
2079 *   GERMANY                    * pgp key:                           *
2080 * phone:                       *   get from WWW pages or keyservers *
2081 *   GERMANY +49 (0)3594/706666 *                                    *
2082 *********************************************************************
2083 @endnode
2085 @remark ********************************************************************
2086 @node Index
2087 The entries given here link to the correct node entry, but not always to
2088 correct line. This is because I often change the texts and the line
2089 numbers would need to be updated every time.
2091         @{"##abi" LINK FDDesign}
2092         @{"##base" LINK FDDesign}
2093         @{"##bias" LINK FDDesign}
2094         @{"##end" LINK FDDesign}
2095         @{"##private" LINK FDDesign}
2096         @{"##public" LINK FDDesign}
2097         @{"#pragma amicall" LINK PragmaDesign}
2098         @{"#pragma flibcall" LINK PragmaDesign}
2099         @{"#pragma libcall" LINK PragmaDesign}
2100         @{"#pragma syscall" LINK PragmaDesign}
2101         @{"#pragma tagcall" LINK PragmaDesign}
2102         @{".lib files" LINK Words}
2103         @{"<xxx>_<xxx>_H define" LINK IncludeDefs}
2104         @{"<xxx>_BASE_NAME define" LINK IncludeDefs}
2105         @{"__CONSTLIBBASEDECL__" LINK Proto}
2106         @{"_INCLUDE_<xxx>_CSTUB_H define" LINK IncludeDefs}
2107         @{"_INCLUDE_PRAGMA_<xxx>_LIB_H define" LINK IncludeDefs}
2108         @{"_INCLUDE_PROTO_<xxx>_LOC_H define" LINK IncludeDefs}
2109         @{"_INLINE_<xxx>_H define" LINK IncludeDefs}
2110         @{"_PPCINLINE_<xxx>_H define" LINK IncludeDefs}
2111         @{"_PPCPRAGMA_<xxx>_H define" LINK IncludeDefs}
2112         @{"_PROTO_<xxx>_H define" LINK IncludeDefs}
2113         @{"_VBCCINLINE_<xxx>_H define" LINK IncludeDefs}
2114         @{"__NOLIBBASE__ define" LINK Proto}
2115  A      @{"ABI option" LINK OptionAdvanced}
2116         @{"About" LINK About}
2117         @{"Author" LINk Last}
2118         @{"AUTOHEADER option" LINK OptionAdvanced}
2119  B      @{"BASENAME option" LINK OptionAdvanced}
2120         @{"BMAP file" LINK OptionAll}
2121         @{"bugs and problems" LINK Bugs}
2122  C      @{"clib files" LINK Words}
2123         @{"CLIB option" LINK OptionAdvanced}
2124         @{"CLIB_<xxx>_PROTOS_H define" LINK IncludeDefs}
2125         @{"COMMENT option" LINK OptionAdvanced}
2126         @{"COPYRIGHT option" LINK OptionAdvanced}
2127         @{"Copyright" LINK Last}
2128  D      @{"data models" LINK Words}
2129  E      @{"Examples" LINK Examples}
2130         @{"EXTERNC option" LINK OptionAdvanced}
2131  F      @{"far data" LINK Words}
2132         @{"FD file design" LINK FDDesign}
2133         @{"fd2pragma.types" LINK TypesFile}
2134         @{"FPU comments" LINK FPUusage}
2135         @{"FPUONLY option" LINK OptionAdvanced}
2136  H      @{"HEADER option" LINK OptionAdvanced}
2137         @{"Headerscan" LINK HeaderScan}
2138         @{"HUNKNAME option" LINK OptionAdvanced}
2139  I      @{"Include directory system" LINK Includes}
2140         @{"Include file definitions" LINK IncludeDefs}
2141         @{"INFILE option" LINK OptionAll}
2142         @{"inline files" LINK Words}
2143  L      @{"large data" LINK Words}
2144         @{"library design" LINK LibDesign}
2145         @{"LIBNAME option" LINK OptionAdvanced}
2146         @{"LIBTYPE option" LINK OptionAdvanced}
2147         @{"link libraries" LINK Words}
2148         @{"Link library comments" LINK LinkLib}
2149         @{"Local library base files" LINK Local}
2150  M      @{"MakeInline" LINK Scripts}
2151         @{"MakePPCStuff" LINK Scripts}
2152         @{"MakePragma" LINK Scripts}
2153         @{"MakeProto" LINK Scripts}
2154         @{"MakeStubLib" LINK Scripts}
2155         @{"MakeStuff" LINK Scripts}
2156         @{"MakeUnit" LINK Scripts}
2157         @{"MODE option" LINK OptionAdvanced}
2158  N      @{"near data" LINK Words}
2159         @{"NEWSYNTAX option" LINK OptionAdvanced}
2160         @{"NOFPU option" LINK OptionAdvanced}
2161         @{"NOPPC option" LINK OptionAdvanced}
2162         @{"NOPPCREGNAME option" LINK OptionAdvanced}
2163         @{"NOSYMBOL option" LINK OptionAdvanced}
2164         @{"NO_INLINE_STDARG define" LINK IncludeDefs}
2165         @{"NO_PPCINLINE_STDARG define" LINK IncludeDefs}
2166  O      @{"ONLYCNAMES option" LINK OptionAdvanced}
2167         @{"OPT040 option" LINK OptionAdvanced}
2168         @{"Options" LINK Options}
2169  P      @{"Pascal unit" LINK OptionAll}
2170         @{"PowerUP - PPC" LINK PowerUP}
2171         @{"PPCONLY option" LINK OptionAdvanced}
2172         @{"PPCPROTO_<xxx>_H define" LINK IncludeDefs}
2173         @{"pragma" LINK Words}
2174         @{"pragma file design" LINK PragmaDesign}
2175         @{"PREFIX option" LINK OptionAdvanced}
2176         @{"PREMACRO option" LINK OptionAdvanced}
2177         @{"PRIORITY option" LINK OptionAdvanced}
2178         @{"PRIVATE option" LINK OptionAdvanced}
2179         @{"proto file" LINK Words}
2180         @{"Proto files" LINK Proto}
2181         @{"prototypes" LINK Words}
2182  R      @{"registers" LINK Registers}
2183  S      @{"Scripts" LINK Scripts}
2184         @{"SECTION option" LINK OptionAdvanced}
2185         @{"SFD file design" LINK SFDDesign}
2186         @{"small data" LINK Words}
2187         @{"SMALLDATA option" LINK OptionAdvanced}
2188         @{"SORTED option" LINK OptionAdvanced}
2189         @{"SPECIAL option" LINK OptionAll}
2190         @{"stub function" LINK Words}
2191         @{"SUBPREFIX option" LINK OptionAdvanced}
2192  T      @{"tag function" LINK Words}
2193         @{"tag-functions definition" LINK TagFuncs}
2194  U      @{"usefd2pragma" LINK usefd2pragma}
2195         @{"USESYSCALL option" LINK OptionAdvanced}
2196  V      @{"VBCC compiler" LINK VBCC}
2197         @{"VOIDBASE option" LINK OptionAdvanced}
2198  W      @{"WarpOS - WOS" LINK VBCC}
2199 @endnode