Makefile 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #
  2. # Copyright (C) 2007 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. # Main makefile for the host tools
  8. #
  9. curdir:=tools
  10. # subdirectories to descend into
  11. $(curdir)/builddirs := sed sstrip ipkg-utils genext2fs squashfs mtd-utils lzma mkimage firmware-utils patch-cmdline pkg-config automake $(if $(CONFIG_CCACHE),ccache) bison $(if $(CONFIG_powerpc),dtc) quilt autoconf $(if $(CONFIG_GCC_VERSION_4_3),gmp mpfr) yaffs2
  12. # builddir dependencies
  13. $(curdir)/squashfs/compile := $(curdir)/lzma/install
  14. $(curdir)/quilt/compile := $(curdir)/sed/install
  15. $(curdir)/dtc/compile := $(curdir)/bison/install
  16. # preparatory work
  17. $(STAGING_DIR)/.prepared: $(TMP_DIR)/.build
  18. @for dir in $(STAGING_DIR) $(STAGING_DIR_HOST); do ( \
  19. set -x; \
  20. mkdir -p "$$dir"; \
  21. cd "$$dir"; \
  22. mkdir -p bin lib include stamp; \
  23. ); done
  24. mkdir -p $(BUILD_DIR_HOST)/stamp $(BUILD_DIR)/stamp
  25. $(INSTALL_DATA) $(TOPDIR)/tools/include/*.h $(STAGING_DIR_HOST)/include/
  26. touch $@
  27. define PrepareCommand
  28. $(STAGING_DIR_HOST)/bin/$(1): $(STAGING_DIR)/.prepared
  29. @mkdir -p "$$(dir $$@)"; rm -f "$$@"
  30. @export FILE="$$$$(which $(2) 2>/dev/null | grep -v 'not found' | head -n1)"; [ -n "$$$$FILE" ] || { \
  31. echo "Command $(1) not found."; false; \
  32. }; ln -s "$$$$FILE" "$$@"
  33. endef
  34. $(eval $(call PrepareCommand,find,gfind find))
  35. $(eval $(call PrepareCommand,md5sum,md5sum $(SCRIPT_DIR)/md5sum))
  36. $(eval $(call PrepareCommand,cp,gcp cp))
  37. $(eval $(call PrepareCommand,stat,gstat stat))
  38. $(curdir)/cmddeps = $(patsubst %,$(STAGING_DIR_HOST)/bin/%,find md5sum cp stat)
  39. $(curdir)//prepare = $(STAGING_DIR)/.prepared $($(curdir)/cmddeps)
  40. $(curdir)//compile = $(STAGING_DIR)/.prepared $($(curdir)/cmddeps)
  41. # prerequisites for the individual targets
  42. $(curdir)/ := .config prereq
  43. $(curdir)//install = $(1)/compile
  44. $(eval $(call stampfile,$(curdir),tools,install))
  45. $(eval $(call subdir,$(curdir)))