Index: busybox/scripts/bb_mkdep.c =================================================================== --- busybox/scripts/bb_mkdep.c (revision 15159) +++ busybox/scripts/bb_mkdep.c (working copy) @@ -69,10 +69,19 @@ #include #include +#ifdef __GNUC__ +#define ATTRIBUTE __attribute__ +#else +#define ATTRIBUTE(a) /* nothing */ +#endif +#if !(defined __USE_ISOC99 || (defined __GLIBC_HAVE_LONG_LONG && defined __USE_MISC)) +#define strtoll strtol +#endif + /* partial and simplified libbb routine */ -static void bb_error_d(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); -static char * bb_asprint(const char *format, ...) __attribute__ ((format (printf, 1, 2))); +static void bb_error_d(const char *s, ...) ATTRIBUTE ((noreturn, format (printf, 1, 2))); +static char * bb_asprint(const char *format, ...) ATTRIBUTE ((format (printf, 1, 2))); static char *bb_simplify_path(const char *path); /* stolen from libbb as is */ @@ -1598,7 +1607,7 @@ } } -static void show_usage(void) __attribute__ ((noreturn)); +static void show_usage(void) ATTRIBUTE ((noreturn)); static void show_usage(void) { bb_error_d("%s\n%s\n", bb_mkdep_terse_options, bb_mkdep_full_options); @@ -1720,9 +1729,16 @@ int r; char *out; +#ifdef __USE_GNU va_start(p, format); r = vasprintf(&out, format, p); va_end(p); +#else + out = xmalloc(BUFSIZ); + va_start(p, format); + r = vsprintf(out, format, p); + va_end(p); +#endif if (r < 0) bb_error_d("bb_asprint: %m"); Index: busybox/scripts/config/bool.h =================================================================== --- busybox/scripts/config/bool.h (revision 0) +++ busybox/scripts/config/bool.h (revision 0) @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2002 Roman Zippel + * Released under the terms of the GNU GPL v2.0. + */ + +#ifndef __BOOL_H +#define __BOOL_H + +#if !defined HAVE_STDBOOL_H && defined __GNUC__ +#define HAVE_STDBOOL_H 1 +#endif +#ifndef HAVE_STDBOOL_H +typedef char bool; +# if !defined true +# undef true +# define true 1 +# endif +# if !defined false +# undef false +# define false 0 +# endif +#endif +#endif /* __BOOL_H */ Index: busybox/scripts/config/zconf.tab.c_shipped =================================================================== --- busybox/scripts/config/zconf.tab.c_shipped (revision 15159) +++ busybox/scripts/config/zconf.tab.c_shipped (working copy) @@ -159,7 +159,13 @@ #include #include #include -#include +#if !defined __cplusplus +# if defined __GNUC__ || defined HAVE_STDBOOL_H +# include +# else +# include "bool.h" +# endif +#endif #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) Index: busybox/scripts/config/zconf.y =================================================================== --- busybox/scripts/config/zconf.y (revision 15159) +++ busybox/scripts/config/zconf.y (working copy) @@ -9,7 +9,13 @@ #include #include #include -#include +#if !defined __cplusplus +# if defined __GNUC__ || defined HAVE_STDBOOL_H +# include +# else +# include "bool.h" +# endif +#endif #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) Index: busybox/scripts/config/lkc.h =================================================================== --- busybox/scripts/config/lkc.h (revision 15159) +++ busybox/scripts/config/lkc.h (working copy) @@ -6,6 +6,21 @@ #ifndef LKC_H #define LKC_H +#if !defined HAVE_STDBOOL_H && defined __GNUC__ +#define HAVE_STDBOOL_H 1 +#endif +#ifndef HAVE_STDBOOL_H +typedef char bool; +# if !defined true +# undef true +# define true 1 +# endif +# if !defined false +# undef false +# define false 0 +# endif +#endif + #include "expr.h" #ifdef __cplusplus Index: busybox/scripts/config/confdata.c =================================================================== --- busybox/scripts/config/confdata.c (revision 15159) +++ busybox/scripts/config/confdata.c (working copy) @@ -138,7 +138,11 @@ } break; - case 'A' ... 'Z': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': + case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': + case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': + case 'Y': case 'Z': p = strchr(line, '='); if (!p) continue; @@ -451,10 +455,10 @@ /* busybox`s code */ if (out_h) { fprintf(out_h, "#define ENABLE_%s %d\n", opt_name, use_flg); - fprintf(out_h, "#define USE_%s(...)%s\n", opt_name, - (use_flg ? " __VA_ARGS__" : "")); - fprintf(out_h, "#define SKIP_%s(...)%s\n\n", opt_name, - (use_flg ? "" : " __VA_ARGS__")); + fprintf(out_h, "#define USE_%s(a)%s\n", opt_name, + (use_flg ? " a" : "")); + fprintf(out_h, "#define SKIP_%s(a)%s\n\n", opt_name, + (use_flg ? "" : " a")); } /* end busybox`s code */ } Index: busybox/scripts/config/expr.h =================================================================== --- busybox/scripts/config/expr.h (revision 15159) +++ busybox/scripts/config/expr.h (working copy) @@ -11,10 +11,16 @@ #endif #include -#ifndef __cplusplus -#include + +#if !defined __cplusplus +# if defined HAVE_STDBOOL_H +# include +# else +# include "bool.h" +# endif #endif + struct file { struct file *next; struct file *parent; Index: busybox/networking/nslookup.c =================================================================== --- busybox/networking/nslookup.c (revision 15159) +++ busybox/networking/nslookup.c (working copy) @@ -30,7 +30,6 @@ #include #include -#include #include #include #include Index: busybox/networking/libiproute/rt_names.c =================================================================== --- busybox/networking/libiproute/rt_names.c (revision 15159) +++ busybox/networking/libiproute/rt_names.c (working copy) @@ -12,7 +12,6 @@ #include #include -#include #include "rt_names.h" static void rtnl_tab_initialize(char *file, char **tab, int size) Index: busybox/networking/libiproute/rt_names.h =================================================================== --- busybox/networking/libiproute/rt_names.h (revision 15159) +++ busybox/networking/libiproute/rt_names.h (working copy) @@ -1,8 +1,6 @@ #ifndef RT_NAMES_H_ #define RT_NAMES_H_ 1 -#include - extern const char* rtnl_rtprot_n2a(int id, char *buf, int len); extern const char* rtnl_rtscope_n2a(int id, char *buf, int len); extern const char* rtnl_dsfield_n2a(int id, char *buf, int len); Index: busybox/archival/libunarchive/rangecoder.h =================================================================== --- busybox/archival/libunarchive/rangecoder.h (revision 15159) +++ busybox/archival/libunarchive/rangecoder.h (working copy) @@ -1,39 +1,8 @@ -/* - * Small range coder implementation for lzma. - * Copyright (C) 2006 Aurelien Jacobs - * - * Based on LzmaDecode.c from the LZMA SDK 4.22 (http://www.7-zip.org/) - * Copyright (c) 1999-2005 Igor Pavlov - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include - #include "libbb.h" -#ifndef always_inline -# if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >0) -# define always_inline __attribute__((always_inline)) inline -# else -# define always_inline inline -# endif -#endif - #ifdef CONFIG_FEATURE_LZMA_FAST -# define speed_inline always_inline +# define speed_inline ATTRIBUTE_ALWAYS_INLINE #else # define speed_inline #endif @@ -67,7 +36,7 @@ } /* Called once */ -static always_inline void rc_init(rc_t * rc, int fd, int buffer_size) +static ATTRIBUTE_ALWAYS_INLINE void rc_init(rc_t * rc, int fd, int buffer_size) { int i; @@ -87,7 +56,7 @@ } /* Called once. TODO: bb_maybe_free() */ -static always_inline void rc_free(rc_t * rc) +static ATTRIBUTE_ALWAYS_INLINE void rc_free(rc_t * rc) { if (ENABLE_FEATURE_CLEAN_UP) free(rc->buffer); @@ -101,7 +70,7 @@ rc->range <<= 8; rc->code = (rc->code << 8) | *rc->ptr++; } -static always_inline void rc_normalize(rc_t * rc) +static ATTRIBUTE_ALWAYS_INLINE void rc_normalize(rc_t * rc) { if (rc->range < (1 << RC_TOP_BITS)) { rc_do_normalize(rc); @@ -118,7 +87,7 @@ rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS); return rc->bound; } -static always_inline int rc_is_bit_0(rc_t * rc, uint16_t * p) +static ATTRIBUTE_ALWAYS_INLINE int rc_is_bit_0(rc_t * rc, uint16_t * p) { uint32_t t = rc_is_bit_0_helper(rc, p); return rc->code < t; @@ -152,7 +121,7 @@ } /* Called once */ -static always_inline int rc_direct_bit(rc_t * rc) +static ATTRIBUTE_ALWAYS_INLINE int rc_direct_bit(rc_t * rc) { rc_normalize(rc); rc->range >>= 1; Index: busybox/archival/libunarchive/decompress_unlzma.c =================================================================== --- busybox/archival/libunarchive/decompress_unlzma.c (revision 15159) +++ busybox/archival/libunarchive/decompress_unlzma.c (working copy) @@ -20,7 +20,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include #include #include Index: busybox/Rules.mak =================================================================== --- busybox/Rules.mak (revision 15159) +++ busybox/Rules.mak (working copy) @@ -31,7 +31,8 @@ # to something more interesting... Target architecture is determined # by asking the CC compiler what arch it compiles things for, so unless # your compiler is broken, you should not need to specify TARGET_ARCH -CROSS =$(subst ",, $(strip $(CROSS_COMPILER_PREFIX))) +CROSS =$(strip $(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))) +# be gentle to vi coloring.. ")) CC = $(CROSS)gcc AR = $(CROSS)ar AS = $(CROSS)as @@ -47,10 +48,6 @@ # OS specific things, syscall overrides, etc. TARGET_OS=linux -# Select the compiler needed to build binaries for your development system -HOSTCC = gcc -HOSTCFLAGS= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer - # Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc. LC_ALL:= C @@ -79,11 +76,6 @@ CFLAGS+=$(CHECKED_CFLAGS) ARFLAGS=cru -# Warnings - -CFLAGS += -Wall -Wstrict-prototypes -Wshadow -LDFLAGS += $(call check_ld,--warn-common,) - # gcc centric. Perhaps fiddle with findstring gcc,$(CC) for the rest # get the CC MAJOR/MINOR version CC_MAJOR:=$(shell printf "%02d" $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n 1)) @@ -107,27 +99,90 @@ endif # A nifty macro to make testing gcc features easier, but note that everything -# that uses this _must_ use := or it will be re-evaluated for every file. +# that uses this _must_ use := or it will be re-evaluated everytime it is +# referenced. ifeq ($(strip $(V)),2) -VERBOSE_CHECK_GCC=echo check_gcc $(1) >> /dev/stderr; +VERBOSE_CHECK_CC=echo CC=\"$(1)\" check_cc $(2) >&2; endif -check_gcc=$(shell \ - $(VERBOSE_CHECK_GCC)\ - if [ "$(1)" != "" ]; then \ - if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \ - then echo "$(1)"; else echo "$(2)"; fi \ +check_cc=$(shell \ + $(VERBOSE_CHECK_CC) \ + if [ "x$(1)" != "x" ] && [ "x$(2)" != "x" ]; then \ + echo "int i;" > ./conftest.c; \ + if $(1) $(2) -c -o conftest.o conftest.c > /dev/null 2>&1; \ + then echo "$(2)"; else echo "$(3)"; fi ; \ + rm -f conftest.c conftest.o; \ fi) # A not very robust macro to check for available ld flags +ifeq ($(strip $(V)),2) +VERBOSE_CHECK_LD=echo LD=\"$(1)\" check_ld $(2) >&2; +endif check_ld=$(shell \ - if [ "x$(1)" != "x" ]; then \ - $(LD) --help | grep -q "\$(1)" && echo "-Wl,$(1)" ; \ + $(VERBOSE_CHECK_LD) \ + if [ "x$(1)" != "x" ] && [ "x$(2)" != "x" ]; then \ + $(1) -o /dev/null -b binary /dev/null > /dev/null 2>&1 && \ + echo "-Wl,$(2)" ; \ fi) +# A not very robust macro to check for available strip flags +ifeq ($(strip $(V)),2) +VERBOSE_CHECK_STRIP=echo STRIPCMD=\"$(1)\" check_strip $(2) >&2; +endif +check_strip=$(shell \ + $(VERBOSE_CHECK_STRIP) \ + if [ "x$(1)" != "x" ] && [ "x$(2)" != "x" ]; then \ + echo "int i;" > ./conftest.c ; \ + $(CC) -c -o conftest.o conftest.c > /dev/null 2>&1 ; \ + $(1) $(2) conftest.o > /dev/null 2>&1 && \ + echo "$(2)" || echo "$(3)"; \ + rm -f conftest.c conftest.o > /dev/null 2>&1 ; \ + fi) + + + +# Select the compiler needed to build binaries for your development system +HOSTCC = gcc +HOSTCFLAGS:=$(call check_cc,$(HOSTCC),-Wall,) +HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-Wstrict-prototypes,) +HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-O2,) +HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-fomit-frame-pointer,) + +LD_WHOLE_ARCHIVE:=$(shell echo "int i;" > conftest.c ; \ + $(CC) -c -o conftest.o conftest.c ; \ + echo "int main(void){return 0;}" > conftest_main.c ; \ + $(CC) -c -o conftest_main.o conftest_main.c ; \ + $(AR) $(ARFLAGS) conftest.a conftest.o ; \ + $(CC) -Wl,--whole-archive conftest.a -Wl,--no-whole-archive \ + conftest_main.o -o conftest > /dev/null 2>&1 \ + && echo "-Wl,--whole-archive" ; \ + rm conftest_main.o conftest_main.c conftest.o conftest.c \ + conftest.a conftest > /dev/null 2>&1 ; ) +ifneq ($(findstring whole-archive,$(LD_WHOLE_ARCHIVE)),) +LD_NO_WHOLE_ARCHIVE:= -Wl,--no-whole-archive +endif + +LD_START_GROUP:=$(shell echo "int bar(void){return 0;}" > conftest.c ; \ + $(CC) -c -o conftest.o conftest.c ; \ + echo "int main(void){return bar();}" > conftest_main.c ; \ + $(CC) -c -o conftest_main.o conftest_main.c ; \ + $(AR) $(ARFLAGS) conftest.a conftest.o ; \ + $(CC) -Wl,--start-group conftest.a conftest_main.o -Wl,--end-group \ + -o conftest > /dev/null 2>&1 && echo "-Wl,--start-group" ; \ + echo rm conftest_main.o conftest_main.c conftest.o conftest.c \ + conftest.a conftest > /dev/null 2>&1 ; ) +ifneq ($(findstring start-group,$(LD_START_GROUP)),) +LD_END_GROUP:= -Wl,--end-group +endif + +CHECKED_LDFLAGS := $(call check_ld,$(LD),--warn-common,) + # Pin CHECKED_CFLAGS with := so it's only evaluated once. -CHECKED_CFLAGS:=$(call check_gcc,-funsigned-char,) -CHECKED_CFLAGS+=$(call check_gcc,-mmax-stack-frame=256,) -CHECKED_CFLAGS+=$(call check_gcc,-fno-builtin-strlen) +CHECKED_CFLAGS:=$(call check_cc,$(CC),-Wall,) +CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wstrict-prototypes,) +CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wshadow,) +CHECKED_CFLAGS+=$(call check_cc,$(CC),-funsigned-char,) +CHECKED_CFLAGS+=$(call check_cc,$(CC),-mmax-stack-frame=256,) +CHECKED_CFLAGS+=$(call check_cc,$(CC),-fno-builtin-strlen) # Preemptively pin this too. PROG_CFLAGS:= @@ -139,26 +194,26 @@ # for OPTIMIZATION... # use '-Os' optimization if available, else use -O2 -OPTIMIZATION:=$(call check_gcc,-Os,-O2) +OPTIMIZATION:=$(call check_cc,$(CC),-Os,-O2) ifeq ($(CONFIG_BUILD_AT_ONCE),y) # gcc 2.95 exits with 0 for "unrecognized option" ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 3 ] ; echo $$?)),0) - CFLAGS_COMBINE:=$(call check_gcc,--combine,) + CFLAGS_COMBINE:=$(call check_cc,$(CC),--combine,) endif -OPTIMIZATION+=$(call check_gcc,-funit-at-a-time,) -OPTIMIZATION+=$(call check_gcc,-fgcse-after-reload,) +OPTIMIZATION+=$(call check_cc,$(CC),-funit-at-a-time,) +OPTIMIZATION+=$(call check_cc,$(CC),-fgcse-after-reload,) ifneq ($(CONFIG_BUILD_LIBBUSYBOX),y) # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25795 # This prevents us from using -fwhole-program when we build the lib -PROG_CFLAGS+=$(call check_gcc,-fwhole-program,) +PROG_CFLAGS+=$(call check_cc,$(CC),-fwhole-program,) endif # CONFIG_BUILD_LIBBUSYBOX endif # CONFIG_BUILD_AT_ONCE -LIB_LDFLAGS:=$(call check_ld,--enable-new-dtags,) -#LIB_LDFLAGS+=$(call check_ld,--reduce-memory-overheads,) -#LIB_LDFLAGS+=$(call check_ld,--as-needed,) -#LIB_LDFLAGS+=$(call check_ld,--warn-shared-textrel,) +LIB_LDFLAGS:=$(call check_ld,$(LD),--enable-new-dtags,) +#LIB_LDFLAGS+=$(call check_ld,$(LD),--reduce-memory-overheads,) +#LIB_LDFLAGS+=$(call check_ld,$(LD),--as-needed,) +#LIB_LDFLAGS+=$(call check_ld,$(LD),--warn-shared-textrel,) # Some nice architecture specific optimizations @@ -166,25 +221,25 @@ OPTIMIZATION+=-fstrict-aliasing endif ifeq ($(strip $(TARGET_ARCH)),i386) - OPTIMIZATION+=$(call check_gcc,-march=i386,) + OPTIMIZATION+=$(call check_cc,$(CC),-march=i386,) # gcc-4.0 and older seem to benefit from these #ifneq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0) - OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=2,) - OPTIMIZATION+=$(call check_gcc,-falign-functions=1 -falign-jumps=1 -falign-loops=1,\ + OPTIMIZATION+=$(call check_cc,$(CC),-mpreferred-stack-boundary=2,) + OPTIMIZATION+=$(call check_cc,$(CC),-falign-functions=1 -falign-jumps=1 -falign-loops=1,\ -malign-functions=0 -malign-jumps=0 -malign-loops=0) #endif # gcc-4.0 and older # gcc-4.1 and beyond seem to benefit from these ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0) # turn off flags which hurt -Os - OPTIMIZATION+=$(call check_gcc,-fno-tree-loop-optimize,) - OPTIMIZATION+=$(call check_gcc,-fno-tree-dominator-opts,) - OPTIMIZATION+=$(call check_gcc,-fno-strength-reduce,) + OPTIMIZATION+=$(call check_cc,$(CC),-fno-tree-loop-optimize,) + OPTIMIZATION+=$(call check_cc,$(CC),-fno-tree-dominator-opts,) + OPTIMIZATION+=$(call check_cc,$(CC),-fno-strength-reduce,) - OPTIMIZATION+=$(call check_gcc,-fno-branch-count-reg,) + OPTIMIZATION+=$(call check_cc,$(CC),-fno-branch-count-reg,) endif # gcc-4.1 and beyond endif -OPTIMIZATION+=$(call check_gcc,-fomit-frame-pointer,) +OPTIMIZATION+=$(call check_cc,$(CC),-fomit-frame-pointer,) # #-------------------------------------------------------- @@ -215,7 +270,7 @@ CFLAGS +=-g else CFLAGS +=-DNDEBUG - LDFLAGS += $(call check_ld,--sort-common,) + CHECKED_LDFLAGS += $(call check_ld,$(LD),--sort-common,) endif ifneq ($(strip $(CONFIG_DEBUG_PESSIMIZE)),y) @@ -224,27 +279,26 @@ # warn a bit more verbosely for non-release versions ifneq ($(EXTRAVERSION),) - CHECKED_CFLAGS+=$(call check_gcc,-Wstrict-prototypes,) - CHECKED_CFLAGS+=$(call check_gcc,-Wmissing-prototypes,) - CHECKED_CFLAGS+=$(call check_gcc,-Wmissing-declarations,) - CHECKED_CFLAGS+=$(call check_gcc,-Wunused,) - CHECKED_CFLAGS+=$(call check_gcc,-Winit-self,) - CHECKED_CFLAGS+=$(call check_gcc,-Wshadow,) - CHECKED_CFLAGS+=$(call check_gcc,-Wcast-align,) + CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wstrict-prototypes,) + CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wmissing-prototypes,) + CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wmissing-declarations,) + CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wunused,) + CHECKED_CFLAGS+=$(call check_cc,$(CC),-Winit-self,) + CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wshadow,) + CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wcast-align,) endif -STRIPCMD:=$(STRIP) -s --remove-section=.note --remove-section=.comment +STRIPCMD:=$(call check_strip,$(STRIP),-s --remove-section=.note --remove-section=.comment,$(STRIP)) ifeq ($(strip $(CONFIG_STATIC)),y) - PROG_CFLAGS += $(call check_gcc,-static,) + PROG_CFLAGS += $(call check_cc,$(CC),-static,) endif -CFLAGS_SHARED := $(call check_gcc,-shared,) +CFLAGS_SHARED := $(call check_cc,$(CC),-shared,) LIB_CFLAGS+=$(CFLAGS_SHARED) ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) - CFLAGS_PIC:= $(call check_gcc,-fPIC,) + CFLAGS_PIC:= $(call check_cc,$(CC),-fPIC,) LIB_CFLAGS+=$(CFLAGS_PIC) endif - ifeq ($(strip $(CONFIG_SELINUX)),y) LIBRARIES += -lselinux endif @@ -261,7 +315,9 @@ OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o -CFLAGS += $(CHECKED_CFLAGS) $(CROSS_CFLAGS) +CFLAGS += $(CHECKED_CFLAGS) $(CROSS_CFLAGS) +LDFLAGS += $(CHECKED_LDFLAGS) + ifdef BB_INIT_SCRIPT CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"' endif Index: busybox/shell/ash.c =================================================================== --- busybox/shell/ash.c (revision 15159) +++ busybox/shell/ash.c (working copy) @@ -77,7 +77,6 @@ #include #include #include -#include #include #include Index: busybox/coreutils/md5_sha1_sum.c =================================================================== --- busybox/coreutils/md5_sha1_sum.c (revision 15159) +++ busybox/coreutils/md5_sha1_sum.c (working copy) @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include Index: busybox/coreutils/dos2unix.c =================================================================== --- busybox/coreutils/dos2unix.c (revision 15159) +++ busybox/coreutils/dos2unix.c (working copy) @@ -13,7 +13,6 @@ #include #include -#include #include #include #include "busybox.h" Index: busybox/coreutils/stat.c =================================================================== --- busybox/coreutils/stat.c (revision 15159) +++ busybox/coreutils/stat.c (working copy) @@ -13,7 +13,6 @@ */ #include -#include #include #include #include Index: busybox/libbb/Makefile.in =================================================================== --- busybox/libbb/Makefile.in (revision 15159) +++ busybox/libbb/Makefile.in (working copy) @@ -14,7 +14,7 @@ bb_asprintf.c ask_confirmation.c change_identity.c chomp.c \ compare_string_array.c concat_path_file.c copy_file.c copyfd.c \ crc32.c create_icmp_socket.c create_icmp6_socket.c \ - device_open.c dump.c error_msg.c error_msg_and_die.c find_mount_point.c \ + device_open.c dump.c error_msg.c error_msg_and_die.c \ find_pid_by_name.c find_root_device.c fgets_str.c full_read.c \ full_write.c get_last_path_component.c get_line_from_file.c \ herror_msg.c herror_msg_and_die.c \ @@ -48,6 +48,8 @@ LIBBB-$(CONFIG_VLOCK)+= correct_password.c LIBBB-$(CONFIG_SU)+= correct_password.c LIBBB-$(CONFIG_LOGIN)+= correct_password.c +LIBBB-$(CONFIG_DF)+= find_mount_point.c +LIBBB-$(CONFIG_EJECT)+= find_mount_point.c LIBBB-y:=$(patsubst %,$(srcdir)/%,$(LIBBB-y)) Index: busybox/libbb/md5.c =================================================================== --- busybox/libbb/md5.c (revision 15159) +++ busybox/libbb/md5.c (working copy) @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include Index: busybox/libbb/sha1.c =================================================================== --- busybox/libbb/sha1.c (revision 15159) +++ busybox/libbb/sha1.c (working copy) @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include Index: busybox/libbb/getopt_ulflags.c =================================================================== --- busybox/libbb/getopt_ulflags.c (revision 15159) +++ busybox/libbb/getopt_ulflags.c (working copy) @@ -297,6 +297,18 @@ int *counter; } t_complementally; + +#ifndef no_argument +struct option { + const char *name; + int has_arg; + int *flag; + int val; +}; +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 +#endif /* You can set bb_applet_long_options for parse called long options */ static const struct option bb_default_long_options[] = { Index: busybox/Makefile =================================================================== --- busybox/Makefile (revision 15159) +++ busybox/Makefile (working copy) @@ -8,7 +8,7 @@ #-------------------------------------------------------------- # You shouldn't need to mess with anything beyond this point... #-------------------------------------------------------------- -noconfig_targets := menuconfig config oldconfig randconfig \ +noconfig_targets := menuconfig config oldconfig randconfig hostsed \ defconfig allyesconfig allnoconfig allbareconfig \ clean distclean help \ release tags @@ -126,6 +126,9 @@ @echo ' defconfig - set .config to largest generic configuration' @echo ' menuconfig - interactive curses-based configurator' @echo ' oldconfig - resolve any unresolved symbols in .config' + @echo ' hostsed - build a sed for the host.' + @echo ' You can use this sed if the sed on the host' + @echo ' is unusable. Afterwards do make SED=./sed' @echo @echo 'Installation:' @echo ' install - install busybox into $(PREFIX)' @@ -210,6 +213,15 @@ @echo "CONFIG_FEATURE_BUFFERS_GO_ON_STACK=y" >> .config @yes n | ./scripts/config/conf -o $(CONFIG_CONFIG_IN) > /dev/null +hostsed: allnoconfig + $(Q)mv .config .config.in + $(Q)(grep -v CONFIG_SED .config.in ; echo "CONFIG_SED=y" ; ) > .config + $(Q)rm -f .config.in + $(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" oldconfig include/bb_config.h + $(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" busybox + mv busybox sed + @echo "Now do: $(MAKE) SED=$(top_builddir)/sed" + else # ifneq ($(strip $(HAVE_DOT_CONFIG)),y) all: busybox busybox.links doc @@ -287,9 +299,9 @@ -Wl,-soname=$(LD_LIBBUSYBOX).$(MAJOR_VERSION) \ -Wl,-z,combreloc $(LIB_LDFLAGS) \ -o $(@) \ - -Wl,--start-group -Wl,--whole-archive \ + $(LD_START_GROUP) $(LD_WHOLE_ARCHIVE) \ $(LIBRARY_DEFINE) $(^) \ - -Wl,--no-whole-archive -Wl,--end-group + $(LD_NO_WHOLE_ARCHIVE) $(LD_END_GROUP) @rm -f $(DO_INSTALL_LIBS) @for i in $(DO_INSTALL_LIBS); do ln -s $(@) $$i ; done $(do_strip) @@ -298,11 +310,11 @@ busybox_unstripped: .depend $(LIBBUSYBOX_SONAME) $(BUSYBOX_SRC) $(APPLET_SRC) $(libraries-y) $(do_link) $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) \ - -o $@ -Wl,--start-group \ + -o $@ $(LD_START_GROUP) \ $(APPLETS_DEFINE) $(APPLET_SRC) \ $(BUSYBOX_DEFINE) $(BUSYBOX_SRC) $(libraries-y) \ $(LDBUSYBOX) $(LIBRARIES) \ - -Wl,--end-group + $(LD_END_GROUP) busybox: busybox_unstripped $(Q)cp busybox_unstripped busybox @@ -486,4 +498,4 @@ endif # ifeq ($(skip-makefile),) .PHONY: dummy subdirs release distclean clean config oldconfig \ - menuconfig tags check test depend dep buildtree + menuconfig tags check test depend dep buildtree hostsed Index: busybox/include/pwd_.h =================================================================== --- busybox/include/pwd_.h (revision 15159) +++ busybox/include/pwd_.h (working copy) @@ -29,7 +29,6 @@ #define _PWD_H 1 #include -#include #include /* The passwd structure. */ Index: busybox/include/libbb.h =================================================================== --- busybox/include/libbb.h (revision 15159) +++ busybox/include/libbb.h (working copy) @@ -18,13 +18,10 @@ #include #include #include -#include #include #include -#include - #include "platform.h" #include "bb_config.h" #ifdef CONFIG_SELINUX @@ -41,8 +38,11 @@ #endif /* Some useful definitions */ +#undef FALSE #define FALSE ((int) 0) +#undef TRUE #define TRUE ((int) 1) +#undef SKIP #define SKIP ((int) 2) /* for mtab.c */ @@ -246,6 +246,8 @@ int nfsmount(const char *spec, const char *node, int *flags, char **mount_opts, int running_bg); +#if defined __linux__ +/* FIXME: move this to platform.h */ /* Include our own copy of struct sysinfo to avoid binary compatibility * problems with Linux 2.4, which changed things. Grumble, grumble. */ struct sysinfo { @@ -265,6 +267,9 @@ char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */ }; extern int sysinfo (struct sysinfo* info); +#else +#include +#endif enum { KILOBYTE = 1024, Index: busybox/include/busybox.h =================================================================== --- busybox/include/busybox.h (revision 15159) +++ busybox/include/busybox.h (working copy) @@ -15,16 +15,8 @@ #include #include -#if __GNU_LIBRARY__ < 5 && \ - !defined(__dietlibc__) && \ - !defined(_NEWLIB_VERSION) -#error "Sorry, this libc version is not supported :(" -#endif - extern const char BB_BANNER[]; -#include - /* Pull in the utility routines from libbb */ #include "libbb.h" Index: busybox/include/platform.h =================================================================== --- busybox/include/platform.h (revision 15159) +++ busybox/include/platform.h (working copy) @@ -33,6 +33,26 @@ # endif #endif +#undef inline +#if __STDC_VERSION__ > 199901L +/* it's a keyword */ +#else +# if __GNUC_PREREQ (2,7) +# define inline __inline__ +# else +# define inline +# endif +#endif + +#ifndef __const +# define __const const +#endif + +#ifndef __THROW +# define __THROW +#endif + + #ifndef ATTRIBUTE_UNUSED # define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) #endif /* ATTRIBUTE_UNUSED */ @@ -49,6 +69,14 @@ # define ATTRIBUTE_ALIGNED(m) __attribute__ ((__aligned__(m))) #endif /* ATTRIBUTE_ALIGNED */ +#ifndef ATTRIBUTE_ALWAYS_INLINE +# if __GNUC_PREREQ (3,0) +# define ATTRIBUTE_ALWAYS_INLINE __attribute__ ((always_inline)) inline +# else +# define ATTRIBUTE_ALWAYS_INLINE inline +# endif +#endif + /* -fwhole-program makes all symbols local. The attribute externally_visible forces a symbol global. */ #ifndef ATTRIBUTE_EXTERNALLY_VISIBLE @@ -69,11 +97,18 @@ #endif /* ---- Endian Detection ------------------------------------ */ -#ifndef __APPLE__ +#if !defined __APPLE__ && !defined __DECC # include # include #endif +#if defined __DECC +# include +# define __BIG_ENDIAN__ (BYTE_ORDER == BIG_ENDIAN) +# define __BYTE_ORDER BYTE_ORDER +#endif + + #ifdef __BIG_ENDIAN__ # define BB_BIG_ENDIAN 1 # define BB_LITTLE_ENDIAN 0 @@ -92,19 +127,60 @@ # include #endif +#ifndef __socklen_t_defined +typedef int socklen_t; +#endif + +/* ---- Compiler dependent settings ------------------------- */ +#ifndef __GNUC__ +#if defined __INTEL_COMPILER +__extension__ typedef __signed__ long long __s64; +__extension__ typedef unsigned long long __u64; +#endif /* __INTEL_COMPILER */ +#endif /* ifndef __GNUC__ */ + +#ifdef __DECC +# undef HAVE_STDBOOL_H +#else +# define HAVE_STDBOOL_H 1 +#endif /* __DECC */ + /*----- Kernel versioning ------------------------------------*/ #ifdef __linux__ #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -#else -#error implement KERNEL_VERSION for your platform #endif /* ---- miscellaneous --------------------------------------- */ + +#if __GNU_LIBRARY__ < 5 && \ + !defined(__dietlibc__) && \ + !defined(_NEWLIB_VERSION) && \ + !defined __DECC +#error "Sorry, this libc version is not supported :(" +#endif + +#if defined __GLIBC__ || defined __UCLIBC__ \ + || defined __dietlibc__ || defined _NEWLIB_VERSION +#include +#define HAVE_FEATURES_H +#include +#define HAVE_STDINT_H +#endif + +#if defined __DECC +#include +#define HAVE_STANDARDS_H +#include +#define HAVE_INTTYPES_H +#endif + + /* NLS stuff */ /* THIS SHOULD BE CLEANED OUT OF THE TREE ENTIRELY */ #define _(Text) Text #define N_(Text) (Text) -#define fdprintf(...) dprintf(__VA_ARGS__) +/* THIS SHOULD BE CLEANED OUT OF THE TREE ENTIRELY */ +#define fdprintf dprintf #endif /* platform.h */ Index: busybox/include/grp_.h =================================================================== --- busybox/include/grp_.h (revision 15159) +++ busybox/include/grp_.h (working copy) @@ -31,7 +31,6 @@ #include -#include #include Index: busybox/include/inet_common.h =================================================================== --- busybox/include/inet_common.h (revision 15159) +++ busybox/include/inet_common.h (working copy) @@ -8,7 +8,6 @@ * */ -#include #include #include #include "platform.h" Index: busybox/libpwdgrp/pwd_grp_internal.c =================================================================== --- busybox/libpwdgrp/pwd_grp_internal.c (revision 15159) +++ busybox/libpwdgrp/pwd_grp_internal.c (working copy) @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include Index: busybox/libpwdgrp/pwd_grp.c =================================================================== --- busybox/libpwdgrp/pwd_grp.c (revision 15159) +++ busybox/libpwdgrp/pwd_grp.c (working copy) @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include Index: busybox/util-linux/fdisk.c =================================================================== --- busybox/util-linux/fdisk.c (revision 15159) +++ busybox/util-linux/fdisk.c (working copy) @@ -30,8 +30,6 @@ #include #include /* major */ -#include /* for uint32_t, uint16_t, uint8_t, int16_t, etc */ - /* Copied from linux/major.h */ #define FLOPPY_MAJOR 2 Index: busybox/util-linux/fbset.c =================================================================== --- busybox/util-linux/fbset.c (revision 15159) +++ busybox/util-linux/fbset.c (working copy) @@ -19,7 +19,6 @@ #include #include #include -#include #include #include "busybox.h" Index: busybox/util-linux/mkfs_minix.c =================================================================== --- busybox/util-linux/mkfs_minix.c (revision 15159) +++ busybox/util-linux/mkfs_minix.c (working copy) @@ -70,7 +70,6 @@ #include #include #include -#include #include #include #include