Blob


1 .TH 9C 1
2 .SH NAME
3 9c, 9a, 9l, 9ar \- C compiler, assembler, linker, archiver
4 .SH SYNOPSIS
5 .B 9c
6 [
7 .B -I
8 .I path
9 ]
10 [
11 .B -D
12 .I name
13 ]
14 .I file
15 \&...
16 .PP
17 .B 9a
18 .I file
19 \&...
20 .PP
21 .B 9l
22 [
23 .I -o
24 .I target
25 ]
26 .I object
27 \&...
28 [
29 .I library
30 \&...
31 ]
32 [
33 .BI -L path
34 \&...
35 ]
36 [
37 .BI -l name
38 \&...
39 ]
40 .PP
41 .B 9ar
42 .I key
43 [
44 .I posname
45 ]
46 .I afile
47 [
48 .I file
49 \&...
50 ]
51 .SH DESCRIPTION
52 These programs are shell scripts that invoke the appropriate standard tools
53 for the current operating system and architecture.
54 One can use them to write portable recipes for mkfiles.
55 .PP
56 .I 9c
57 compiles the named C
58 .I files
59 into object files for the current system.
60 The system C compiler is invoked with warnings enabled.
61 The
62 .B -I
63 option adds
64 .I path
65 to the include path,
66 and the
67 .B -D
68 option defines
69 .I name
70 in the C preprocessor.
71 .I 9c
72 always
73 defines the symbol
74 .B PLAN9PORT
75 defined in the C preprocessor and adds
76 .B $PLAN9/include
77 to the include path.
78 .PP
79 .I 9c
80 also defines
81 .B __sun__
82 on SunOS systems and
83 .B __Linux26__
84 on Linux systems with 2.6-series kernels.
85 .PP
86 .I 9a
87 assembles the named files into object files for the current system.
88 Unlike some system assemblers, it does
89 .I not
90 promise to run the C preprocessor on the source files.
91 .PP
92 .I 9l
93 links the named object files and libraries to create the target executable.
94 Each
95 .B -l
96 option specifies that a library named
97 .BI lib name .a
98 be found and linked.
99 The
100 .B -L
101 option adds directories to the library search path.
102 .I 9l
103 invokes the system linker with
104 .B $PLAN9/lib
105 already on the library search path.
106 .PP
107 .I 9l
108 searches the named objects and libraries for symbols of the form
109 .BI __p9l_autolib_ name \fR,
110 which it takes as indication that it should link
111 .BI $PLAN9/lib/lib name .a
112 as well.
113 It also examines such libraries to find their own dependencies.
114 A single
115 .B -l
116 option at the beginning of the command line disables this behavior.
117 The symbol
118 .BI __p9l_autolib_ name
119 is added to an object file by the macro
120 .B AUTOLIB( name )\fR,
121 defined in
122 .B <u.h>.
123 Header files associated with libraries contain
124 .B AUTOLIB
125 annotations; ordinary programs need not use them.
126 Due to shortcomings in the implementation, a source file may not
127 contain the same
128 .B AUTOLIB
129 statement multiple times.
130 .PP
131 .I 9ar
132 maintains object file archives called libraries.
133 The exact set of valid command keys varies from system to system,
134 but
135 .I 9ar
136 always provides the following key characters:
137 .TP
138 .B d
139 Delete
140 .I files
141 from the archive file.
142 .TP
143 .B r
144 Replace
145 .I files
146 in the archive file, or add them if missing.
147 .TP
148 .B t
149 List a table of contents of the archive.
150 If names are given, only those files are listed.
151 .TP
152 .B x
153 Extract the named files.
154 If no names are given, all files in the archive are
155 extracted.
156 In neither case does
157 .B x
158 alter the archive file.
159 .TP
160 .B v
161 Verbose.
162 Give a file-by-file
163 description of the making of a
164 new archive file from the old archive and the constituent files.
165 With
166 .BR t ,
167 give a long listing of all information about the files,
168 somewhat like a listing by
169 .IR ls (1),
170 showing
171 .br
172 .ns
173 .IP
174 .B
175 mode uid/gid size date name
176 .TP
177 .B c
178 Create.
179 Normally
180 .I 9ar
181 will create a new archive when
182 .I afile
183 does not exist, and give a warning.
184 Option
185 .B c
186 discards any old contents and suppresses the warning.
187 .PD
188 .PP
189 When a
190 .BR d ,
191 .BR r ,
192 or
193 .BR m
194 .I key
195 is specified,
196 .I 9ar
197 inserts a table of contents, required by the linker, at
198 the front of the library.
199 The table of contents is
200 rebuilt whenever the archive is modified.
201 .SH EXAMPLES
202 .TP
203 .L
204 9c file1.c file2.c file3.c
205 Compile three C source files.
206 .TP
207 .L
208 9a file4.s
209 Assemble one assembler source file.
210 .TP
211 .L
212 9ar rvc lib.a file[12].o
213 Archive the first two object files into a library.
214 .TP
215 .L
216 9l -o prog file3.o file4.o lib.a
217 Link the final two object files and any necessary objects from the library
218 into an executable.
219 .SH SOURCE
220 .B \*9/bin