[uClibc] PATCH: ldconfig w/o LDSO_CONF/CACHE
Peter S. Mazinger
ps.m at gmx.net
Tue Oct 12 15:00:36 UTC 2004
Hello!
The attached makes it possible to build ldconfig w/o cache and makes
ldconfig 3,5 kB smaller (the dl-defs.h changes can be undone)
Peter
--
Peter S. Mazinger <ps dot m at gmx dot net> ID: 0xA5F059F2
Key fingerprint = 92A4 31E1 56BC 3D5A 2D08 BB6E C389 975E A5F0 59F2
____________________________________________________________________
Miert fizetsz az internetert? Korlatlan, ingyenes internet hozzaferes a FreeStarttol.
Probald ki most! http://www.freestart.hu
-------------- next part --------------
--- utils/ldconfig.c.mps 2004-10-12 15:03:43.000000000 +0200
+++ utils/ldconfig.c 2004-10-12 16:01:39.000000000 +0200
@@ -87,14 +87,18 @@
int debug = 0; /* debug mode */
int verbose = 0; /* verbose mode */
int libmode = 0; /* library mode */
+#ifdef __LDSO_CACHE_SUPPORT__
int nocache = 0; /* don't build cache */
+#endif
int nolinks = 0; /* don't update links */
+#ifdef __LDSO_CACHE_SUPPORT__
char *conffile = LDSO_CONF; /* default conf file */
char *cachefile = LDSO_CACHE; /* default cache file */
void cache_print(void);
void cache_dolib(const char *dir, const char *so, int libtype);
void cache_write(void);
+#endif
/* These two are used internally -- you shouldn't need to use them */
static void verror_msg(const char *s, va_list p)
@@ -523,6 +527,7 @@
return;
}
+#ifdef __LDSO_CACHE_SUPPORT__
/* return the list of system-specific directories */
char *get_extpath(void)
{
@@ -552,6 +557,7 @@
return res;
}
+#endif
#ifdef __LDSO_CACHE_SUPPORT__
typedef struct liblist
@@ -716,34 +722,43 @@
munmap (c,st.st_size);
}
-#else
-void cache_print(void)
-{
- warnx("Cache support disabled\n");
-}
#endif
void usage(void)
{
fprintf(stderr,
- "ldconfig - updates symlinks for shared libraries\n\n"
+#ifdef __LDSO_CACHE_SUPPORT__
+ "ldconfig - updates symlinks and cache for shared libraries\n\n"
"Usage: ldconfig [-DvqnNX] [-f conf] [-C cache] [-r root] dir ...\n"
" ldconfig -l [-Dv] lib ...\n"
" ldconfig -p\n\nOptions:\n"
+#else
+ "ldconfig - updates symlinks for shared libraries\n\n"
+ "Usage: ldconfig [-DvqnX] [-r root] dir ...\n"
+ " ldconfig -l [-Dv] lib ...\n\nOptions:\n"
+#endif
"\t-D:\t\tdebug mode, don't update links\n"
"\t-v:\t\tverbose mode, print things as we go\n"
"\t-q:\t\tquiet mode, don't print warnings\n"
"\t-n:\t\tdon't process standard directories\n"
+#ifdef __LDSO_CACHE_SUPPORT__
"\t-N:\t\tdon't update the library cache\n"
+#endif
"\t-X:\t\tdon't update the library links\n"
"\t-l:\t\tlibrary mode, manually link libraries\n"
+#ifdef __LDSO_CACHE_SUPPORT__
"\t-p:\t\tprint the current library cache\n"
"\t-f conf :\tuse conf instead of %s\n"
"\t-C cache:\tuse cache instead of %s\n"
+#endif
"\t-r root :\tfirst, do a chroot to the indicated directory\n"
"\tdir ... :\tdirectories to process\n"
+#ifdef __LDSO_CACHE_SUPPORT__
"\tlib ... :\tlibraries to link\n\n",
LDSO_CONF, LDSO_CACHE
+#else
+ "\tlib ... :\tlibraries to link\n\n"
+#endif
);
exit(EXIT_FATAL);
}
@@ -753,21 +768,31 @@
{
int i, c;
int nodefault = 0;
+#ifdef __LDSO_CACHE_SUPPORT__
int printcache = 0;
+#endif
char *cp, *dir, *so;
+#ifdef __LDSO_CACHE_SUPPORT__
char *extpath;
+#endif
int libtype, islink;
char *chroot_dir = NULL;
prog = argv[0];
opterr = 0;
+#ifdef __LDSO_CACHE_SUPPORT__
while ((c = getopt(argc, argv, "DvqnNXlpf:C:r:")) != EOF)
+#else
+ while ((c = getopt(argc, argv, "DvqnXl:r:")) != EOF)
+#endif
switch (c)
{
case 'D':
debug = 1; /* debug mode */
+#ifdef __LDSO_CACHE_SUPPORT__
nocache = 1;
+#endif
nolinks = 1;
verbose = 1;
break;
@@ -780,17 +805,22 @@
break;
case 'n':
nodefault = 1; /* no default dirs */
+#ifdef __LDSO_CACHE_SUPPORT__
nocache = 1;
+#endif
break;
+#ifdef __LDSO_CACHE_SUPPORT__
case 'N':
nocache = 1; /* don't build cache */
break;
+#endif
case 'X':
nolinks = 1; /* don't update links */
break;
case 'l':
libmode = 1; /* library mode */
break;
+#ifdef __LDSO_CACHE_SUPPORT__
case 'p':
printcache = 1; /* print cache */
break;
@@ -800,6 +830,7 @@
case 'C':
cachefile = optarg; /* alternate cache file */
break;
+#endif
case 'r':
chroot_dir = optarg;
break;
@@ -822,6 +853,7 @@
if (verbose > 0)
printf("%s: uClibc version\n", argv[0]);
+#ifdef __LDSO_CACHE_SUPPORT__
if (printcache)
{
/* print the cache -- don't you trust me? */
@@ -829,6 +861,9 @@
exit(EXIT_OK);
}
else if (libmode)
+#else
+ if (libmode)
+#endif
{
/* so you want to do things manually, eh? */
@@ -863,16 +898,20 @@
{
/* the lazy bum want's us to do all the work for him */
+#ifdef __LDSO_CACHE_SUPPORT__
/* don't cache dirs on the command line */
int nocache_save = nocache;
nocache = 1;
+#endif
/* OK, which directories should we do? */
for (i = optind; i < argc; i++)
scan_dir(argv[i]);
+#ifdef __LDSO_CACHE_SUPPORT__
/* restore the desired caching state */
nocache = nocache_save;
+#endif
/* look ma, no defaults */
if (!nodefault)
@@ -881,8 +920,7 @@
scan_dir(UCLIBC_RUNTIME_PREFIX "usr/lib");
#ifndef __LDSO_CACHE_SUPPORT__
scan_dir(UCLIBC_RUNTIME_PREFIX "usr/X11R6/lib");
-#endif
-
+#else
/* I guess the defaults aren't good enough */
if ((extpath = get_extpath()))
{
@@ -893,18 +931,17 @@
while (cp[--len] == '/' && len)
cp[len] = 0;
/* we do the redundancy check only if cache usage is enabled */
-#ifdef __LDSO_CACHE_SUPPORT__
if (strcmp(UCLIBC_RUNTIME_PREFIX "lib", cp) == 0 ||
strcmp(UCLIBC_RUNTIME_PREFIX "usr/lib", cp) == 0) {
if (verbose >= 0)
warnx("Remove `%s' from `%s'\n", cp, LDSO_CONF);
continue;
}
-#endif
scan_dir(cp);
}
free(extpath);
}
+#endif
}
#ifdef __LDSO_CACHE_SUPPORT__
More information about the uClibc
mailing list