aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-06-22 03:00:21 +0000
committerEric Andersen <andersen@codepoet.org>2001-06-22 03:00:21 +0000
commit30f1eafaaa16c8223a3b5c38436918418a79fea2 (patch)
tree8f1a6c2a69cc880a7a15c35ab426359ad53f5f61
parent6b03504441079ba23318316f6147cc55fc0d0dd9 (diff)
downloadbusybox-w32-30f1eafaaa16c8223a3b5c38436918418a79fea2.tar.gz
busybox-w32-30f1eafaaa16c8223a3b5c38436918418a79fea2.tar.bz2
busybox-w32-30f1eafaaa16c8223a3b5c38436918418a79fea2.zip
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
-rw-r--r--Makefile13
-rw-r--r--libbb/unarchive.c25
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 \
246my_getpwuid.c parse_mode.c parse_number.c perror_msg.c perror_msg_and_die.c \ 246my_getpwuid.c parse_mode.c parse_number.c perror_msg.c perror_msg_and_die.c \
247print_file.c process_escape_sequence.c read_package_field.c recursive_action.c \ 247print_file.c process_escape_sequence.c read_package_field.c recursive_action.c \
248safe_read.c safe_strncpy.c syscalls.c syslog_msg_with_name.c time_string.c \ 248safe_read.c safe_strncpy.c syscalls.c syslog_msg_with_name.c time_string.c \
249trim.c unarchive.c unzip.c vdprintf.c verror_msg.c vperror_msg.c wfopen.c xfuncs.c \ 249trim.c unzip.c vdprintf.c verror_msg.c vperror_msg.c wfopen.c xfuncs.c \
250xgetcwd.c xreadlink.c xregcomp.c interface.c remove_file.c last_char_is.c \ 250xgetcwd.c xreadlink.c xregcomp.c interface.c remove_file.c last_char_is.c \
251copyfd.c vherror_msg.c herror_msg.c herror_msg_and_die.c xgethostbyname.c \ 251copyfd.c vherror_msg.c herror_msg.c herror_msg_and_die.c xgethostbyname.c \
252dirname.c make_directory.c strdup_substr.c 252dirname.c make_directory.c strdup_substr.c
@@ -262,6 +262,11 @@ memory_exhausted invalid_date invalid_option io_error dash_dash_help \
262write_error too_few_args name_longer_than_foo unknown 262write_error too_few_args name_longer_than_foo unknown
263LIBBB_MOBJ=$(patsubst %,$(LIBBB)/%.o, $(LIBBB_MESSAGES)) 263LIBBB_MOBJ=$(patsubst %,$(LIBBB)/%.o, $(LIBBB_MESSAGES))
264 264
265LIBBB_ARCSRC=libbb/unarchive.c
266LIBBB_ARCOBJ= archive_offset seek_sub_file extract_archive unarchive \
267get_header_ar get_header_cpio get_header_tar deb_extract
268LIBBB_AROBJS=$(patsubst %,$(LIBBB)/%.o, $(LIBBB_ARCOBJ))
269
265 270
266# Put user-supplied flags at the end, where they 271# Put user-supplied flags at the end, where they
267# have a chance of winning. 272# have a chance of winning.
@@ -365,10 +370,14 @@ $(LIBBB_MOBJ): $(LIBBB_MSRC)
365 - mkdir -p $(LIBBB) 370 - mkdir -p $(LIBBB)
366 $(CC) $(CFLAGS) $(LIBBB_CFLAGS) -DL_$(patsubst libbb/%,%,$*) -c $< -o $*.o 371 $(CC) $(CFLAGS) $(LIBBB_CFLAGS) -DL_$(patsubst libbb/%,%,$*) -c $< -o $*.o
367 372
373$(LIBBB_AROBJS): $(LIBBB_ARCSRC)
374 - mkdir -p $(LIBBB)
375 $(CC) $(CFLAGS) $(LIBBB_CFLAGS) -DL_$(patsubst libbb/%,%,$*) -c $< -o $*.o
376
368libpwd.a: $(PWD_OBJS) 377libpwd.a: $(PWD_OBJS)
369 $(AR) $(ARFLAGS) $@ $^ 378 $(AR) $(ARFLAGS) $@ $^
370 379
371libbb.a: $(LIBBB_MOBJ) $(LIBBB_OBJS) 380libbb.a: $(LIBBB_MOBJ) $(LIBBB_AROBJS) $(LIBBB_OBJS)
372 $(AR) $(ARFLAGS) $@ $^ 381 $(AR) $(ARFLAGS) $@ $^
373 382
374usage.o: usage.h 383usage.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 {
38 dev_t device; 38 dev_t device;
39} file_header_t; 39} file_header_t;
40 40
41
42extern void seek_sub_file(FILE *src_stream, const int count);
43extern char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *file_entry,
44 const int function, const char *prefix);
45
46
47#ifdef L_archive_offset
41off_t archive_offset; 48off_t archive_offset;
49#else
50extern off_t archive_offset;
51#endif
42 52
53#ifdef L_seek_sub_file
43void seek_sub_file(FILE *src_stream, const int count) 54void seek_sub_file(FILE *src_stream, const int count)
44{ 55{
45 int i; 56 int i;
@@ -52,8 +63,11 @@ void seek_sub_file(FILE *src_stream, const int count)
52 } 63 }
53 return; 64 return;
54} 65}
66#endif
55 67
56 68
69
70#ifdef L_extract_archive
57/* Extract the data postioned at src_stream to either filesystem, stdout or 71/* Extract the data postioned at src_stream to either filesystem, stdout or
58 * buffer depending on the value of 'function' which is defined in libbb.h 72 * buffer depending on the value of 'function' which is defined in libbb.h
59 * 73 *
@@ -202,7 +216,9 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f
202 216
203 return(NULL); /* Maybe we should say if failed */ 217 return(NULL); /* Maybe we should say if failed */
204} 218}
219#endif
205 220
221#ifdef L_unarchive
206char *unarchive(FILE *src_stream, void *(*get_headers)(FILE *), 222char *unarchive(FILE *src_stream, void *(*get_headers)(FILE *),
207 const int extract_function, const char *prefix, char **extract_names) 223 const int extract_function, const char *prefix, char **extract_names)
208{ 224{
@@ -233,8 +249,9 @@ char *unarchive(FILE *src_stream, void *(*get_headers)(FILE *),
233 } 249 }
234 return(buffer); 250 return(buffer);
235} 251}
252#endif
236 253
237#if defined BB_AR || defined BB_DPKG_DEB || defined BB_DPKG 254#ifdef L_get_header_ar
238void *get_header_ar(FILE *src_stream) 255void *get_header_ar(FILE *src_stream)
239{ 256{
240 file_header_t *typed; 257 file_header_t *typed;
@@ -317,7 +334,7 @@ void *get_header_ar(FILE *src_stream)
317} 334}
318#endif 335#endif
319 336
320#if defined BB_CPIO 337#ifdef L_get_header_cpio
321void *get_header_cpio(FILE *src_stream) 338void *get_header_cpio(FILE *src_stream)
322{ 339{
323 file_header_t *cpio_entry = NULL; 340 file_header_t *cpio_entry = NULL;
@@ -378,7 +395,7 @@ void *get_header_cpio(FILE *src_stream)
378} 395}
379#endif 396#endif
380 397
381#if defined BB_UNTAR || defined BB_DPKG_DEB || defined BB_DPKG 398#ifdef L_get_header_tar
382void *get_header_tar(FILE *tar_stream) 399void *get_header_tar(FILE *tar_stream)
383{ 400{
384 union { 401 union {
@@ -455,7 +472,7 @@ void *get_header_tar(FILE *tar_stream)
455} 472}
456#endif 473#endif
457 474
458#if defined BB_DPKG || defined BB_DPKG_DEB 475#ifdef L_deb_extract
459char *deb_extract(const char *package_filename, FILE *out_stream, const int extract_function, 476char *deb_extract(const char *package_filename, FILE *out_stream, const int extract_function,
460 const char *prefix, const char *filename) 477 const char *prefix, const char *filename)
461{ 478{