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