-### # defconfig is allyesconfig minus any features that are specialized enough
-### # or cause enough behavior change that the user really should switch them on
-### # manually if that's what they want. Sort of "maximum sane config".
-
-### defconfig: scripts/config/conf
-### @./scripts/config/conf -y $(CONFIG_CONFIG_IN) > /dev/null
-### @$(SED) -i -r -e "s/^(CONFIG_(DEBUG.*|STATIC|SELINUX|NITPICK|BUILD_(AT_ONCE|LIBBUSYBOX)|FEATURE_(DEVFS|FULL_LIBBUSYBOX|SHARED_BUSYBOX|MTAB_SUPPORT|CLEAN_UP|UDHCP_DEBUG)|INSTALL_NO_USR))=.*/# \1 is not set/" .config
-### @./scripts/config/conf -o $(CONFIG_CONFIG_IN) > /dev/null
-
-### allbareconfig: scripts/config/conf
-### @./scripts/config/conf -y $(CONFIG_CONFIG_IN) > /dev/null
-### @$(SED) -i -r -e "s/^(CONFIG_(DEBUG|STATIC|SELINUX|DEVFSD|NC_GAPING_SECURITY_HOLE|BUILD_AT_ONCE)).*/# \1 is not set/" .config
-### @$(SED) -i -e "/FEATURE/s/=.*//;/^[^#]/s/.*FEATURE.*/# \0 is not set/;" .config
-### @echo "CONFIG_FEATURE_BUFFERS_GO_ON_STACK=y" >> .config
-### @yes n | ./scripts/config/conf -o $(CONFIG_CONFIG_IN) > /dev/null
-
-### hosttools:
-### $(Q)cp .config .config.bak || noold=yea
-### $(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" allnoconfig
-### $(Q)mv .config .config.in
-### $(Q)(grep -v CONFIG_SED .config.in ; \
-### echo "CONFIG_SED=y" ; ) > .config
-### $(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" oldconfig include/bb_config.h
-### $(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" busybox
-### $(Q)[ -f .config.bak ] && mv .config.bak .config || rm .config
-### mv busybox sed
-### @echo "Now do: $(MAKE) SED=$(objtree)/sed <target>"
-
-%.bflt: %_unstripped
- $(CROSS_COMPILE)elf2flt $(ELF2FLTFLAGS) $< -o $@
-
-busybox.links: $(srctree)/applets/busybox.mkll include/bb_config.h $(srctree)/include/applets.h
+# ==========================================================================
+# Build system
+# ==========================================================================
+
+busybox.links: $(srctree)/applets/busybox.mkll $(objtree)/include/autoconf.h include/applets.h
$(Q)-$(SHELL) $^ >$@
.PHONY: install
+ifeq ($(CONFIG_INSTALL_APPLET_SYMLINKS),y)
+INSTALL_OPTS:= --symlinks
+endif
+ifeq ($(CONFIG_INSTALL_APPLET_HARDLINKS),y)
+INSTALL_OPTS:= --hardlinks
+endif
+ifeq ($(CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS),y)
+ifeq ($(CONFIG_INSTALL_SH_APPLET_SYMLINK),y)
+INSTALL_OPTS:= --sw-sh-sym
+endif
+ifeq ($(CONFIG_INSTALL_SH_APPLET_HARDLINK),y)
+INSTALL_OPTS:= --sw-sh-hard
+endif
+ifeq ($(CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER),y)
+INSTALL_OPTS:= --scriptwrapper
+endif
+endif
install: $(srctree)/applets/install.sh busybox busybox.links
$(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
$(SHELL) $< $(CONFIG_PREFIX) $(INSTALL_OPTS)
done
endif
-check test: busybox
- bindir=$(objtree) srcdir=$(srctree)/testsuite SED="$(SED)" \
- $(SHELL) $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:1=),-v)
-
-### checkhelp:
-### $(Q)$(srctree)/scripts/checkhelp.awk \
-### $(wildcard $(patsubst %,%/Config.in,$(SRC_DIRS) ./))
+# Not very elegant: copies testsuite to objdir...
+# (cp -pPR is POSIX-compliant (cp -dpR or cp -a would not be))
+.PHONY: check
+.PHONY: test
+check test: busybox busybox.links
+ test -d $(objtree)/testsuite || cp -pPR $(srctree)/testsuite $(objtree)
+ bindir=$(objtree) srcdir=$(srctree)/testsuite \
+ $(SHELL) -c "cd $(objtree)/testsuite && $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:0=),-v)"
+
+.PHONY: release
+release: distclean
+ cd ..; \
+ rm -r -f busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION); \
+ cp -pPR busybox busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) && { \
+ find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \
+ -name .svn \
+ -print \
+ -exec rm -r -f {} \; ; \
+ find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \
+ -name .git \
+ -print \
+ -exec rm -r -f {} \; ; \
+ find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type f \
+ -name .\#* \
+ -print \
+ -exec rm -f {} \; ; \
+ tar -czf busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION).tar.gz \
+ busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ ; }
+
+.PHONY: checkhelp
+checkhelp:
+ $(Q)$(srctree)/scripts/checkhelp.awk \
+ $(patsubst %,$(srctree)/%,$(wildcard $(patsubst %,%/Config.in,$(busybox-dirs) ./)))
.PHONY: sizes
sizes: busybox_unstripped
.PHONY: bloatcheck
bloatcheck: busybox_old busybox_unstripped
@$(srctree)/scripts/bloat-o-meter busybox_old busybox_unstripped
+ @$(CROSS_COMPILE)size busybox_old busybox_unstripped
.PHONY: baseline
baseline: busybox_unstripped
.PHONY: objsizes
objsizes: busybox_unstripped
- $(SHELL) $(srctree)/scripts/objsizes
+ $(srctree)/scripts/objsizes
+
+.PHONY: stksizes
+stksizes: busybox_unstripped
+ $(CROSS_COMPILE)objdump -d busybox_unstripped | $(srctree)/scripts/checkstack.pl $(ARCH) | uniq
+
+.PHONY: bigdata
+bigdata: busybox_unstripped
+ $(CROSS_COMPILE)nm --size-sort busybox_unstripped | grep -vi ' [trw] '
# Documentation Targets
.PHONY: doc
doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
+# FIXME: Doesn't belong here
+ cmd_doc =
+ quiet_cmd_doc = $(Q)echo " DOC $(@F)"
+silent_cmd_doc =
+disp_doc = $($(quiet)cmd_doc)
+
+# sed adds newlines after "Options:" etc,
+# this is needed in order to get good BusyBox.{1,txt,html}
docs/busybox.pod: $(srctree)/docs/busybox_header.pod \
- $(srctree)/include/usage.h \
+ include/usage.h \
$(srctree)/docs/busybox_footer.pod \
- $(srctree)/docs/autodocifier.pl
+ applets/usage_pod
$(disp_doc)
$(Q)-mkdir -p docs
- $(Q)-( cat $(srctree)/docs/busybox_header.pod ; \
- $(srctree)/docs/autodocifier.pl $(srctree)/include/usage.h ; \
- cat $(srctree)/docs/busybox_footer.pod ; ) > docs/busybox.pod
+ $(Q)-( \
+ cat $(srctree)/docs/busybox_header.pod; \
+ applets/usage_pod | sed 's/^[A-Za-z][A-Za-z ]*[a-z]:$$/&\n/'; \
+ cat $(srctree)/docs/busybox_footer.pod; \
+ ) > docs/busybox.pod
docs/BusyBox.txt: docs/busybox.pod
$(disp_doc)
docs/BusyBox.1: docs/busybox.pod
$(disp_doc)
$(Q)-mkdir -p docs
- $(Q)-pod2man --center=BusyBox --release="version $(VERSION)" \
- $< > $@
+ $(Q)-pod2man --center=BusyBox --release="version $(KERNELVERSION)" $< > $@
docs/BusyBox.html: docs/busybox.net/BusyBox.html
$(disp_doc)
docs/busybox.net/BusyBox.html: docs/busybox.pod
$(Q)-mkdir -p docs/busybox.net
- $(Q)-pod2html --noindex $< > \
- docs/busybox.net/BusyBox.html
+ $(Q)-pod2html --noindex $< > $@
$(Q)-rm -f pod2htm*
# documentation, cross-reference
# Modern distributions already ship synopsis packages (e.g. debian)
# If you have an old distribution go to http://synopsis.fresco.org/
-syn_tgt := $(wildcard $(patsubst %,%/*.c,$(SRC_DIRS)))
-syn := $(patsubst %.c, %.syn, $(syn_tgt))
+syn_tgt = $(wildcard $(patsubst %,%/*.c,$(busybox-alldirs)))
+syn = $(patsubst %.c, %.syn, $(syn_tgt))
+
+comma:= ,
+brace_open:= (
+brace_close:= )
+
+SYN_CPPFLAGS := $(strip $(CPPFLAGS) $(EXTRA_CPPFLAGS))
+SYN_CPPFLAGS := $(subst $(brace_open),\$(brace_open),$(SYN_CPPFLAGS))
+SYN_CPPFLAGS := $(subst $(brace_close),\$(brace_close),$(SYN_CPPFLAGS))
+#SYN_CPPFLAGS := $(subst ",\",$(SYN_CPPFLAGS))
+#")
+#SYN_CPPFLAGS := [$(patsubst %,'%'$(comma),$(SYN_CPPFLAGS))'']
%.syn: %.c
- synopsis -p C -l Comments.SSDFilter,Comments.Previous $(INCS) -Wp,verbose,debug,preprocess,cppflags="'$(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) $(APPLETS_DEFINE) $(BUSYBOX_DEFINE)'" -o $@ $<
+ synopsis -p C -l Comments.SSDFilter,Comments.Previous -Wp,preprocess=True,cppflags="'$(SYN_CPPFLAGS)'" -o $@ $<
.PHONY: html
html: $(syn)
synopsis -f HTML -Wf,title="'BusyBox Documentation'" -o $@ $^
+
+-include $(srctree)/Makefile.local