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