So much for my evil optimization. Doesn't seem to work. Will test

more on it later.
 -Erik
This commit is contained in:
Erik Andersen 2000-05-13 00:28:25 +00:00
parent 7ab9c7ee52
commit 23dea9b712
2 changed files with 74 additions and 11 deletions

View File

@ -59,6 +59,17 @@ else
#Only staticly link when _not_ debugging #Only staticly link when _not_ debugging
ifeq ($(DOSTATIC),true) ifeq ($(DOSTATIC),true)
LDFLAGS += --static LDFLAGS += --static
#
#use '-ffunction-sections -fdata-sections' and '--gc-sections' if they work
#to try and strip out any unused junk. Doesn't do much for me, but you may
#want to give it a shot...
#
#ifeq ($(shell $(CC) -ffunction-sections -fdata-sections -S \
# -o /dev/null -xc /dev/null && $(LD) --gc-sections -v >/dev/null && echo 1),1)
# CFLAGS += -ffunction-sections -fdata-sections -DFUNCTION_SECTIONS
# LDFLAGS += --gc-sections
#endif
#
endif endif
endif endif
@ -74,13 +85,6 @@ ifdef BB_INIT_SCRIPT
CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"' CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
endif endif
# use '-ffunction-sections -fdata-sections' and '--gc-sections' if they work
ifeq ($(shell $(CC) -ffunction-sections -fdata-sections -S \
-o /dev/null -xc /dev/null && $(LD) --gc-sections -v >/dev/null && echo 1),1)
CFLAGS += -ffunction-sections -fdata-sections -DFUNCTION_SECTIONS
LDFLAGS += --gc-sections
endif
all: busybox busybox.links doc all: busybox busybox.links doc
doc: docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html doc: docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html

View File

