]> git.sur5r.net Git - cc65/blob - doc/cl65.sgml
Moved the data that keeps a copy of the used zero page locations in its own
[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   -mm model             Set the memory model
44   -o name               Name the output file
45   -r                    Enable register variables
46   -t sys                Set the target system
47   -v                    Verbose mode
48   -vm                   Verbose map file
49   -C name               Use linker config file
50   -Cl                   Make local variables static
51   -D sym[=defn]         Define a preprocessor symbol
52   -I dir                Set a compiler include directory path
53   -L path               Specify a library search path
54   -Ln name              Create a VICE label file
55   -O                    Optimize code
56   -Oi                   Optimize code, inline functions
57   -Or                   Optimize code, honour the register keyword
58   -Os                   Optimize code, inline known C funtions
59   -S                    Compile but don't assemble and link
60   -T                    Include source as comment
61   -V                    Print the version number
62   -W                    Suppress warnings
63   -Wa options           Pass options to the assembler
64   -Wl options           Pass options to the linker
65
66 Long options:
67   --add-source          Include source as comment
68   --asm-args options    Pass options to the assembler
69   --asm-define sym[=v]  Define an assembler symbol
70   --asm-include-dir dir Set an assembler include directory
71   --bss-label name      Define and export a BSS segment label
72   --bss-name seg        Set the name of the BSS segment
73   --cfg-path path       Specify a config file search path
74   --check-stack         Generate stack overflow checks
75   --code-label name     Define and export a CODE segment label
76   --code-name seg       Set the name of the CODE segment
77   --codesize x          Accept larger code by factor x
78   --config name         Use linker config file
79   --cpu type            Set cpu type
80   --create-dep          Create a make dependency file
81   --data-label name     Define and export a DATA segment label
82   --data-name seg       Set the name of the DATA segment
83   --debug               Debug mode
84   --debug-info          Add debug info
85   --feature name        Set an emulation feature
86   --forget-inc-paths    Forget include search paths (compiler)
87   --help                Help (this text)
88   --include-dir dir     Set a compiler include directory path
89   --ld-args options     Pass options to the linker
90   --lib file            Link this library
91   --lib-path path       Specify a library search path
92   --list-targets        List all available targets
93   --listing             Create an assembler listing
94   --list-bytes n        Number of bytes per assembler listing line
95   --mapfile name        Create a map file
96   --memory-model model  Set the memory model
97   --module              Link as a module
98   --module-id id        Specify a module id for the linker
99   --o65-model model     Override the o65 model
100   --obj file            Link this object file
101   --obj-path path       Specify an object file search path
102   --register-space b    Set space available for register variables
103   --register-vars       Enable register variables
104   --rodata-name seg     Set the name of the RODATA segment
105   --signed-chars        Default characters are signed
106   --standard std        Language standard (c89, c99, cc65)
107   --start-addr addr     Set the default start address
108   --static-locals       Make local variables static
109   --target sys          Set the target system
110   --version             Print the version number
111   --verbose             Verbose mode
112   --zeropage-label name Define and export a ZEROPAGE segment label
113   --zeropage-name seg   Set the name of the ZEROPAGE segment
114 ---------------------------------------------------------------------------
115 </verb></tscreen>
116
117 Most of the options have the same meaning than the corresponding compiler,
118 assembler or linker option. See the documentation for these tools for an
119 explanation. If an option is available for more than one of the tools, it
120 is set for all tools, where it is available. One example for this is <tt/-v/:
121 The compiler, the assembler and the linker are all called with the <tt/-v/
122 switch.
123
124 There are a few remaining options that control the behaviour of cl65:
125
126 <descrip>
127
128   <tag><tt>-S</tt></tag>
129
130   This option forces cl65 to stop after the assembly step. This means that
131   C files are translated into assembler files, but nothing more is done.
132   Assembler files, object files and libraries given on the command line
133   are ignored.
134
135
136   <tag><tt>-c</tt></tag>
137
138   This options forces cl65 to stop after the assembly step. This means
139   that C and assembler files given on the command line are translated into
140   object files, but there is no link step, and object files and libraries
141   given on the command line are ignored.
142
143
144   <tag><tt>-o name</tt></tag>
145
146   The -o option is used for the target name in the final step. This causes
147   problems, if the linker will not be called, and there are several input
148   files on the command line. In this case, the name given with -o will be
149   used for all of them, which makes the option pretty useless. You
150   shouldn't use -o when more than one output file is created.
151
152
153   <tag><tt>-t sys, --target sys</tt></tag>
154
155   The default for this option is different from the compiler and linker in the
156   case that the option is missing: While the other tools (compiler, assembler
157   and linker) will use the "none" system settings by default, cl65 will use
158   the C64 as a target system by default. This was chosen since most people
159   seem to use cc65 to develop for the C64.
160
161   <tag><tt>-Wa options, --asm-args options</tt></tag>
162
163   Pass options directly to the assembler. This may be used to pass options
164   that aren't directly supported by cl65. Several options may be separated by
165   commas, the commas are replaced by spaces when passing them to the
166   assembler. Beware: Passing arguments directly to the assembler may interfere
167   with some of the defaults, because cl65 doesn't parse the options passed. So
168   if cl65 supports an option by itself, do not pass this option to the
169   assembler by means of the <tt/-Wa/ switch.
170
171   <tag><tt>-Wl options, --ld-args options</tt></tag>
172
173   Pass options directly to the linker. This may be used to pass options that
174   aren't directly supported by cl65. Several options may be separated by
175   commas, the commas are replaced by spaces when passing them to the linker.
176   Beware: Passing arguments directly to the linker may interfere with some of
177   the defaults, because cl65 doesn't parse the options passed. So if cl65
178   supports an option by itself, do not pass this option to the linker by means
179   of the <tt/-Wl/ switch.
180
181 </descrip>
182
183
184
185 <sect>More usage<p>
186
187 Since cl65 was created to simplify the use of the cc65 development
188 package, it tries to be smart about several things.
189
190 <itemize>
191
192 <item>  If you don't give a target system on the command line, cl65
193         defaults to the C64.
194
195 <item>  When linking, cl65 will supply the names of the startup file and
196         library for the target system to the linker, so you don't have to do
197         that.
198
199 <item>  If the final step is the linker, and the name of the output file was
200         not explicitly given, cl65 will use the name of the first input file
201         without the extension, provided that the name of this file has an
202         extension. So you don't need to name the executable name in most
203         cases, just give the name of your "main" file as first input file.
204 </itemize>
205
206 The type of an input file is derived from its extension:
207
208 <itemize>
209 <item>C files: <tt/.c/
210 <item>Assembler files: <tt/.s/, <tt/.asm/, <tt/.a65/
211 <item>Object files: <tt/.o/ <tt/.obj/
212 <item>Libraries: <tt/.a/, <tt/.lib/
213 <item>GEOS resource files: <tt/.grc/
214 <item>o65 files: <tt/.o65/, <tt/.emd/, <tt/.joy/, <tt/.tgi/
215 </itemize>
216
217 Please note that the program cannot handle input files with unknown file
218 extensions.
219
220
221 <sect>Examples<p>
222
223 The morse trainer software, which consists of one C file (morse.c) and one
224 assembler file (irq.s) will need the following separate steps to compile
225 into an executable named morse:
226
227 <tscreen><verb>
228         cc65 -g -Oi -t c64 morse.c
229         ca65 -g morse.s
230         ca65 -g irq.s
231         ld65 -t c64 -o morse c64.o morse.o irq.o c64.lib
232 </verb></tscreen>
233
234 When using cl65, this is simplified to
235
236 <tscreen><verb>
237         cl65 -g -Oi morse.c irq.s
238 </verb></tscreen>
239
240 As a general rule, you may use cl65 instead of cc65 at most times,
241 especially in makefiles to build object files directly from C files. Use
242
243 <tscreen><verb>
244         .c.o:
245                 cl65 -g -Oi $<
246 </verb></tscreen>
247
248 to do this.
249
250
251
252 <sect>Bugs/Feedback<p>
253
254 If you have problems using the utility, if you find any bugs, or if you're
255 doing something interesting with it, I would be glad to hear from you. Feel
256 free to contact me by email (<htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">).
257
258
259
260 <sect>Copyright<p>
261
262 cl65 (and all cc65 binutils) are (C) Copyright 1998-2004 Ullrich von
263 Bassewitz. For usage of the binaries and/or sources the following
264 conditions do apply:
265
266 This software is provided 'as-is', without any expressed or implied
267 warranty.  In no event will the authors be held liable for any damages
268 arising from the use of this software.
269
270 Permission is granted to anyone to use this software for any purpose,
271 including commercial applications, and to alter it and redistribute it
272 freely, subject to the following restrictions:
273
274 <enum>
275 <item>  The origin of this software must not be misrepresented; you must not
276         claim that you wrote the original software. If you use this software
277         in a product, an acknowledgment in the product documentation would be
278         appreciated but is not required.
279 <item>  Altered source versions must be plainly marked as such, and must not
280         be misrepresented as being the original software.
281 <item>  This notice may not be removed or altered from any source
282         distribution.
283 </enum>
284
285
286
287 </article>
288