1899
|
1 Index: ccache.1
|
|
2 ===================================================================
|
|
3 RCS file: /home/cvsroot/lars/ccache/ccache.1,v
|
|
4 retrieving revision 1.1.1.1.2.1
|
|
5 retrieving revision 1.6
|
|
6 diff -u -r1.1.1.1.2.1 -r1.6
|
|
7 --- ccache.1 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1
|
|
8 +++ ccache.1 21 Nov 2004 18:19:28 -0000 1.6
|
|
9 @@ -210,7 +210,8 @@
|
|
10 CCACHE_HARDLINK then ccache will attempt to use hard links from the
|
|
11 cache directory when creating the compiler output rather than using a
|
|
12 file copy\&. Using hard links is faster, but can confuse programs like
|
|
13 -\&'make\&' that rely on modification times\&.
|
|
14 +\&'make\&' that rely on modification times\&. Hard links are never made for
|
|
15 +compressed cache files\&.
|
|
16 .IP
|
|
17 .IP "\fBCCACHE_RECACHE\fP"
|
|
18 This forces ccache to not use any cached
|
|
19 @@ -257,6 +258,11 @@
|
|
20 the default\&. On HP-UX set this environment variable to "i" if you use
|
|
21 the aCC compiler\&.
|
|
22 .IP
|
|
23 +.IP "\fBCCACHE_NOCOMPRESS\fP"
|
|
24 +If you set the environment variable
|
|
25 +CCACHE_NOCOMPRESS then there is no compression used on files that go
|
|
26 +into the cache\&.
|
|
27 +.IP
|
|
28 .PP
|
|
29 .SH "CACHE SIZE MANAGEMENT"
|
|
30 .PP
|
|
31 @@ -269,6 +275,14 @@
|
|
32 below the numbers you specified in order to avoid doing the cache
|
|
33 clean operation too often\&.
|
|
34 .PP
|
|
35 +.SH "CACHE COMPRESSION"
|
|
36 +.PP
|
|
37 +By default ccache will compress all files it puts into the cache
|
|
38 +using the zlib compression\&. While this involves a negligible
|
|
39 +performance slowdown, it significantly increases the number of files
|
|
40 +that fit in the cache\&. You can turn off compression setting the
|
|
41 +CCACHE_NOCOMPRESS environment variable\&.
|
|
42 +.PP
|
|
43 .SH "HOW IT WORKS"
|
|
44 .PP
|
|
45 The basic idea is to detect when you are compiling exactly the same
|
|
46 Index: ccache.c
|
|
47 ===================================================================
|
|
48 RCS file: /home/cvsroot/lars/ccache/ccache.c,v
|
|
49 retrieving revision 1.1.1.1.2.1
|
|
50 retrieving revision 1.9
|
|
51 diff -u -r1.1.1.1.2.1 -r1.9
|
|
52 --- ccache.c 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1
|
|
53 +++ ccache.c 21 Nov 2004 18:19:28 -0000 1.9
|
|
54 @@ -199,7 +199,7 @@
|
|
55 fd = open(tmp_stderr, O_RDONLY | O_BINARY);
|
|
56 if (fd != -1) {
|
|
57 if (strcmp(output_file, "/dev/null") == 0 ||
|
|
58 - rename(tmp_hashname, output_file) == 0 || errno == ENOENT) {
|
|
59 + move_file(tmp_hashname, output_file) == 0 || errno == ENOENT) {
|
|
60 if (cpp_stderr) {
|
|
61 /* we might have some stderr from cpp */
|
|
62 int fd2 = open(cpp_stderr, O_RDONLY | O_BINARY);
|
|
63 @@ -231,14 +231,25 @@
|
|
64 x_asprintf(&path_stderr, "%s.stderr", hashname);
|
|
65
|
|
66 if (stat(tmp_stderr, &st1) != 0 ||
|
|
67 - stat(tmp_hashname, &st2) != 0 ||
|
|
68 - rename(tmp_hashname, hashname) != 0 ||
|
|
69 - rename(tmp_stderr, path_stderr) != 0) {
|
|
70 + stat(tmp_hashname, &st2) != 0 ||
|
|
71 + move_file(tmp_hashname, hashname) != 0 ||
|
|
72 + move_file(tmp_stderr, path_stderr) != 0) {
|
|
73 cc_log("failed to rename tmp files - %s\n", strerror(errno));
|
|
74 stats_update(STATS_ERROR);
|
|
75 failed();
|
|
76 }
|
|
77
|
|
78 +#if ENABLE_ZLIB
|
|
79 + /* do an extra stat on the cache files for
|
|
80 + the size statistics */
|
|
81 + if (stat(path_stderr, &st1) != 0 ||
|
|
82 + stat(hashname, &st2) != 0) {
|
|
83 + cc_log("failed to stat cache files - %s\n", strerror(errno));
|
|
84 + stats_update(STATS_ERROR);
|
|
85 + failed();
|
|
86 + }
|
|
87 +#endif
|
|
88 +
|
|
89 cc_log("Placed %s into cache\n", output_file);
|
|
90 stats_tocache(file_size(&st1) + file_size(&st2));
|
|
91
|
|
92 @@ -474,7 +485,13 @@
|
|
93 }
|
|
94
|
|
95 /* the user might be disabling cache hits */
|
|
96 +#ifndef ENABLE_ZLIB
|
|
97 + /* if the cache file is compressed we must recache */
|
|
98 + if ((first && getenv("CCACHE_RECACHE")) ||
|
|
99 + test_if_compressed(hashname) == 1) {
|
|
100 +#else
|
|
101 if (first && getenv("CCACHE_RECACHE")) {
|
|
102 +#endif
|
|
103 close(fd_stderr);
|
|
104 unlink(stderr_file);
|
|
105 free(stderr_file);
|
|
106 @@ -487,7 +504,9 @@
|
|
107 ret = 0;
|
|
108 } else {
|
|
109 unlink(output_file);
|
|
110 - if (getenv("CCACHE_HARDLINK")) {
|
|
111 + /* only make a hardlink if the cache file is uncompressed */
|
|
112 + if (getenv("CCACHE_HARDLINK") &&
|
|
113 + test_if_compressed(hashname) == 0) {
|
|
114 ret = link(hashname, output_file);
|
|
115 } else {
|
|
116 ret = copy_file(hashname, output_file);
|
|
117 Index: ccache.h
|
|
118 ===================================================================
|
|
119 RCS file: /home/cvsroot/lars/ccache/ccache.h,v
|
|
120 retrieving revision 1.1.1.1.2.1
|
|
121 retrieving revision 1.7
|
|
122 diff -u -r1.1.1.1.2.1 -r1.7
|
|
123 --- ccache.h 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1
|
|
124 +++ ccache.h 21 Nov 2004 18:19:28 -0000 1.7
|
|
125 @@ -23,6 +23,10 @@
|
|
126 #include <pwd.h>
|
|
127 #endif
|
|
128
|
|
129 +#ifdef ENABLE_ZLIB
|
|
130 +#include <zlib.h>
|
|
131 +#endif
|
|
132 +
|
|
133 #define STATUS_NOTFOUND 3
|
|
134 #define STATUS_FATAL 4
|
|
135 #define STATUS_NOCACHE 5
|
|
136 @@ -36,6 +40,13 @@
|
|
137 #define DEFAULT_MAXSIZE (1000*1000)
|
|
138 #endif
|
|
139
|
|
140 +/* file copy mode */
|
|
141 +#ifdef ENABLE_ZLIB
|
|
142 +#define COPY_UNCOMPRESSED 0
|
|
143 +#define COPY_FROM_CACHE 1
|
|
144 +#define COPY_TO_CACHE 2
|
|
145 +#endif
|
|
146 +
|
|
147 enum stats {
|
|
148 STATS_NONE=0,
|
|
149 STATS_STDOUT,
|
|
150 @@ -79,6 +90,8 @@
|
|
151
|
|
152 void copy_fd(int fd_in, int fd_out);
|
|
153 int copy_file(const char *src, const char *dest);
|
|
154 +int move_file(const char *src, const char *dest);
|
|
155 +int test_if_compressed(const char *filename);
|
|
156
|
|
157 int create_dir(const char *dir);
|
|
158 void x_asprintf(char **ptr, const char *format, ...);
|
|
159 Index: ccache.yo
|
|
160 ===================================================================
|
|
161 RCS file: /home/cvsroot/lars/ccache/ccache.yo,v
|
|
162 retrieving revision 1.1.1.1.2.1
|
|
163 retrieving revision 1.5
|
|
164 diff -u -r1.1.1.1.2.1 -r1.5
|
|
165 --- ccache.yo 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1
|
|
166 +++ ccache.yo 21 Nov 2004 18:19:28 -0000 1.5
|
|
167 @@ -169,6 +169,11 @@
|
|
168 this optimisation, in which case this option could allow ccache to be
|
|
169 used.
|
|
170
|
|
171 +dit(bf(CCACHE_NOCOMPRESS)) If you set the environment variable
|
|
172 +CCACHE_NOCOMPRESS then there is no compression used on files that go
|
|
173 +into the cache. However, this setting has no effect on how files are
|
|
174 +retrieved from the cache, compressed results will still be usable.
|
|
175 +
|
|
176 dit(bf(CCACHE_NOSTATS)) If you set the environment variable
|
|
177 CCACHE_NOSTATS then ccache will not update the statistics files on
|
|
178 each compile.
|
|
179 @@ -181,7 +186,8 @@
|
|
180 CCACHE_HARDLINK then ccache will attempt to use hard links from the
|
|
181 cache directory when creating the compiler output rather than using a
|
|
182 file copy. Using hard links is faster, but can confuse programs like
|
|
183 -'make' that rely on modification times.
|
|
184 +'make' that rely on modification times. Hard links are never made for
|
|
185 +compressed cache files.
|
|
186
|
|
187 dit(bf(CCACHE_RECACHE)) This forces ccache to not use any cached
|
|
188 results, even if it finds them. New results are still cached, but
|
|
189 @@ -236,6 +242,14 @@
|
|
190 below the numbers you specified in order to avoid doing the cache
|
|
191 clean operation too often.
|
|
192
|
|
193 +manpagesection(CACHE COMPRESSION)
|
|
194 +
|
|
195 +By default ccache will compress all files it puts into the cache
|
|
196 +using the zlib compression. While this involves a negligible
|
|
197 +performance slowdown, it significantly increases the number of files
|
|
198 +that fit in the cache. You can turn off compression setting the
|
|
199 +CCACHE_NOCOMPRESS environment variable.
|
|
200 +
|
|
201 manpagesection(HOW IT WORKS)
|
|
202
|
|
203 The basic idea is to detect when you are compiling exactly the same
|
|
204 @@ -294,6 +308,8 @@
|
|
205 cache. This tells the filesystem to inherit group ownership for new
|
|
206 directories. The command "chmod g+s `find $CCACHE_DIR -type d`" might
|
|
207 be useful for this.
|
|
208 + it() Set bf(CCACHE_NOCOMPRESS) for all users, if there are users with
|
|
209 + versions of ccache that do not support compression.
|
|
210 )
|
|
211
|
|
212 manpagesection(HISTORY)
|
|
213 Index: config.h.in
|
|
214 ===================================================================
|
|
215 RCS file: /home/cvsroot/lars/ccache/config.h.in,v
|
|
216 retrieving revision 1.1.1.1
|
|
217 retrieving revision 1.2
|
|
218 diff -u -r1.1.1.1 -r1.2
|
|
219 --- config.h.in 30 Apr 2004 13:13:41 -0000 1.1.1.1
|
|
220 +++ config.h.in 4 May 2004 20:49:26 -0000 1.2
|
|
221 @@ -98,3 +98,6 @@
|
|
222
|
|
223 /* Define _GNU_SOURCE so that we get all necessary prototypes */
|
|
224 #undef _GNU_SOURCE
|
|
225 +
|
|
226 +/* Define to 1 if you like to have zlib compression for the ccache. */
|
|
227 +#undef ENABLE_ZLIB
|
|
228 Index: configure
|
|
229 ===================================================================
|
|
230 RCS file: /home/cvsroot/lars/ccache/configure,v
|
|
231 retrieving revision 1.1.1.1.2.1
|
|
232 diff -u -r1.1.1.1.2.1 configure
|
|
233 --- configure 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1
|
|
234 +++ configure 21 Nov 2004 18:24:42 -0000
|
|
235 @@ -836,6 +836,11 @@
|
|
236
|
|
237 cat <<\_ACEOF
|
|
238
|
|
239 +Optional Features:
|
|
240 + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
|
|
241 + --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
|
|
242 + --enable-zlib enable zlib support for ccache compression
|
|
243 +
|
|
244 Some influential environment variables:
|
|
245 CC C compiler command
|
|
246 CFLAGS C compiler flags
|
|
247 @@ -936,7 +941,7 @@
|
|
248 else
|
|
249 echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
|
|
250 fi
|
|
251 - cd "$ac_popdir"
|
|
252 + cd $ac_popdir
|
|
253 done
|
|
254 fi
|
|
255
|
|
256 @@ -1859,7 +1864,8 @@
|
|
257 cat conftest.err >&5
|
|
258 echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
259 (exit $ac_status); } &&
|
|
260 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
|
261 + { ac_try='test -z "$ac_c_werror_flag"
|
|
262 + || test ! -s conftest.err'
|
|
263 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
264 (eval $ac_try) 2>&5
|
|
265 ac_status=$?
|
|
266 @@ -1917,7 +1923,8 @@
|
|
267 cat conftest.err >&5
|
|
268 echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
269 (exit $ac_status); } &&
|
|
270 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
|
271 + { ac_try='test -z "$ac_c_werror_flag"
|
|
272 + || test ! -s conftest.err'
|
|
273 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
274 (eval $ac_try) 2>&5
|
|
275 ac_status=$?
|
|
276 @@ -2033,7 +2040,8 @@
|
|
277 cat conftest.err >&5
|
|
278 echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
279 (exit $ac_status); } &&
|
|
280 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
|
281 + { ac_try='test -z "$ac_c_werror_flag"
|
|
282 + || test ! -s conftest.err'
|
|
283 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
284 (eval $ac_try) 2>&5
|
|
285 ac_status=$?
|
|
286 @@ -2087,7 +2095,8 @@
|
|
287 cat conftest.err >&5
|
|
288 echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
289 (exit $ac_status); } &&
|
|
290 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
|
291 + { ac_try='test -z "$ac_c_werror_flag"
|
|
292 + || test ! -s conftest.err'
|
|
293 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
294 (eval $ac_try) 2>&5
|
|
295 ac_status=$?
|
|
296 @@ -2132,7 +2141,8 @@
|
|
297 cat conftest.err >&5
|
|
298 echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
299 (exit $ac_status); } &&
|
|
300 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
|
301 + { ac_try='test -z "$ac_c_werror_flag"
|
|
302 + || test ! -s conftest.err'
|
|
303 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
304 (eval $ac_try) 2>&5
|
|
305 ac_status=$?
|
|
306 @@ -2176,7 +2186,8 @@
|
|
307 cat conftest.err >&5
|
|
308 echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
309 (exit $ac_status); } &&
|
|
310 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
|
311 + { ac_try='test -z "$ac_c_werror_flag"
|
|
312 + || test ! -s conftest.err'
|
|
313 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
314 (eval $ac_try) 2>&5
|
|
315 ac_status=$?
|
|
316 @@ -2609,7 +2620,8 @@
|
|
317 cat conftest.err >&5
|
|
318 echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
319 (exit $ac_status); } &&
|
|
320 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
|
321 + { ac_try='test -z "$ac_c_werror_flag"
|
|
322 + || test ! -s conftest.err'
|
|
323 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
324 (eval $ac_try) 2>&5
|
|
325 ac_status=$?
|
|
326 @@ -2681,7 +2693,8 @@
|
|
327 cat conftest.err >&5
|
|
328 echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
329 (exit $ac_status); } &&
|
|
330 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
|
331 + { ac_try='test -z "$ac_c_werror_flag"
|
|
332 + || test ! -s conftest.err'
|
|
333 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
334 (eval $ac_try) 2>&5
|
|
335 ac_status=$?
|
|
336 @@ -2735,7 +2748,8 @@
|
|
337 cat conftest.err >&5
|
|
338 echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
339 (exit $ac_status); } &&
|
|
340 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
|
341 + { ac_try='test -z "$ac_c_werror_flag"
|
|
342 + || test ! -s conftest.err'
|
|
343 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
344 (eval $ac_try) 2>&5
|
|
345 ac_status=$?
|
|
346 @@ -2806,7 +2820,8 @@
|
|
347 cat conftest.err >&5
|
|
348 echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
349 (exit $ac_status); } &&
|
|
350 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
|
351 + { ac_try='test -z "$ac_c_werror_flag"
|
|
352 + || test ! -s conftest.err'
|
|
353 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
354 (eval $ac_try) 2>&5
|
|
355 ac_status=$?
|
|
356 @@ -2860,7 +2875,8 @@
|
|
357 cat conftest.err >&5
|
|
358 echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
359 (exit $ac_status); } &&
|
|
360 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
|
361 + { ac_try='test -z "$ac_c_werror_flag"
|
|
362 + || test ! -s conftest.err'
|
|
363 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
364 (eval $ac_try) 2>&5
|
|
365 ac_status=$?
|
|
366 @@ -2927,7 +2943,8 @@
|
|
367 cat conftest.err >&5
|
|
368 echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
369 (exit $ac_status); } &&
|
|
370 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
|
371 + { ac_try='test -z "$ac_c_werror_flag"
|
|
372 + || test ! -s conftest.err'
|
|
373 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
374 (eval $ac_try) 2>&5
|
|
375 ac_status=$?
|
|
376 @@ -2997,7 +3014,8 @@
|
|
377 cat conftest.err >&5
|
|
378 echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
379 (exit $ac_status); } &&
|
|
380 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
|
381 + { ac_try='test -z "$ac_c_werror_flag"
|
|
382 + || test ! -s conftest.err'
|
|
383 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
384 (eval $ac_try) 2>&5
|
|
385 ac_status=$?
|
|
386 @@ -3078,7 +3096,8 @@
|
|
387 cat conftest.err >&5
|
|
388 echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
389 (exit $ac_status); } &&
|
|
390 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
|
391 + { ac_try='test -z "$ac_c_werror_flag"
|
|
392 + || test ! -s conftest.err'
|
|
393 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
394 (eval $ac_try) 2>&5
|
|
395 ac_status=$?
|
|
396 @@ -3248,7 +3267,8 @@
|
|
397 cat conftest.err >&5
|
|
398 echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
399 (exit $ac_status); } &&
|
|
400 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
|
401 + { ac_try='test -z "$ac_c_werror_flag"
|
|
402 + || test ! -s conftest.err'
|
|
403 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
404 (eval $ac_try) 2>&5
|
|
405 ac_status=$?
|
|
406 @@ -3319,7 +3339,8 @@
|
|
407 cat conftest.err >&5
|
|
408 echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
409 (exit $ac_status); } &&
|
|
410 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
|
411 + { ac_try='test -z "$ac_c_werror_flag"
|
|
412 + || test ! -s conftest.err'
|
|
413 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
414 (eval $ac_try) 2>&5
|
|
415 ac_status=$?
|
|
416 @@ -3509,7 +3530,8 @@
|
|
417 cat conftest.err >&5
|
|
418 echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
419 (exit $ac_status); } &&
|
|
420 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
|
421 + { ac_try='test -z "$ac_c_werror_flag"
|
|
422 + || test ! -s conftest.err'
|
|
423 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
424 (eval $ac_try) 2>&5
|
|
425 ac_status=$?
|
|
426 @@ -3611,7 +3633,8 @@
|
|
427 cat conftest.err >&5
|
|
428 echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
429 (exit $ac_status); } &&
|
|
430 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
|
431 + { ac_try='test -z "$ac_c_werror_flag"
|
|
432 + || test ! -s conftest.err'
|
|
433 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
434 (eval $ac_try) 2>&5
|
|
435 ac_status=$?
|
|
436 @@ -3676,7 +3699,8 @@
|
|
437 cat conftest.err >&5
|
|
438 echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
439 (exit $ac_status); } &&
|
|
440 - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
|
441 + { ac_try='test -z "$ac_c_werror_flag"
|
|
442 + || test ! -s conftest.err'
|
|
443 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
444 (eval $ac_try) 2>&5
|
|
445 ac_status=$?
|
|
446 @@ -3775,6 +3799,229 @@
|
|
447
|
|
448 fi
|
|
449
|
|
450 +# Check whether --enable-zlib or --disable-zlib was given.
|
|
451 +if test "${enable_zlib+set}" = set; then
|
|
452 + enableval="$enable_zlib"
|
|
453 +
|
|
454 +else
|
|
455 + enable_zlib=yes
|
|
456 +fi;
|
|
457 +
|
|
458 +if test x"$enable_zlib" = x"yes"; then
|
|
459 + if test "${ac_cv_header_zlib_h+set}" = set; then
|
|
460 + echo "$as_me:$LINENO: checking for zlib.h" >&5
|
|
461 +echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6
|
|
462 +if test "${ac_cv_header_zlib_h+set}" = set; then
|
|
463 + echo $ECHO_N "(cached) $ECHO_C" >&6
|
|
464 +fi
|
|
465 +echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5
|
|
466 +echo "${ECHO_T}$ac_cv_header_zlib_h" >&6
|
|
467 +else
|
|
468 + # Is the header compilable?
|
|
469 +echo "$as_me:$LINENO: checking zlib.h usability" >&5
|
|
470 +echo $ECHO_N "checking zlib.h usability... $ECHO_C" >&6
|
|
471 +cat >conftest.$ac_ext <<_ACEOF
|
|
472 +/* confdefs.h. */
|
|
473 +_ACEOF
|
|
474 +cat confdefs.h >>conftest.$ac_ext
|
|
475 +cat >>conftest.$ac_ext <<_ACEOF
|
|
476 +/* end confdefs.h. */
|
|
477 +$ac_includes_default
|
|
478 +#include <zlib.h>
|
|
479 +_ACEOF
|
|
480 +rm -f conftest.$ac_objext
|
|
481 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
|
|
482 + (eval $ac_compile) 2>conftest.er1
|
|
483 + ac_status=$?
|
|
484 + grep -v '^ *+' conftest.er1 >conftest.err
|
|
485 + rm -f conftest.er1
|
|
486 + cat conftest.err >&5
|
|
487 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
488 + (exit $ac_status); } &&
|
|
489 + { ac_try='test -z "$ac_c_werror_flag"
|
|
490 + || test ! -s conftest.err'
|
|
491 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
492 + (eval $ac_try) 2>&5
|
|
493 + ac_status=$?
|
|
494 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
495 + (exit $ac_status); }; } &&
|
|
496 + { ac_try='test -s conftest.$ac_objext'
|
|
497 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
498 + (eval $ac_try) 2>&5
|
|
499 + ac_status=$?
|
|
500 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
501 + (exit $ac_status); }; }; then
|
|
502 + ac_header_compiler=yes
|
|
503 +else
|
|
504 + echo "$as_me: failed program was:" >&5
|
|
505 +sed 's/^/| /' conftest.$ac_ext >&5
|
|
506 +
|
|
507 +ac_header_compiler=no
|
|
508 +fi
|
|
509 +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
|
|
510 +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
|
|
511 +echo "${ECHO_T}$ac_header_compiler" >&6
|
|
512 +
|
|
513 +# Is the header present?
|
|
514 +echo "$as_me:$LINENO: checking zlib.h presence" >&5
|
|
515 +echo $ECHO_N "checking zlib.h presence... $ECHO_C" >&6
|
|
516 +cat >conftest.$ac_ext <<_ACEOF
|
|
517 +/* confdefs.h. */
|
|
518 +_ACEOF
|
|
519 +cat confdefs.h >>conftest.$ac_ext
|
|
520 +cat >>conftest.$ac_ext <<_ACEOF
|
|
521 +/* end confdefs.h. */
|
|
522 +#include <zlib.h>
|
|
523 +_ACEOF
|
|
524 +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
|
|
525 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
|
|
526 + ac_status=$?
|
|
527 + grep -v '^ *+' conftest.er1 >conftest.err
|
|
528 + rm -f conftest.er1
|
|
529 + cat conftest.err >&5
|
|
530 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
531 + (exit $ac_status); } >/dev/null; then
|
|
532 + if test -s conftest.err; then
|
|
533 + ac_cpp_err=$ac_c_preproc_warn_flag
|
|
534 + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
|
|
535 + else
|
|
536 + ac_cpp_err=
|
|
537 + fi
|
|
538 +else
|
|
539 + ac_cpp_err=yes
|
|
540 +fi
|
|
541 +if test -z "$ac_cpp_err"; then
|
|
542 + ac_header_preproc=yes
|
|
543 +else
|
|
544 + echo "$as_me: failed program was:" >&5
|
|
545 +sed 's/^/| /' conftest.$ac_ext >&5
|
|
546 +
|
|
547 + ac_header_preproc=no
|
|
548 +fi
|
|
549 +rm -f conftest.err conftest.$ac_ext
|
|
550 +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
|
|
551 +echo "${ECHO_T}$ac_header_preproc" >&6
|
|
552 +
|
|
553 +# So? What about this header?
|
|
554 +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
|
|
555 + yes:no: )
|
|
556 + { echo "$as_me:$LINENO: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&5
|
|
557 +echo "$as_me: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
|
|
558 + { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the compiler's result" >&5
|
|
559 +echo "$as_me: WARNING: zlib.h: proceeding with the compiler's result" >&2;}
|
|
560 + ac_header_preproc=yes
|
|
561 + ;;
|
|
562 + no:yes:* )
|
|
563 + { echo "$as_me:$LINENO: WARNING: zlib.h: present but cannot be compiled" >&5
|
|
564 +echo "$as_me: WARNING: zlib.h: present but cannot be compiled" >&2;}
|
|
565 + { echo "$as_me:$LINENO: WARNING: zlib.h: check for missing prerequisite headers?" >&5
|
|
566 +echo "$as_me: WARNING: zlib.h: check for missing prerequisite headers?" >&2;}
|
|
567 + { echo "$as_me:$LINENO: WARNING: zlib.h: see the Autoconf documentation" >&5
|
|
568 +echo "$as_me: WARNING: zlib.h: see the Autoconf documentation" >&2;}
|
|
569 + { echo "$as_me:$LINENO: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&5
|
|
570 +echo "$as_me: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&2;}
|
|
571 + { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the preprocessor's result" >&5
|
|
572 +echo "$as_me: WARNING: zlib.h: proceeding with the preprocessor's result" >&2;}
|
|
573 + { echo "$as_me:$LINENO: WARNING: zlib.h: in the future, the compiler will take precedence" >&5
|
|
574 +echo "$as_me: WARNING: zlib.h: in the future, the compiler will take precedence" >&2;}
|
|
575 + (
|
|
576 + cat <<\_ASBOX
|
|
577 +## ------------------------------------------ ##
|
|
578 +## Report this to the AC_PACKAGE_NAME lists. ##
|
|
579 +## ------------------------------------------ ##
|
|
580 +_ASBOX
|
|
581 + ) |
|
|
582 + sed "s/^/$as_me: WARNING: /" >&2
|
|
583 + ;;
|
|
584 +esac
|
|
585 +echo "$as_me:$LINENO: checking for zlib.h" >&5
|
|
586 +echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6
|
|
587 +if test "${ac_cv_header_zlib_h+set}" = set; then
|
|
588 + echo $ECHO_N "(cached) $ECHO_C" >&6
|
|
589 +else
|
|
590 + ac_cv_header_zlib_h=$ac_header_preproc
|
|
591 +fi
|
|
592 +echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5
|
|
593 +echo "${ECHO_T}$ac_cv_header_zlib_h" >&6
|
|
594 +
|
|
595 +fi
|
|
596 +if test $ac_cv_header_zlib_h = yes; then
|
|
597 + echo "$as_me:$LINENO: checking for gzdopen in -lz" >&5
|
|
598 +echo $ECHO_N "checking for gzdopen in -lz... $ECHO_C" >&6
|
|
599 +if test "${ac_cv_lib_z_gzdopen+set}" = set; then
|
|
600 + echo $ECHO_N "(cached) $ECHO_C" >&6
|
|
601 +else
|
|
602 + ac_check_lib_save_LIBS=$LIBS
|
|
603 +LIBS="-lz $LIBS"
|
|
604 +cat >conftest.$ac_ext <<_ACEOF
|
|
605 +/* confdefs.h. */
|
|
606 +_ACEOF
|
|
607 +cat confdefs.h >>conftest.$ac_ext
|
|
608 +cat >>conftest.$ac_ext <<_ACEOF
|
|
609 +/* end confdefs.h. */
|
|
610 +
|
|
611 +/* Override any gcc2 internal prototype to avoid an error. */
|
|
612 +#ifdef __cplusplus
|
|
613 +extern "C"
|
|
614 +#endif
|
|
615 +/* We use char because int might match the return type of a gcc2
|
|
616 + builtin and then its argument prototype would still apply. */
|
|
617 +char gzdopen ();
|
|
618 +int
|
|
619 +main ()
|
|
620 +{
|
|
621 +gzdopen ();
|
|
622 + ;
|
|
623 + return 0;
|
|
624 +}
|
|
625 +_ACEOF
|
|
626 +rm -f conftest.$ac_objext conftest$ac_exeext
|
|
627 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
|
|
628 + (eval $ac_link) 2>conftest.er1
|
|
629 + ac_status=$?
|
|
630 + grep -v '^ *+' conftest.er1 >conftest.err
|
|
631 + rm -f conftest.er1
|
|
632 + cat conftest.err >&5
|
|
633 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
634 + (exit $ac_status); } &&
|
|
635 + { ac_try='test -z "$ac_c_werror_flag"
|
|
636 + || test ! -s conftest.err'
|
|
637 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
638 + (eval $ac_try) 2>&5
|
|
639 + ac_status=$?
|
|
640 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
641 + (exit $ac_status); }; } &&
|
|
642 + { ac_try='test -s conftest$ac_exeext'
|
|
643 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
644 + (eval $ac_try) 2>&5
|
|
645 + ac_status=$?
|
|
646 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
647 + (exit $ac_status); }; }; then
|
|
648 + ac_cv_lib_z_gzdopen=yes
|
|
649 +else
|
|
650 + echo "$as_me: failed program was:" >&5
|
|
651 +sed 's/^/| /' conftest.$ac_ext >&5
|
|
652 +
|
|
653 +ac_cv_lib_z_gzdopen=no
|
|
654 +fi
|
|
655 +rm -f conftest.err conftest.$ac_objext \
|
|
656 + conftest$ac_exeext conftest.$ac_ext
|
|
657 +LIBS=$ac_check_lib_save_LIBS
|
|
658 +fi
|
|
659 +echo "$as_me:$LINENO: result: $ac_cv_lib_z_gzdopen" >&5
|
|
660 +echo "${ECHO_T}$ac_cv_lib_z_gzdopen" >&6
|
|
661 +if test $ac_cv_lib_z_gzdopen = yes; then
|
|
662 + LIBS="-lz $LIBS"; cat >>confdefs.h <<\_ACEOF
|
|
663 +#define ENABLE_ZLIB 1
|
|
664 +_ACEOF
|
|
665 +
|
|
666 +fi
|
|
667 +
|
|
668 +fi
|
|
669 +
|
|
670 +
|
|
671 +fi
|
|
672 +
|
|
673 ac_config_files="$ac_config_files Makefile"
|
|
674
|
|
675 cat >confcache <<\_ACEOF
|
|
676 @@ -4568,6 +4815,11 @@
|
|
677 *) ac_INSTALL=$ac_top_builddir$INSTALL ;;
|
|
678 esac
|
|
679
|
|
680 + if test x"$ac_file" != x-; then
|
|
681 + { echo "$as_me:$LINENO: creating $ac_file" >&5
|
|
682 +echo "$as_me: creating $ac_file" >&6;}
|
|
683 + rm -f "$ac_file"
|
|
684 + fi
|
|
685 # Let's still pretend it is `configure' which instantiates (i.e., don't
|
|
686 # use $as_me), people would be surprised to read:
|
|
687 # /* config.h. Generated by config.status. */
|
|
688 @@ -4606,12 +4858,6 @@
|
|
689 fi;;
|
|
690 esac
|
|
691 done` || { (exit 1); exit 1; }
|
|
692 -
|
|
693 - if test x"$ac_file" != x-; then
|
|
694 - { echo "$as_me:$LINENO: creating $ac_file" >&5
|
|
695 -echo "$as_me: creating $ac_file" >&6;}
|
|
696 - rm -f "$ac_file"
|
|
697 - fi
|
|
698 _ACEOF
|
|
699 cat >>$CONFIG_STATUS <<_ACEOF
|
|
700 sed "$ac_vpsub
|
|
701 Index: configure.in
|
|
702 ===================================================================
|
|
703 RCS file: /home/cvsroot/lars/ccache/configure.in,v
|
|
704 retrieving revision 1.1.1.1.2.1
|
|
705 retrieving revision 1.4
|
|
706 diff -u -r1.1.1.1.2.1 -r1.4
|
|
707 --- configure.in 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1
|
|
708 +++ configure.in 21 Nov 2004 18:19:28 -0000 1.4
|
|
709 @@ -68,5 +68,14 @@
|
|
710 AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ])
|
|
711 fi
|
|
712
|
|
713 +dnl Check for zlib.
|
|
714 +AC_ARG_ENABLE([zlib],
|
|
715 + AS_HELP_STRING([--enable-zlib], [enable zlib support for ccache compression]),,
|
|
716 + [enable_zlib=yes])
|
|
717 +
|
|
718 +if test x"$enable_zlib" = x"yes"; then
|
|
719 + AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, gzdopen, LIBS="-lz $LIBS"; AC_DEFINE(ENABLE_ZLIB)))
|
|
720 +fi
|
|
721 +
|
|
722 AC_CONFIG_FILES([Makefile])
|
|
723 AC_OUTPUT
|
|
724 Index: util.c
|
|
725 ===================================================================
|
|
726 RCS file: /home/cvsroot/lars/ccache/util.c,v
|
|
727 retrieving revision 1.1.1.1.2.1
|
|
728 retrieving revision 1.11
|
|
729 diff -u -r1.1.1.1.2.1 -r1.11
|
|
730 --- util.c 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1
|
|
731 +++ util.c 21 Nov 2004 18:19:28 -0000 1.11
|
|
732 @@ -44,6 +44,7 @@
|
|
733 exit(1);
|
|
734 }
|
|
735
|
|
736 +#ifndef ENABLE_ZLIB
|
|
737 /* copy all data from one file descriptor to another */
|
|
738 void copy_fd(int fd_in, int fd_out)
|
|
739 {
|
|
740 @@ -57,6 +58,11 @@
|
|
741 }
|
|
742 }
|
|
743
|
|
744 +/* move a file using rename */
|
|
745 +int move_file(const char *src, const char *dest) {
|
|
746 + return rename(src, dest);
|
|
747 +}
|
|
748 +
|
|
749 /* copy a file - used when hard links don't work
|
|
750 the copy is done via a temporary file and atomic rename
|
|
751 */
|
|
752 @@ -120,6 +126,174 @@
|
|
753 return 0;
|
|
754 }
|
|
755
|
|
756 +#else /* ENABLE_ZLIB */
|
|
757 +
|
|
758 +/* copy all data from one file descriptor to another
|
|
759 + possibly decompressing it
|
|
760 +*/
|
|
761 +void copy_fd(int fd_in, int fd_out) {
|
|
762 + char buf[10240];
|
|
763 + int n;
|
|
764 + gzFile gz_in;
|
|
765 +
|
|
766 + gz_in = gzdopen(dup(fd_in), "rb");
|
|
767 +
|
|
768 + if (!gz_in) {
|
|
769 + fatal("Failed to copy fd");
|
|
770 + }
|
|
771 +
|
|
772 + while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) {
|
|
773 + if (write(fd_out, buf, n) != n) {
|
|
774 + fatal("Failed to copy fd");
|
|
775 + }
|
|
776 + }
|
|
777 +}
|
|
778 +
|
|
779 +static int _copy_file(const char *src, const char *dest, int mode) {
|
|
780 + int fd_in, fd_out;
|
|
781 + gzFile gz_in, gz_out = NULL;
|
|
782 + char buf[10240];
|
|
783 + int n, ret;
|
|
784 + char *tmp_name;
|
|
785 + mode_t mask;
|
|
786 + struct stat st;
|
|
787 +
|
|
788 + x_asprintf(&tmp_name, "%s.XXXXXX", dest);
|
|
789 +
|
|
790 + if (getenv("CCACHE_NOCOMPRESS")) {
|
|
791 + mode = COPY_UNCOMPRESSED;
|
|
792 + }
|
|
793 +
|
|
794 + /* open source file */
|
|
795 + fd_in = open(src, O_RDONLY);
|
|
796 + if (fd_in == -1) {
|
|
797 + return -1;
|
|
798 + }
|
|
799 +
|
|
800 + gz_in = gzdopen(fd_in, "rb");
|
|
801 + if (!gz_in) {
|
|
802 + close(fd_in);
|
|
803 + return -1;
|
|
804 + }
|
|
805 +
|
|
806 + /* open destination file */
|
|
807 + fd_out = mkstemp(tmp_name);
|
|
808 + if (fd_out == -1) {
|
|
809 + gzclose(gz_in);
|
|
810 + free(tmp_name);
|
|
811 + return -1;
|
|
812 + }
|
|
813 +
|
|
814 + if (mode == COPY_TO_CACHE) {
|
|
815 + /* The gzip file format occupies at least 20 bytes. So
|
|
816 + it will always occupy an entire filesystem block,
|
|
817 + even for empty files.
|
|
818 + Since most stderr files will be empty, we turn off
|
|
819 + compression in this case to save space.
|
|
820 + */
|
|
821 + if (fstat(fd_in, &st) != 0) {
|
|
822 + gzclose(gz_in);
|
|
823 + close(fd_out);
|
|
824 + free(tmp_name);
|
|
825 + return -1;
|
|
826 + }
|
|
827 + if (file_size(&st) == 0) {
|
|
828 + mode = COPY_UNCOMPRESSED;
|
|
829 + }
|
|
830 + }
|
|
831 +
|
|
832 + if (mode == COPY_TO_CACHE) {
|
|
833 + gz_out = gzdopen(dup(fd_out), "wb");
|
|
834 + if (!gz_out) {
|
|
835 + gzclose(gz_in);
|
|
836 + close(fd_out);
|
|
837 + free(tmp_name);
|
|
838 + return -1;
|
|
839 + }
|
|
840 + }
|
|
841 +
|
|
842 + while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) {
|
|
843 + if (mode == COPY_TO_CACHE) {
|
|
844 + ret = gzwrite(gz_out, buf, n);
|
|
845 + } else {
|
|
846 + ret = write(fd_out, buf, n);
|
|
847 + }
|
|
848 + if (ret != n) {
|
|
849 + gzclose(gz_in);
|
|
850 + if (gz_out) {
|
|
851 + gzclose(gz_out);
|
|
852 + }
|
|
853 + close(fd_out);
|
|
854 + unlink(tmp_name);
|
|
855 + free(tmp_name);
|
|
856 + return -1;
|
|
857 + }
|
|
858 + }
|
|
859 +
|
|
860 + gzclose(gz_in);
|
|
861 + if (gz_out) {
|
|
862 + gzclose(gz_out);
|
|
863 + }
|
|
864 +
|
|
865 + /* get perms right on the tmp file */
|
|
866 + mask = umask(0);
|
|
867 + fchmod(fd_out, 0666 & ~mask);
|
|
868 + umask(mask);
|
|
869 +
|
|
870 + /* the close can fail on NFS if out of space */
|
|
871 + if (close(fd_out) == -1) {
|
|
872 + unlink(tmp_name);
|
|
873 + free(tmp_name);
|
|
874 + return -1;
|
|
875 + }
|
|
876 +
|
|
877 + unlink(dest);
|
|
878 +
|
|
879 + if (rename(tmp_name, dest) == -1) {
|
|
880 + unlink(tmp_name);
|
|
881 + free(tmp_name);
|
|
882 + return -1;
|
|
883 + }
|
|
884 +
|
|
885 + free(tmp_name);
|
|
886 +
|
|
887 + return 0;
|
|
888 +}
|
|
889 +
|
|
890 +/* move a file to the cache, compressing it */
|
|
891 +int move_file(const char *src, const char *dest) {
|
|
892 + int ret;
|
|
893 +
|
|
894 + ret = _copy_file(src, dest, COPY_TO_CACHE);
|
|
895 + if (ret != -1) unlink(src);
|
|
896 + return ret;
|
|
897 +}
|
|
898 +
|
|
899 +/* copy a file from the cache, decompressing it */
|
|
900 +int copy_file(const char *src, const char *dest) {
|
|
901 + return _copy_file(src, dest, COPY_FROM_CACHE);
|
|
902 +}
|
|
903 +#endif /* ENABLE_ZLIB */
|
|
904 +
|
|
905 +/* test if a file is zlib compressed */
|
|
906 +int test_if_compressed(const char *filename) {
|
|
907 + FILE *f;
|
|
908 +
|
|
909 + f = fopen(filename, "rb");
|
|
910 + if (!f) {
|
|
911 + return 0;
|
|
912 + }
|
|
913 +
|
|
914 + /* test if file starts with 1F8B, which is zlib's
|
|
915 + * magic number */
|
|
916 + if ((fgetc(f) != 0x1f) || (fgetc(f) != 0x8b)) {
|
|
917 + fclose(f);
|
|
918 + return 0;
|
|
919 + }
|
|
920 +
|
|
921 + fclose(f);
|
|
922 + return 1;
|
|
923 +}
|
|
924
|
|
925 /* make sure a directory exists */
|
|
926 int create_dir(const char *dir)
|
|
927 Index: manage-cache.sh
|
|
928 ===================================================================
|
|
929 RCS file: manage-cache.sh
|
|
930 diff -N manage-cache.sh
|
|
931 --- manage-cache.sh 1 Jan 1970 00:00:00 -0000
|
|
932 +++ manage-cache.sh-cache.sh 12 May 2004 19:22:20 -0000 1.1
|
|
933 @@ -0,0 +1,68 @@
|
|
934 +#!/bin/bash
|
|
935 +#
|
|
936 +# 2004-05-12 lars@gustaebel.de
|
|
937 +
|
|
938 +CCACHE_DIR=${CCACHE_DIR:-$HOME/.ccache}
|
|
939 +
|
|
940 +echo "Do you want to compress or decompress the ccache in $CCACHE_DIR?"
|
|
941 +read -p "Type c or d: " mode
|
|
942 +
|
|
943 +if [ "$mode" != "c" ] && [ "$mode" != "d" ]
|
|
944 +then
|
|
945 + exit 1
|
|
946 +fi
|
|
947 +
|
|
948 +is_compressed() {
|
|
949 + test "$(head -c 2 $1)" = $'\x1f\x8b'
|
|
950 + return $?
|
|
951 +}
|
|
952 +
|
|
953 +tmpfile=$(mktemp)
|
|
954 +
|
|
955 +for dir in 0 1 2 3 4 5 6 7 8 9 a b c d e f
|
|
956 +do
|
|
957 + # process ccache subdir
|
|
958 + echo -n "$dir "
|
|
959 +
|
|
960 + # find cache files
|
|
961 + find $CCACHE_DIR/$dir -type f -name '*-*' |
|
|
962 + sort > $tmpfile
|
|
963 +
|
|
964 + oldsize=$(cat $CCACHE_DIR/$dir/stats | cut -d ' ' -f 13)
|
|
965 + newsize=0
|
|
966 +
|
|
967 + while read file
|
|
968 + do
|
|
969 + # empty files will be ignored since compressing
|
|
970 + # them makes them bigger
|
|
971 + test $(stat -c %s $file) -eq 0 && continue
|
|
972 +
|
|
973 + if [ $mode = c ]
|
|
974 + then
|
|
975 + if ! is_compressed $file
|
|
976 + then
|
|
977 + gzip $file
|
|
978 + mv $file.gz $file
|
|
979 + fi
|
|
980 + else
|
|
981 + if is_compressed $file
|
|
982 + then
|
|
983 + mv $file $file.gz
|
|
984 + gzip -d $file.gz
|
|
985 + fi
|
|
986 + fi
|
|
987 +
|
|
988 + # calculate new size statistic for this subdir
|
|
989 + let newsize=$newsize+$(stat -c "%B*%b" $file)/1024
|
|
990 + done < $tmpfile
|
|
991 +
|
|
992 + # update statistic file
|
|
993 + read -a numbers < $CCACHE_DIR/$dir/stats
|
|
994 + numbers[12]=$newsize
|
|
995 + echo "${numbers[*]} " > $CCACHE_DIR/$dir/stats
|
|
996 +done
|
|
997 +echo
|
|
998 +
|
|
999 +# clean up
|
|
1000 +rm $tmpfile
|
|
1001 +
|
|
1002 Index: Makefile.in
|
|
1003 ===================================================================
|
|
1004 RCS file: /home/cvsroot/lars/ccache/Makefile.in,v
|
|
1005 retrieving revision 1.1.1.1.2.1
|
|
1006 retrieving revision 1.12
|
|
1007 diff -u -r1.1.1.1.2.1 -r1.12
|
|
1008 --- Makefile.in 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1
|
|
1009 +++ Makefile.in 21 Nov 2004 18:19:28 -0000 1.12
|
|
1010 @@ -11,6 +11,7 @@
|
|
1011 CFLAGS=@CFLAGS@ -I.
|
|
1012 EXEEXT=@EXEEXT@
|
|
1013
|
|
1014 +LIBS= @LIBS@
|
|
1015 OBJS= ccache.o mdfour.o hash.o execute.o util.o args.o stats.o \
|
|
1016 cleanup.o snprintf.o unify.o
|
|
1017 HEADERS = ccache.h mdfour.h
|
|
1018 @@ -20,7 +21,7 @@
|
|
1019 docs: ccache.1 web/ccache-man.html
|
|
1020
|
|
1021 ccache$(EXEEXT): $(OBJS) $(HEADERS)
|
|
1022 - $(CC) $(CFLAGS) -o $@ $(OBJS)
|
|
1023 + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS)
|
|
1024
|
|
1025 ccache.1: ccache.yo
|
|
1026 -yodl2man -o ccache.1 ccache.yo
|