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