#!/usr/bin/make -f SHELL := sh -e DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH) DEB_BUILD_ARCH := $(shell dpkg-architecture -qDEB_BUILD_ARCH) SOURCE := $(shell dpkg-parsechangelog | sed -ne 's,^Source: *\(.*\)$$,\1,p') VERSION_DEBIAN := $(shell dpkg-parsechangelog | sed -ne 's,^Version: *\(.*\)$$,\1,p') VERSION := $(shell echo "$(VERSION_DEBIAN)" | sed -e 's,^[^:]*:,,' -e 's,-[^-]*$$,,') BUILD_DIR = debian/build STAMPS_DIR = debian/stamps ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) CONFIG_DEBUG = y endif ifneq (,$(findstring thumb,$(DEB_BUILD_OPTIONS))) THUMB := -mthumb endif ifneq (,$(findstring parallel,$(DEB_BUILD_OPTIONS))) PARALLEL_JOBS := $(shell echo $(DEB_BUILD_OPTIONS) | \ sed -e 's/.*parallel=\([0-9]\+\).*/\1/') ifeq ($(DEB_BUILD_OPTIONS),$(PARALLEL_JOBS)) PARALLEL_JOBS := $(shell if [ -f /proc/cpuinfo ]; \ then echo `cat /proc/cpuinfo | grep 'processor' | wc -l`; \ else echo 1; fi) endif NJOBS := -j$(PARALLEL_JOBS) endif source: $(STAMPS_DIR)/source $(STAMPS_DIR)/source: SOURCE_FILES = $(filter-out debian, $(wildcard * .[^.]*)) $(STAMPS_DIR)/source: DIR = $(BUILD_DIR)/source $(STAMPS_DIR)/source: dh_testdir rm -rf '$(DIR)' mkdir -p $(STAMPS_DIR) '$(DIR)' cp -al $(SOURCE_FILES) '$(DIR)' cd $(DIR); QUILT_PATCHES=$(CURDIR)/debian/patches quilt --quiltrc /dev/null push -a || test $$? = 2 touch $@ setup: $(STAMPS_DIR)/setup_busybox $(STAMPS_DIR)/setup_busybox-althist $(STAMPS_DIR)/setup_%: SOURCE_DIR=$(BUILD_DIR)/source $(STAMPS_DIR)/setup_%: DIR=$(BUILD_DIR)/build_$* $(STAMPS_DIR)/setup_%: $(STAMPS_DIR)/source dh_testdir rm -rf '$(DIR)' cp -al '$(SOURCE_DIR)' '$(DIR)' cp debian/config/config.busybox '$(DIR)'/.config if test "$*" == "busybox-althist"; then \ sed -i "s/CONFIG_FEATURE_EDITING_SAVE_ON_EXIT=y/# CONFIG_FEATURE_EDITING_SAVE_ON_EXIT is not set/" '$(DIR)'/.config; fi make -C '$(DIR)' oldconfig touch $@ build: $(STAMPS_DIR)/build_busybox $(STAMPS_DIR)/build_busybox-althist $(STAMPS_DIR)/build_%: DIR=$(BUILD_DIR)/build_$* $(STAMPS_DIR)/build_%: $(STAMPS_DIR)/setup_% dh_testdir make -C '$(DIR)' $(NJOBS) THUMB=$(THUMB) busybox docs/busybox.1 BB_EXTRA_VERSION="$(shell lsb_release -is) $(VERSION_DEBIAN)" make -C '$(DIR)' busybox.links touch $@ $(BUILD_DIR) $(STAMPS_DIR): @[ -d $@ ] || mkdir $@ maintainerclean: rm -rf $(filter-out .svn debian, $(wildcard * .[^.]*)) clean: dh_testdir rm -rf $(BUILD_DIR) $(STAMPS_DIR) dh_clean rm -rf debian/busybox-power-althistory* binary-indep: binary-arch: binary-arch_busybox binary-arch_busybox-althist binary-arch_all binary-arch_busybox: DIR = $(BUILD_DIR)/build_busybox binary-arch_busybox: DH_OPTIONS = -pbusybox-power binary-arch_busybox: $(STAMPS_DIR)/build_busybox dh_testdir dh_testroot install -D -m644 debian/scripts/applets debian/busybox-power/opt/busybox-power/applets install -D -m644 debian/scripts/functions debian/busybox-power/opt/busybox-power/functions install -D -m755 $(DIR)/busybox_unstripped debian/busybox-power/opt/busybox-power/busybox.power binary-arch_busybox-althist: DIR = $(BUILD_DIR)/build_busybox-althist binary-arch_busybox-althist: DH_OPTIONS = -pbusybox-power-althist binary-arch_busybox-althist: $(STAMPS_DIR)/build_busybox-althist dh_testdir dh_testroot # busybox-power-althist == busybox-power, only BusyBox' .config differs # Duplicate the maintainer scripts etc. into busybox-power-althist for f in debian/busybox-power.*; do cp -p "$$f" "$${f/busybox-power/busybox-power-althist}"; done install -D -m644 debian/scripts/applets debian/busybox-power-althist/opt/busybox-power/applets install -D -m644 debian/scripts/functions debian/busybox-power-althist/opt/busybox-power/functions install -D -m755 $(DIR)/busybox_unstripped debian/busybox-power-althist/opt/busybox-power/busybox.power binary-arch_all: dh_installdirs dh_installdocs dh_installchangelogs dh_strip dh_compress dh_link dh_fixperms dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch DIR_ORIG = ../orig/$(SOURCE)-$(VERSION) TAR_ORIG_NAME = $(SOURCE)_$(VERSION).orig.tar.gz TAR_ORIG = $(firstword $(wildcard ../$(TAR_ORIG_NAME)) $(wildcard ../orig/$(TAR_ORIG_NAME))) orig: $(DIR_ORIG) rsync --delete --exclude debian --exclude .svk --exclude .svn --link-dest=$(DIR_ORIG)/ -a $(DIR_ORIG)/ . $(DIR_ORIG): ifeq ($(TAR_ORIG),) $(error Cannot find orig tarball $(TAR_ORIG_NAME)) else mkdir -p ../orig tar -C ../orig -xzf $(TAR_ORIG) endif