From 30f1eafaaa16c8223a3b5c38436918418a79fea2 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Fri, 22 Jun 2001 03:00:21 +0000 Subject: [PATCH] Fix the build process so it does not do the evil #ifdef BB_FOO stuff. Build exactly one .o file per function, and let the linker throw away the junk it doesn't want. -Erik --- Makefile | 13 +++++++++++-- libbb/unarchive.c | 25 +++++++++++++++++++++---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 89d56d50c..0474d17e3 100644 --- a/Makefile +++ b/Makefile @@ -246,7 +246,7 @@ mtab_file.c my_getgrnam.c my_getgrgid.c my_getpwnam.c my_getpwnamegid.c \ my_getpwuid.c parse_mode.c parse_number.c perror_msg.c perror_msg_and_die.c \ print_file.c process_escape_sequence.c read_package_field.c recursive_action.c \ safe_read.c safe_strncpy.c syscalls.c syslog_msg_with_name.c time_string.c \ -trim.c unarchive.c unzip.c vdprintf.c verror_msg.c vperror_msg.c wfopen.c xfuncs.c \ +trim.c unzip.c vdprintf.c verror_msg.c vperror_msg.c wfopen.c xfuncs.c \ xgetcwd.c xreadlink.c xregcomp.c interface.c remove_file.c last_char_is.c \ copyfd.c vherror_msg.c herror_msg.c herror_msg_and_die.c xgethostbyname.c \ dirname.c make_directory.c strdup_substr.c @@ -262,6 +262,11 @@ memory_exhausted invalid_date invalid_option io_error dash_dash_help \ write_error too_few_args name_longer_than_foo unknown LIBBB_MOBJ=$(patsubst %,$(LIBBB)/%.o, $(LIBBB_MESSAGES)) +LIBBB_ARCSRC=libbb/unarchive.c +LIBBB_ARCOBJ= archive_offset seek_sub_file extract_archive unarchive \ +get_header_ar get_header_cpio get_header_tar deb_extract +LIBBB_AROBJS=$(patsubst %,$(LIBBB)/%.o, $(LIBBB_ARCOBJ)) + # Put user-supplied flags at the end, where they # have a chance of winning. @@ -365,10 +370,14 @@ $(LIBBB_MOBJ): $(LIBBB_MSRC) - mkdir -p $(LIBBB) $(CC) $(CFLAGS) $(LIBBB_CFLAGS) -DL_$(patsubst libbb/%,%,$*) -c $< -o $*.o +$(LIBBB_AROBJS): $(LIBBB_ARCSRC) + - mkdir -p $(LIBBB) + $(CC) $(CFLAGS) $(LIBBB_CFLAGS) -DL_$(patsubst libbb/%,%,$*) -c $< -o $*.o + libpwd.a: $(PWD_OBJS) $(AR) $(ARFLAGS) $@ $^ -libbb.a: $(LIBBB_MOBJ) $(LIBBB_OBJS) +libbb.a: $(LIBBB_MOBJ) $(LIBBB_AROBJS) $(LIBBB_OBJS) $(AR) $(ARFLAGS) $@ $^ usage.o: usage.h diff --git a/libbb/unarchive.c b/libbb/unarchive.c index 199123ec4..635dcae35 100644 --- a/libbb/unarchive.c +++ b/libbb/unarchive.c @@ -38,8 +38,19 @@ typedef struct file_headers_s { dev_t device; } file_header_t; + +extern void seek_sub_file(FILE *src_stream, const int count); +extern char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *file_entry, + const int function, const char *prefix); + + +#ifdef L_archive_offset off_t archive_offset; +#else +extern off_t archive_offset; +#endif +#ifdef L_seek_sub_file void seek_sub_file(FILE *src_stream, const int count) { int i; @@ -52,8 +63,11 @@ void seek_sub_file(FILE *src_stream, const int count) } return; } +#endif + +#ifdef L_extract_archive /* Extract the data postioned at src_stream to either filesystem, stdout or * buffer depending on the value of 'function' which is defined in libbb.h * @@ -202,7 +216,9 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f return(NULL); /* Maybe we should say if failed */ } +#endif +#ifdef L_unarchive char *unarchive(FILE *src_stream, void *(*get_headers)(FILE *), const int extract_function, const char *prefix, char **extract_names) { @@ -233,8 +249,9 @@ char *unarchive(FILE *src_stream, void *(*get_headers)(FILE *), } return(buffer); } +#endif -#if defined BB_AR || defined BB_DPKG_DEB || defined BB_DPKG +#ifdef L_get_header_ar void *get_header_ar(FILE *src_stream) { file_header_t *typed; @@ -317,7 +334,7 @@ void *get_header_ar(FILE *src_stream) } #endif -#if defined BB_CPIO +#ifdef L_get_header_cpio void *get_header_cpio(FILE *src_stream) { file_header_t *cpio_entry = NULL; @@ -378,7 +395,7 @@ void *get_header_cpio(FILE *src_stream) } #endif -#if defined BB_UNTAR || defined BB_DPKG_DEB || defined BB_DPKG +#ifdef L_get_header_tar void *get_header_tar(FILE *tar_stream) { union { @@ -455,7 +472,7 @@ void *get_header_tar(FILE *tar_stream) } #endif -#if defined BB_DPKG || defined BB_DPKG_DEB +#ifdef L_deb_extract char *deb_extract(const char *package_filename, FILE *out_stream, const int extract_function, const char *prefix, const char *filename) { -- 2.25.1