@ -112,6 +112,7 @@ extern void fatalError(const char *s, ...)
exit( FALSE); exit( FALSE);
} }
#if defined BB_INIT
/* Returns kernel version encoded as major*65536 + minor*256 + patch, /* Returns kernel version encoded as major*65536 + minor*256 + patch,
* so, for example, to check if the kernel is greater than 2.2.11: * so, for example, to check if the kernel is greater than 2.2.11:
* if (get_kernel_revision() <= 2*65536+2*256+11) { <stuff> } * if (get_kernel_revision() <= 2*65536+2*256+11) { <stuff> }
@ -128,7 +129,9 @@ extern int get_kernel_revision(void)
sscanf(name.version, "%d.%d.%d", &major, &minor, &patch); sscanf(name.version, "%d.%d.%d", &major, &minor, &patch);
return major * 65536 + minor * 256 + patch; return major * 65536 + minor * 256 + patch;
} }
#endif /* BB_INIT */
#if defined (BB_CP_MV) || defined (BB_DU)
#define HASH_SIZE 311 /* Should be prime */ #define HASH_SIZE 311 /* Should be prime */
#define hash_inode(i) ((i) % HASH_SIZE) #define hash_inode(i) ((i) % HASH_SIZE)
@ -195,7 +198,9 @@ void reset_ino_dev_hashtable(void)
} }
} }
#endif /* BB_CP_MV || BB_DU */
#if defined (BB_CP_MV) || defined (BB_DU) || defined (BB_LN)
/* /*
* Return TRUE if a fileName is a directory. * Return TRUE if a fileName is a directory.
* Nonexistant files return FALSE. * Nonexistant files return FALSE.
@ -226,7 +231,9 @@ int isDirectory(const char *fileName, const int followLinks, struct stat *statBu
} }
return status; return status;
} }
#endif
#if defined (BB_CP_MV)
/* /*
* Copy one file to another, while possibly preserving its modes, times, and * Copy one file to another, while possibly preserving its modes, times, and
* modes. Returns TRUE if successful, or FALSE on a failure with an error * modes. Returns TRUE if successful, or FALSE on a failure with an error
@ -376,9 +383,12 @@ copyFile(const char *srcName, const char *destName,
return FALSE; return FALSE;
} }
#endif /* BB_CP_MV */
#if defined BB_TAR || defined BB_LS
#define TYPEINDEX(mode) (((mode) >> 12) & 0x0f) #define TYPEINDEX(mode) (((mode) >> 12) & 0x0f)
#define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)]) #define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)])
@ -420,8 +430,10 @@ const char *modeString(int mode)
} }
return buf; return buf;
} }
#endif /* BB_TAR || BB_LS */
#if defined BB_TAR
/* /*
* Return the standard ls-like time string from a time_t * Return the standard ls-like time string from a time_t
* This is static and so is overwritten on each call. * This is static and so is overwritten on each call.
@ -446,7 +458,9 @@ const char *timeString(time_t timeVal)
return buf; return buf;
} }
#endif /* BB_TAR */
#if defined BB_TAR || defined BB_CP_MV
/* /*
* Write all of the supplied buffer out to a file. * Write all of the supplied buffer out to a file.
* This does multiple writes as necessary. * This does multiple writes as necessary.
@ -472,8 +486,10 @@ int fullWrite(int fd, const char *buf, int len)
return total; return total;
} }
#endif /* BB_TAR || BB_CP_MV */
#if defined BB_TAR || defined BB_TAIL
/* /*
* Read all of the supplied buffer from a file. * Read all of the supplied buffer from a file.
* This does multiple reads as necessary. * This does multiple reads as necessary.
@ -503,8 +519,16 @@ int fullRead(int fd, char *buf, int len)
return total; return total;
} }
#endif /* BB_TAR || BB_TAIL */
#if defined (BB_CHMOD_CHOWN_CHGRP) \
|| defined (BB_CP_MV) \
|| defined (BB_FIND) \
|| defined (BB_INSMOD) \
|| defined (BB_RM) \
|| defined (BB_TAR)
/* /*
* Walk down all the directories under the specified * Walk down all the directories under the specified
* location, and do something (something specified * location, and do something (something specified
@ -617,9 +641,11 @@ int recursiveAction(const char *fileName,
return TRUE; return TRUE;
} }
#endif /* BB_CHMOD_CHOWN_CHGRP || BB_CP_MV || BB_FIND || BB_LS || BB_INSMOD */
#if defined (BB_TAR) || defined (BB_MKDIR)
/* /*
* Attempt to create the directories along the specified path, except for * Attempt to create the directories along the specified path, except for
* the final component. The mode is given for the final directory only, * the final component. The mode is given for the final directory only,
@ -649,10 +675,15 @@ extern int createPath(const char *name, int mode)
} }
return TRUE; return TRUE;
} }
#endif /* BB_TAR || BB_MKDIR */
#if defined (BB_CHMOD_CHOWN_CHGRP) || defined (BB_MKDIR)
/* [ugoa]{+|-|=}[rwxst] */ /* [ugoa]{+|-|=}[rwxst] */
extern int parse_mode(const char *s, mode_t * theMode) extern int parse_mode(const char *s, mode_t * theMode)
{ {
mode_t andMode = mode_t andMode =
@ -745,9 +776,14 @@ extern int parse_mode(const char *s, mode_t * theMode)
} }
#endif /* BB_CHMOD_CHOWN_CHGRP || BB_MKDIR */
#if defined BB_CHMOD_CHOWN_CHGRP || defined BB_PS || defined BB_LS || defined BB_TAR || defined BB_ID
/* This parses entries in /etc/passwd and /etc/group. This is desirable /* This parses entries in /etc/passwd and /etc/group. This is desirable
* for BusyBox, since we want to avoid using the glibc NSS stuff, which * for BusyBox, since we want to avoid using the glibc NSS stuff, which
* increases target size and is often not needed or wanted for embedded * increases target size and is often not needed or wanted for embedded
@ -852,6 +888,10 @@ gid_t my_getpwnamegid(char *name)
return gid; return gid;
} }
#endif /* BB_CHMOD_CHOWN_CHGRP || BB_PS || BB_LS || BB_TAR || BB_ID */
#if (defined BB_CHVT) || (defined BB_DEALLOCVT)
#include <linux/kd.h> #include <linux/kd.h>
@ -936,9 +976,11 @@ int get_console_fd(char *tty_name)
} }
#endif /* BB_CHVT || BB_DEALLOCVT */
#if !defined BB_REGEXP #if !defined BB_REGEXP && (defined BB_GREP || defined BB_SED)
/* Do a case insensitive strstr() */ /* Do a case insensitive strstr() */
char *stristr(char *haystack, const char *needle) char *stristr(char *haystack, const char *needle)
{ {
@ -1009,9 +1051,11 @@ extern int replace_match(char *haystack, char *needle, char *newNeedle,
else else
return FALSE; return FALSE;
} }
#endif /* ! BB_REGEXP */
#endif /* ! BB_REGEXP && (BB_GREP || BB_SED) */
#if defined BB_FIND
/* /*
* Routine to see if a text string is matched by a wildcard pattern. * Routine to see if a text string is matched by a wildcard pattern.
* Returns TRUE if the text is matched, or FALSE if it is not matched * Returns TRUE if the text is matched, or FALSE if it is not matched
@ -1111,10 +1155,12 @@ extern int check_wildcard_match(const char *text, const char *pattern)
return TRUE; return TRUE;
} }
#endif /* BB_FIND */
#if defined BB_DF || defined BB_MTAB
/* /*
* Given a block device, find the mount table entry if that block device * Given a block device, find the mount table entry if that block device
* is mounted. * is mounted.
@ -1153,9 +1199,11 @@ extern struct mntent *findMountPoint(const char *name, const char *table)
endmntent(mountTable); endmntent(mountTable);
return mountEntry; return mountEntry;
} }
#endif /* BB_DF || BB_MTAB */
#if defined BB_DD || defined BB_TAIL
/* /*
* Read a number with a possible multiplier. * Read a number with a possible multiplier.
* Returns -1 if the number format is illegal. * Returns -1 if the number format is illegal.
@ -1202,8 +1250,10 @@ extern long getNum(const char *cp)
return value; return value;
} }
#endif /* BB_DD || BB_TAIL */
#if defined BB_INIT || defined BB_SYSLOGD
/* try to open up the specified device */ /* try to open up the specified device */
extern int device_open(char *device, int mode) extern int device_open(char *device, int mode)
{ {
@ -1222,11 +1272,15 @@ extern int device_open(char *device, int mode)
fcntl(fd, F_SETFL, mode); fcntl(fd, F_SETFL, mode);
return fd; return fd;
} }
#endif /* BB_INIT BB_SYSLOGD */
#if defined BB_KILLALL || ( defined BB_FEATURE_LINUXRC && ( defined BB_HALT || defined BB_REBOOT || defined BB_POWEROFF ))
#ifdef BB_FEATURE_USE_DEVPS_PATCH #ifdef BB_FEATURE_USE_DEVPS_PATCH
#include <linux/devps.h> #include <linux/devps.h>
#endif
#if defined BB_FEATURE_USE_DEVPS_PATCH
/* findPidByName() /* findPidByName()
* *
* This finds the pid of the specified process, * This finds the pid of the specified process,
@ -1365,6 +1419,7 @@ extern pid_t* findPidByName( char* pidName)
return pidList; return pidList;
} }
#endif /* BB_FEATURE_USE_DEVPS_PATCH */ #endif /* BB_FEATURE_USE_DEVPS_PATCH */
#endif /* BB_KILLALL || ( BB_FEATURE_LINUXRC && ( BB_HALT || BB_REBOOT || BB_POWEROFF )) */
/* this should really be farmed out to libbusybox.a */ /* this should really be farmed out to libbusybox.a */
extern void *xmalloc(size_t size) extern void *xmalloc(size_t size)
@ -1376,7 +1431,7 @@ extern void *xmalloc(size_t size)
return cp; return cp;
} }
#if (__GLIBC__ < 2) #if (__GLIBC__ < 2) && (defined BB_SYSLOGD || defined BB_INIT)
extern int vdprintf(int d, const char *format, va_list ap) extern int vdprintf(int d, const char *format, va_list ap)
{ {
char buf[BUF_SIZE]; char buf[BUF_SIZE];
@ -1385,8 +1440,9 @@ extern int vdprintf(int d, const char *format, va_list ap)
len = vsprintf(buf, format, ap); len = vsprintf(buf, format, ap);
return write(d, buf, len); return write(d, buf, len);
} }
#endif #endif /* BB_SYSLOGD */
#if defined BB_FEATURE_MOUNT_LOOP
extern int del_loop(const char *device) extern int del_loop(const char *device)
{ {
int fd; int fd;
@ -1470,7 +1526,9 @@ extern char *find_unused_loop_device(void)
} }
return NULL; return NULL;
} }
#endif /* BB_FEATURE_MOUNT_LOOP */
#if defined BB_MOUNT || defined BB_DF || ( defined BB_UMOUNT && ! defined BB_MTAB)
extern int find_real_root_device_name(char* name) extern int find_real_root_device_name(char* name)
{ {
DIR *dir; DIR *dir;
@ -1512,6 +1570,7 @@ extern int find_real_root_device_name(char* name)
return( FALSE); return( FALSE);
} }
#endif
const unsigned int CSTRING_BUFFER_LENGTH = 128; const unsigned int CSTRING_BUFFER_LENGTH = 128;
/* recursive parser that returns cstrings of arbitrary length /* recursive parser that returns cstrings of arbitrary length