Makefile 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. tools-y :=
  12. tools-$(CONFIG_GCC_VERSION_4_3)$(CONFIG_GCC_VERSION_4_4) += gmp mpfr
  13. tools-y += m4 autoconf automake bison pkg-config sed
  14. tools-y += sstrip ipkg-utils genext2fs squashfs squashfs4 mtd-utils lzma-old mkimage
  15. tools-y += firmware-utils patch-cmdline quilt yaffs2
  16. tools-$(CONFIG_CCACHE) += ccache
  17. tools-$(CONFIG_powerpc) += dtc
  18. tools-dep += lzma
  19. # builddir dependencies
  20. $(curdir)/pkg-config/compile := $(curdir)/sed/install
  21. $(curdir)/squashfs/compile := $(curdir)/lzma-old/install
  22. $(curdir)/squashfs4/compile := $(curdir)/lzma/install
  23. $(curdir)/quilt/compile := $(curdir)/sed/install
  24. $(curdir)/dtc/compile := $(curdir)/bison/install
  25. $(curdir)/autoconf/compile := $(curdir)/m4/install
  26. $(curdir)/automake/compile := $(curdir)/m4/install $(curdir)/autoconf/install
  27. $(curdir)/mpfr/compile := $(curdir)/gmp/install
  28. $(curdir)/builddirs := $(tools-y) $(tools-dep) $(tools-)
  29. $(curdir)/builddirs-default := $(tools-y)
  30. define PrepareStaging
  31. @for dir in $(1); do ( \
  32. set -x; \
  33. mkdir -p "$$dir"; \
  34. cd "$$dir"; \
  35. mkdir -p bin lib include stamp; \
  36. ); done
  37. endef
  38. # preparatory work
  39. $(STAGING_DIR)/.prepared: $(TMP_DIR)/.build
  40. $(call PrepareStaging,$(STAGING_DIR))
  41. mkdir -p $(BUILD_DIR)/stamp
  42. touch $@
  43. $(STAGING_DIR_HOST)/.prepared: $(TMP_DIR)/.build
  44. $(call PrepareStaging,$(STAGING_DIR_HOST))
  45. mkdir -p $(BUILD_DIR_HOST)/stamp
  46. $(INSTALL_DATA) $(TOPDIR)/tools/include/*.h $(STAGING_DIR_HOST)/include/
  47. touch $@
  48. define PrepareCommand
  49. $(STAGING_DIR_HOST)/bin/$(1): $(STAGING_DIR)/.prepared
  50. @mkdir -p "$$(dir $$@)"; rm -f "$$@"
  51. @export FILE="$$$$(which $(2) 2>/dev/null | grep -v 'not found' | head -n1)"; [ -n "$$$$FILE" ] || { \
  52. echo "Command $(1) not found."; false; \
  53. }; ln -s "$$$$FILE" "$$@"
  54. endef
  55. $(eval $(call PrepareCommand,find,gfind find))
  56. $(eval $(call PrepareCommand,md5sum,md5sum $(SCRIPT_DIR)/md5sum))
  57. $(eval $(call PrepareCommand,cp,gcp cp))
  58. $(eval $(call PrepareCommand,stat,gstat stat))
  59. $(curdir)/cmddeps = $(patsubst %,$(STAGING_DIR_HOST)/bin/%,find md5sum cp stat)
  60. $(curdir)//prepare = $(STAGING_DIR)/.prepared $(STAGING_DIR_HOST)/.prepared $($(curdir)/cmddeps)
  61. $(curdir)//compile = $(STAGING_DIR)/.prepared $(STAGING_DIR_HOST)/.prepared $($(curdir)/cmddeps)
  62. # prerequisites for the individual targets
  63. $(curdir)/ := .config prereq
  64. $(curdir)//install = $(1)/compile
  65. $(eval $(call stampfile,$(curdir),tools,install,,CONFIG_CCACHE CONFIG_powerpc CONFIG_GCC_VERSION_4_3))
  66. $(eval $(call subdir,$(curdir)))