+ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
+ CONFIG_DEBUG = true
+endif
+ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
+endif
+
+PACKAGE_PREFIX = busybox-cvs
+
+ARCH_FLOPPY_UDEB = $(shell sh debian/control-extract Architecture $(PACKAGE_PREFIX)-floppy-udeb)
+
+PACKAGES_DEB = $(PACKAGE_PREFIX) $(PACKAGE_PREFIX)-static
+PACKAGES_UDEB = $(PACKAGE_PREFIX)-udeb
+ifneq ($(filter $(DEB_HOST_ARCH),$(ARCH_FLOPPY_UDEB)),)
+PACKAGES_UDEB += $(PACKAGE_PREFIX)-floppy-udeb
+endif
+PACKAGES = $(PACKAGES_DEB) $(PACKAGES_UDEB)
+
+DEBHELPER_PACKAGES_DEB = $(patsubst %,-p%,$(PACKAGES_DEB))
+DEBHELPER_PACKAGES_UDEB = $(patsubst %,-p%,$(PACKAGES_UDEB))
+
+CONFIG = $(firstword $(wildcard ./debian/config-$(1)-$(DEB_HOST_GNU_SYSTEM)-$(DEB_HOST_GNU_CPU) ./debian/config-$(1)-$(DEB_HOST_GNU_SYSTEM) ./debian/config-$(1)))
+CONFIG_DEB = $(call CONFIG,deb)
+CONFIG_STATIC = $(call CONFIG,static)
+CONFIG_UDEB = $(call CONFIG,udeb)
+CONFIG_FLOPPY_UDEB = $(call CONFIG,floppy-udeb)
+
+configure: configure-stamp
+configure-stamp:
+ sh ./configure
+
+ touch $@
+
+build-arch: build-arch-deb-all build-arch-udeb-all
+build-arch-deb-all: build-arch-deb build-arch-static build-arch-doc
+build-arch-udeb-all: build-arch-udeb build-arch-floppy-udeb
+
+build-arch-deb: build-arch-deb-stamp
+build-arch-deb-stamp: configure-stamp
+ $(MAKE) clean
+
+ cp $(CONFIG_DEB) .config
+
+ $(MAKE) dep
+ $(MAKE) CONFIG_DEBUG=$(CONFIG_DEBUG)
+
+ install -d install-$(PACKAGE_PREFIX)/bin
+ install busybox install-$(PACKAGE_PREFIX)/bin/busybox
+
+ touch $@
+
+build-arch-static: build-arch-static-stamp
+build-arch-static-stamp: configure-stamp
+ $(MAKE) clean
+
+ cp $(CONFIG_STATIC) .config
+
+ $(MAKE) dep
+ $(MAKE) CONFIG_DEBUG=$(CONFIG_DEBUG)
+
+ install -d install-$(PACKAGE_PREFIX)-static/bin
+ install busybox install-$(PACKAGE_PREFIX)-static/bin/busybox
+
+ touch $@
+
+build-arch-udeb: build-arch-udeb-stamp
+build-arch-udeb-stamp: configure-stamp
+ $(MAKE) clean
+
+ cp $(CONFIG_UDEB) .config
+
+ $(MAKE) dep
+ $(MAKE) CONFIG_DEBUG=$(CONFIG_DEBUG)
+
+ $(MAKE) PREFIX=$(CURDIR)/install-$(PACKAGE_PREFIX)-udeb install
+ # Remove init link, but init support is still compiled in to be
+ # used.
+ rm -f $(CURDIR)/install-$(PACKAGE_PREFIX)-udeb/sbin/init
+
+ touch $@
+
+build-arch-floppy-udeb: build-arch-floppy-udeb-stamp
+build-arch-floppy-udeb-stamp: configure-stamp
+ifneq ($(filter $(DEB_HOST_ARCH),$(ARCH_FLOPPY_UDEB)),)
+ $(MAKE) clean
+
+ cp $(CONFIG_FLOPPY_UDEB) .config
+
+ $(MAKE) dep
+ $(MAKE) CONFIG_DEBUG=$(CONFIG_DEBUG)
+
+ $(MAKE) PREFIX=$(CURDIR)/install-$(PACKAGE_PREFIX)-floppy-udeb install
+endif
+
+ touch $@
+
+build-arch-doc: build-arch-doc-stamp
+build-arch-doc-stamp: configure-stamp
+ $(MAKE) docs/BusyBox.1
+
+ cp docs/BusyBox.1 busybox.1
+
+ touch $@
+
+build: build-arch