-#
-#--------------------------------------------------------
-# If you're going to do a lot of builds with a non-vanilla configuration,
-# it makes sense to adjust parameters above, so you can type "make"
-# by itself, instead of following it by the same half-dozen overrides
-# every time. The stuff below, on the other hand, is probably less
-# prone to casual user adjustment.
-#
-
-ifeq ($(strip $(DOLFS)),true)
- # For large file summit support
- CFLAGS+=-D_FILE_OFFSET_BITS=64
-endif
-ifeq ($(strip $(DODMALLOC)),true)
- # For testing mem leaks with dmalloc
- CFLAGS+=-DDMALLOC
- LIBRARIES = -ldmalloc
- # Force debug=true, since this is useless when not debugging...
- DODEBUG = true
-else
- ifeq ($(strip $(DOEFENCE)),true)
- LIBRARIES = -lefence
- # Force debug=true, since this is useless when not debugging...
- DODEBUG = true
- endif
-endif
-ifeq ($(strip $(DODEBUG)),true)
- CFLAGS += $(WARNINGS) -g -D_GNU_SOURCE
- LDFLAGS += -Wl,-warn-common
- STRIP =
-else
- CFLAGS += $(WARNINGS) $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
- LDFLAGS += -s -Wl,-warn-common
- STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
-endif
-ifeq ($(strip $(DOSTATIC)),true)
- 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 2>/dev/null && $(LD) \
- # --gc-sections -v >/dev/null && echo 1),1)
- # CFLAGS += -ffunction-sections -fdata-sections
- # LDFLAGS += --gc-sections
- #endif
-endif
-
-ifndef $(PREFIX)
- PREFIX = `pwd`/_install
-endif
-
-# Additional complications due to support for pristine source dir.
-# Include files in the build directory should take precedence over
-# the copy in BB_SRC_DIR, both during the compilation phase and the
-# shell script that finds the list of object files.
-# Work in progress by <ldoolitt@recycle.lbl.gov>.
-#
-ifneq ($(strip $(BB_SRC_DIR)),)
- VPATH = $(BB_SRC_DIR)
-endif
-#ifneq ($(strip $(VPATH)),)
-# CFLAGS += -I- -I. $(patsubst %,-I%,$(subst :, ,$(VPATH)))
-#endif
-
-# We need to set APPLET_SOURCES to something like
-# $(shell busybox.sh Config.h)
-# but in a manner that works with VPATH and BB_SRC_DIR.
-# Possible ways to approach this:
-#
-# 1. Explicitly search through .:$(VPATH) for busybox.sh and config.h,
-# then $(shell $(BUSYBOX_SH) $(CONFIG_H) $(BB_SRC_DIR))
-#
-# 2. Explicity search through .:$(VPATH) for slist.mk,
-# then $(shell $(MAKE) -f $(SLIST_MK) VPATH=$(VPATH) BB_SRC_DIR=$(BB_SRC_DIR))
-#
-# 3. Create slist.mk in this directory, with commands embedded in
-# a $(shell ...) command, and $(MAKE) it immediately.
-#
-# 4. Use a real rule within this makefile to create a file that sets
-# APPLET_SOURCE_LIST, then include that file. Has complications
-# with the first trip through the makefile (before processing the
-# include) trying to do too much, and a spurious warning the first
-# time make is run.
-#
-# This is option 3:
-#
-#APPLET_SOURCES = $(shell \
-# echo -e 'all: busybox.sh Config.h\n\t@ $$(SHELL) $$^ $$(BB_SRC_DIR)' >slist.mk; \
-# make -f slist.mk VPATH=$(VPATH) BB_SRC_DIR=$(BB_SRC_DIR) \
-#)
-# And option 4:
--include applet_source_list
-
-OBJECTS = $(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
-CFLAGS += $(CROSS_CFLAGS)
-CFLAGS += -DBB_VER='"$(VERSION)"'
-CFLAGS += -DBB_BT='"$(BUILDTIME)"'
-ifdef BB_INIT_SCRIPT
- CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
-endif
-
-ifneq ($(strip $(USE_SYSTEM_PWD_GRP)),true)
- PWD_GRP = pwd_grp
- PWD_GRP_DIR = $(BB_SRC_DIR:=/)$(PWD_GRP)
- PWD_LIB = libpwd.a
- PWD_CSRC=__getpwent.c pwent.c getpwnam.c getpwuid.c putpwent.c getpw.c \
- fgetpwent.c __getgrent.c grent.c getgrnam.c getgrgid.c fgetgrent.c \
- initgroups.c setgroups.c
- PWD_OBJS=$(patsubst %.c,$(PWD_GRP)/%.o, $(PWD_CSRC))
- PWD_CFLAGS = -I$(PWD_GRP_DIR)
-else
- CFLAGS += -DUSE_SYSTEM_PWD_GRP
-endif
-
-LIBBB = libbb
-LIBBB_LIB = libbb.a
-LIBBB_CSRC= ask_confirmation.c check_wildcard_match.c chomp.c \
-concat_path_file.c copy_file.c copy_file_chunk.c create_path.c \
-daemon.c deb_extract.c device_open.c error_msg.c error_msg_and_die.c \
-find_mount_point.c find_pid_by_name.c find_root_device.c full_read.c \
-full_write.c get_ar_headers.c get_console.c get_last_path_component.c \
-get_line_from_file.c gz_open.c human_readable.c inode_hash.c isdirectory.c \
-kernel_version.c loop.c mode_string.c module_syscalls.c mtab.c 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 read_text_file_to_buffer.c \
-recursive_action.c safe_read.c safe_strncpy.c seek_ared_file.c syscalls.c \
-syslog_msg_with_name.c time_string.c trim.c untar.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
-LIBBB_OBJS=$(patsubst %.c,$(LIBBB)/%.o, $(LIBBB_CSRC))
-LIBBB_CFLAGS = -I$(LIBBB)
-ifneq ($(strip $(BB_SRC_DIR)),)
- LIBBB_CFLAGS += -I$(BB_SRC_DIR)/$(LIBBB)
-endif
-
-LIBBB_MSRC=libbb/messages.c
-LIBBB_MESSAGES= full_version name_too_long omitting_directory not_a_directory \
-memory_exhausted invalid_date invalid_option io_error dash_dash_help \
-write_error too_few_args name_longer_than_foo
-LIBBB_MOBJ=$(patsubst %,$(LIBBB)/%.o, $(LIBBB_MESSAGES))
-
-
-# Put user-supplied flags at the end, where they
-# have a chance of winning.
-CFLAGS += $(CFLAGS_EXTRA)
-
-.EXPORT_ALL_VARIABLES:
-
-all: applet_source_list busybox busybox.links doc
-
-sh.c:
- @if [ ! -L sh.c ] ; then ln -s lash.c sh.c ; fi
-
-applet_source_list: sh.c busybox.sh Config.h
- (echo -n "APPLET_SOURCES := "; BB_SRC_DIR=$(BB_SRC_DIR) $(SHELL) $^) > $@