]> git.sur5r.net Git - cc65/blob - doc/cl65.sgml
Added mouse_ioctl to complete mouse.h
[cc65] / doc / cl65.sgml
1 <!doctype linuxdoc system>
2
3 <article>
4 <title>cl65 Users Guide
5 <author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
6 <date>01.08.2000, 27.11.2000, 02.10.2001
7
8 <abstract>
9 cl65 is the compile &amp; link utility for cc65, the 6502 C compiler. It was
10 designed as a smart frontend for the C compiler (cc65), the assembler (ca65),
11 the object file converter (co65), and the linker (ld65).
12 </abstract>
13
14 <!-- Table of contents -->
15 <toc>
16
17 <!-- Begin the document -->
18
19 <sect>Overview<p>
20
21 cl65 is a frontend for cc65, ca65, co65 and ld65. While you may not use the
22 full power of the tools when calling them through cl65, most features are
23 available, and the use of cl65 is much simpler.
24
25
26 <sect>Basic Usage<p>
27
28 The cl65 compile and link utility may be used to convert, compile, assemble
29 and link files. While the separate tools do just one step, cl65 knows how to
30 build object files from C files (by calling the compiler, then the assembler)
31 and other things.
32
33 <tscreen><verb>
34 ---------------------------------------------------------------------------
35 Usage: cl65 [options] file [...]
36 Short options:
37   -c                    Compile and assemble but don't link
38   -d                    Debug mode
39   -g                    Add debug info
40   -h                    Help (this text)
41   -l                    Create an assembler listing
42   -m name               Create a map file
43   -o name               Name the output file
44   -r                    Enable register variables
45   -t sys                Set the target system
46   -v                    Verbose mode
47   -vm                   Verbose map file
48   -C name               Use linker config file
49   -Cl                   Make local variables static
50   -D sym[=defn]         Define a preprocessor symbol
51   -I dir                Set a compiler include directory path
52   -L path               Specify a library search path
53   -Ln name              Create a VICE label file
54   -O                    Optimize code
55   -Oi                   Optimize code, inline functions
56   -Or                   Optimize code, honour the register keyword
57   -Os                   Optimize code, inline known C funtions
58   -S                    Compile but don't assemble and link
59   -T                    Include source as comment
60   -V                    Print the version number
61   -W                    Suppress warnings
62
63 Long options:
64   --add-source          Include source as comment
65   --asm-include-dir dir Set an assembler include directory
66   --bss-label name      Define and export a BSS segment label
67   --bss-name seg        Set the name of the BSS segment
68   --cfg-path path       Specify a config file search path
69   --check-stack         Generate stack overflow checks
70   --code-label name     Define and export a CODE segment label
71   --code-name seg       Set the name of the CODE segment
72   --codesize x          Accept larger code by factor x
73   --cpu type            Set cpu type
74   --create-dep          Create a make dependency file
75   --data-label name     Define and export a DATA segment label
76   --data-name seg       Set the name of the DATA segment
77   --debug               Debug mode
78   --debug-info          Add debug info
79   --feature name        Set an emulation feature
80   --help                Help (this text)
81   --include-dir dir     Set a compiler include directory path
82   --lib file            Link this library
83   --lib-path path       Specify a library search path
84   --listing             Create an assembler listing
85   --mapfile name        Create a map file
86   --module              Link as a module
87   --module-id id        Specify a module id for the linker
88   --o65-model model     Override the o65 model
89   --obj file            Link this object file
90   --obj-path path       Specify an object file search path
91   --register-space b    Set space available for register variables
92   --register-vars       Enable register variables
93   --rodata-name seg     Set the name of the RODATA segment
94   --signed-chars        Default characters are signed
95   --standard std        Language standard (c89, c99, cc65)
96   --start-addr addr     Set the default start address
97   --static-locals       Make local variables static
98   --target sys          Set the target system
99   --version             Print the version number
100   --verbose             Verbose mode
101   --zeropage-label name Define and export a ZEROPAGE segment label
102   --zeropage-name seg   Set the name of the ZEROPAGE segment
103 ---------------------------------------------------------------------------
104 </verb></tscreen>
105
106 Most of the options have the same meaning than the corresponding compiler,
107 assembler or linker option. See the documentation for these tools for an
108 explanation. If an option is available for more than one of the tools, it
109 is set for all tools, where it is available. One example for this is <tt/-v/:
110 The compiler, the assembler and the linker are all called with the <tt/-v/
111 switch.
112
113 There are a few remaining options that control the behaviour of cl65:
114
115 <descrip>
116
117   <tag><tt>-S</tt></tag>
118
119   This option forces cl65 to stop after the assembly step. This means that
120   C files are translated into assembler files, but nothing more is done.
121   Assembler files, object files and libraries given on the command line
122   are ignored.
123
124
125   <tag><tt>-c</tt></tag>
126
127   This options forces cl65 to stop after the assembly step. This means
128   that C and assembler files given on the command line are translated into
129   object files, but there is no link step, and object files and libraries
130   given on the command line are ignored.
131
132
133   <tag><tt>-o name</tt></tag>
134
135   The -o option is used for the target name in the final step. This causes
136   problems, if the linker will not be called, and there are several input
137   files on the command line. In this case, the name given with -o will be
138   used for all of them, which makes the option pretty useless. You
139   shouldn't use -o when more than one output file is created.
140
141
142   <tag><tt>-t sys, --target sys</tt></tag>
143
144   The default for this option is different from the compiler and linker in the
145   case that the option is missing: While the other tools (compiler, assembler
146   and linker) will use the "none" system settings by default, cl65 will use
147   the C64 as a target system by default. This was chosen since most people
148   seem to use cc65 to develop for the C64.
149
150 </descrip>
151
152
153
154 <sect>More usage<p>
155
156 Since cl65 was created to simplify the use of the cc65 development
157 package, it tries to be smart about several things.
158
159 <itemize>
160
161 <item>  If you don't give a target system on the command line, cl65
162         defaults to the C64.
163
164 <item>  When linking, cl65 will supply the names of the startup file and
165         library for the target system to the linker, so you don't have to do
166         that.
167
168 <item>  If the final step is the linker, and the name of the output file was
169         not explicitly given, cl65 will use the name of the first input file
170         without the extension, provided that the name of this file has an
171         extension. So you don't need to name the executable name in most
172         cases, just give the name of your "main" file as first input file.
173 </itemize>
174
175 The type of an input file is derived from its extension:
176
177 <itemize>
178 <item>C files: <tt/.c/
179 <item>Assembler files: <tt/.s/, <tt/.asm/, <tt/.a65/
180 <item>Object files: <tt/.o/ <tt/.obj/
181 <item>Libraries: <tt/.a/, <tt/.lib/
182 <item>GEOS resource files: <tt/.grc/
183 <item>o65 files: <tt/.o65/, <tt/.emd/, <tt/.joy/, <tt/.tgi/
184 </itemize>
185
186 Please note that the program cannot handle input files with unknown file
187 extensions.
188
189
190 <sect>Examples<p>
191
192 The morse trainer software, which consists of one C file (morse.c) and one
193 assembler file (irq.s) will need the following separate steps to compile
194 into an executable named morse:
195
196 <tscreen><verb>
197         cc65 -g -Oi -t c64 morse.c
198         ca65 -g morse.s
199         ca65 -g irq.s
200         ld65 -t c64 -o morse c64.o morse.o irq.o c64.lib
201 </verb></tscreen>
202
203 When using cl65, this is simplified to
204
205 <tscreen><verb>
206         cl65 -g -Oi morse.c irq.s
207 </verb></tscreen>
208
209 As a general rule, you may use cl65 instead of cc65 at most times,
210 especially in makefiles to build object files directly from C files. Use
211
212 <tscreen><verb>
213         .c.o:
214                 cl65 -g -Oi $<
215 </verb></tscreen>
216
217 to do this.
218
219
220
221 <sect>Bugs/Feedback<p>
222
223 If you have problems using the utility, if you find any bugs, or if you're
224 doing something interesting with it, I would be glad to hear from you. Feel
225 free to contact me by email (<htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">).
226
227
228
229 <sect>Copyright<p>
230
231 cl65 (and all cc65 binutils) are (C) Copyright 1998-2004 Ullrich von
232 Bassewitz. For usage of the binaries and/or sources the following
233 conditions do apply:
234
235 This software is provided 'as-is', without any expressed or implied
236 warranty.  In no event will the authors be held liable for any damages
237 arising from the use of this software.
238
239 Permission is granted to anyone to use this software for any purpose,
240 including commercial applications, and to alter it and redistribute it
241 freely, subject to the following restrictions:
242
243 <enum>
244 <item>  The origin of this software must not be misrepresented; you must not
245         claim that you wrote the original software. If you use this software
246         in a product, an acknowledgment in the product documentation would be
247         appreciated but is not required.
248 <item>  Altered source versions must be plainly marked as such, and must not
249         be misrepresented as being the original software.
250 <item>  This notice may not be removed or altered from any source
251         distribution.
252 </enum>
253
254
255
256 </article>
257