]> git.sur5r.net Git - cc65/blob - doc/cl65.sgml
Added explanation for --codesize
[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
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 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 and ld65. While you may not use the full
22 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 compile, assemble and
29 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
31 assembler) and other things.
32
33 <tscreen><verb>
34 ---------------------------------------------------------------------------
35 Usage: cl65 [options] file
36 Short options:
37   -A                    Strict ANSI mode
38   -C name               Use linker config file
39   -Cl                   Make local variables static
40   -D sym[=defn]         Define a preprocessor symbol
41   -I dir                Set a compiler include directory path
42   -Ln name              Create a VICE label file
43   -O                    Optimize code
44   -Oi                   Optimize code, inline functions
45   -Or                   Optimize code, honour the register keyword
46   -Os                   Optimize code, inline known C funtions
47   -S                    Compile but don't assemble and link
48   -V                    Print the version number
49   -W                    Suppress warnings
50   -c                    Compiler and assemble but don't link
51   -d                    Debug mode
52   -g                    Add debug info
53   -h                    Help (this text)
54   -m name               Create a map file
55   -o name               Name the output file
56   -t sys                Set the target system
57   -v                    Verbose mode
58   -vm                   Verbose map file
59
60 Long options:
61   --ansi                Strict ANSI mode
62   --asm-include-dir dir Set an assembler include directory
63   --cpu type            Set cpu type
64   --debug               Debug mode
65   --debug-info          Add debug info
66   --feature name        Set an emulation feature
67   --help                Help (this text)
68   --include-dir dir     Set a compiler include directory path
69   --mapfile name        Create a map file
70   --target sys          Set the target system
71   --version             Print the version number
72   --verbose             Verbose mode
73 ---------------------------------------------------------------------------
74 </verb></tscreen>
75
76 Most of the options have the same meaning than the corresponding compiler,
77 assembler or linker option. See the documentation for these tools for an
78 explanation. If an option is available for more than one of the tools, it
79 is set for all tools, where it is available. One example for this is <tt/-v/:
80 The compiler, the assembler and the linker are all called with the <tt/-v/
81 switch.
82
83 There are a few remaining options that control the behaviour of cl65:
84
85 <descrip>
86
87   <tag><tt>-S</tt></tag>
88
89   This option forces cl65 to stop after the assembly step. This means that
90   C files are translated into assembler files, but nothing more is done.
91   Assembler files, object files and libraries given on the command line
92   are ignored.
93
94
95   <tag><tt>-c</tt></tag>
96
97   This options forces cl65 to stop after the assembly step. This means
98   that C and assembler files given on the command line are translated into
99   object files, but there is no link step, and object files and libraries
100   given on the command line are ignored.
101
102
103   <tag><tt>-o name</tt></tag>
104
105   The -o option is used for the target name in the final step. This causes
106   problems, if the linker will not be called, and there are several input
107   files on the command line. In this case, the name given with -o will be
108   used for all of them, which makes the option pretty useless. You
109   shouldn't use -o when more than one output file is created.
110
111
112   <tag><tt>-t sys, --target sys</tt></tag>
113
114   The default for this option is different from the compiler and linker in the
115   case that the option is missing: While the other tools (compiler, assembler
116   and linker) will use the "none" system settings by default, cl65 will use
117   the C64 as a target system by default. This was choosen since most people
118   seem to use cc65 to develop for the C64.
119
120 </descrip>
121
122
123
124 <sect>More usage<p>
125
126 Since cl65 was created to simplify the use of the cc65 development
127 package, it tries to be smart about several things.
128
129 <itemize>
130
131 <item>  If you don't give a target system on the command line, cl65
132         defaults to the C64.
133
134 <item>  When linking, cl65 will supply the names of the startup file and
135         library for the target system to the linker, so you don't have to do
136         that.
137
138 <item>  If the final step is the linker, and the name of the output file was
139         not explicitly given, cl65 will use the name of the first input file
140         without the extension, provided that the name of this file has an
141         extension. So you don't need to name the executable name in most
142         cases, just give the name of your "main" file as first input file.
143 </itemize>
144
145
146 <sect>Examples<p>
147
148 The morse trainer software, which consists of one C file (morse.c) and one
149 assembler file (irq.s) will need the following separate steps to compile
150 into an executable named morse:
151
152 <tscreen><verb>
153         cc65 -g -Oi -t c64 morse.c
154         ca65 -g morse.s
155         ca65 -g irq.s
156         ld65 -t c64 -o morse c64.o morse.o irq.o c64.lib
157 </verb></tscreen>
158
159 When using cl65, this is simplified to
160
161 <tscreen><verb>
162         cl65 -g -Oi morse.c irq.s
163 </verb></tscreen>
164
165 As a general rule, you may use cl65 instead of cc65 at most times,
166 especially in makefiles to build object files directly from C files. Use
167
168 <tscreen><verb>
169         .c.o:
170                 cl65 -g -Oi $<
171 </verb></tscreen>
172
173 to do this.
174
175
176
177 <sect>Bugs/Feedback<p>
178
179 If you have problems using the utility, if you find any bugs, or if you're
180 doing something interesting with it, I would be glad to hear from you. Feel
181 free to contact me by email (<htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">).
182
183
184
185 <sect>Copyright<p>
186
187 cl65 (and all cc65 binutils) are (C) Copyright 1998-2000 Ullrich von
188 Bassewitz. For usage of the binaries and/or sources the following
189 conditions do apply:
190
191 This software is provided 'as-is', without any expressed or implied
192 warranty.  In no event will the authors be held liable for any damages
193 arising from the use of this software.
194
195 Permission is granted to anyone to use this software for any purpose,
196 including commercial applications, and to alter it and redistribute it
197 freely, subject to the following restrictions:
198
199 <enum>
200 <item>  The origin of this software must not be misrepresented; you must not
201         claim that you wrote the original software. If you use this software
202         in a product, an acknowledgment in the product documentation would be
203         appreciated but is not required.
204 <item>  Altered source versions must be plainly marked as such, and must not
205         be misrepresented as being the original software.
206 <item>  This notice may not be removed or altered from any source
207         distribution.
208 </enum>
209
210
211
212 </article>
213