build.mk 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. # This file is part of the OpenADK project. OpenADK is copyrighted
  2. # material, please see the LICENCE file in the top-level directory.
  3. TOPDIR=$(shell pwd)
  4. export TOPDIR
  5. ifneq ($(shell umask 2>/dev/null | sed 's/0*022/OK/'),OK)
  6. $(error your umask is not 022)
  7. endif
  8. CONFIG_CONFIG_IN = Config.in
  9. CONFIG = config
  10. noconfig_targets:= menuconfig \
  11. _config \
  12. _mconfig \
  13. tags
  14. MAKECLEAN_SYMBOLS= ADK_TARGET_LIB_UCLIBC ADK_TARGET_LIB_GLIBC ADK_SSP \
  15. ADK_IPV6 ADK_CXX ADK_DEBUG
  16. POSTCONFIG= -@\
  17. if [ -f .config.old ];then \
  18. if [ -d .cfg ];then \
  19. what=cleandevice; \
  20. for symbol in ${MAKECLEAN_SYMBOLS}; do \
  21. newval=$$(grep -e "^$$symbol=" -e "^\# $$symbol " .config); \
  22. oldval=$$(cat .cfg/"$$symbol" 2>&-); \
  23. [[ $$newval = $$oldval ]] && continue; \
  24. echo; \
  25. echo >&2 "WARNING: Toolchain related options have changed, 'make" \
  26. "$$what' might be required!"; \
  27. break; \
  28. done; \
  29. fi; \
  30. if [ "$$(grep ^BUSYBOX .config|md5sum)" != "$$(grep ^BUSYBOX .config.old|md5sum)" ];then \
  31. if [ -f build_$(CPU_ARCH)/w-busybox*/busybox*/.configure_done ];then \
  32. rm build_$(CPU_ARCH)/w-busybox*/busybox*/.configure_done; \
  33. fi; \
  34. fi; \
  35. fi
  36. # Pull in the user's configuration file
  37. ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
  38. -include $(TOPDIR)/.config
  39. endif
  40. ifeq ($(strip $(ADK_HAVE_DOT_CONFIG)),y)
  41. include $(TOPDIR)/rules.mk
  42. include ${TOPDIR}/mk/split-cfg.mk
  43. all: world
  44. .NOTPARALLEL:
  45. .PHONY: all world clean cleandevice cleandir distclean image_clean
  46. world: $(DISTDIR) $(BUILD_DIR) $(TARGET_DIR) $(PACKAGE_DIR) ${TOPDIR}/.cfg/ADK_HAVE_DOT_CONFIG
  47. ${BASH} ${TOPDIR}/scripts/scan-pkgs.sh
  48. ifeq ($(ADK_NATIVE),y)
  49. $(MAKE) -f mk/build.mk toolchain/kernel-headers-prepare target/config-prepare target/compile package/compile root_clean package/install package_index target/install
  50. else
  51. $(MAKE) -f mk/build.mk toolchain/install target/config-prepare target/compile package/compile root_clean package/install package_index target/install
  52. endif
  53. package_index:
  54. -cd ${PACKAGE_DIR} && \
  55. ${BASH} ${TOPDIR}/scripts/ipkg-make-index.sh . >Packages
  56. $(DISTDIR):
  57. mkdir -p $(DISTDIR)
  58. $(BUILD_DIR):
  59. mkdir -p $(BUILD_DIR)
  60. $(TARGET_DIR):
  61. mkdir -p $(TARGET_DIR)
  62. $(PACKAGE_DIR):
  63. mkdir -p ${PACKAGE_DIR}/.stamps
  64. ${STAGING_DIR} ${STAGING_DIR}/etc ${STAGING_TOOLS}:
  65. mkdir -p ${STAGING_DIR}/{bin,etc,include,lib,usr} \
  66. ${STAGING_TOOLS}/{bin,lib}
  67. cd ${STAGING_DIR}/usr; ln -s ../include include
  68. ${STAGING_DIR}/etc/ipkg.conf: ${STAGING_DIR}/etc
  69. echo "dest root /" >${STAGING_DIR}/etc/ipkg.conf
  70. echo "option offline_root ${TARGET_DIR}" >>$(STAGING_DIR)/etc/ipkg.conf
  71. package/%: ${TOPDIR}/.cfg/ADK_HAVE_DOT_CONFIG ${STAGING_DIR}/etc/ipkg.conf
  72. $(MAKE) -C package $(patsubst package/%,%,$@)
  73. target/%: ${TOPDIR}/.cfg/ADK_HAVE_DOT_CONFIG
  74. $(MAKE) -C target $(patsubst target/%,%,$@)
  75. toolchain/%: ${STAGING_DIR}
  76. $(MAKE) -C toolchain $(patsubst toolchain/%,%,$@)
  77. image:
  78. $(MAKE) -C target image
  79. switch:
  80. echo "Saving configuration for device: ${DEVICE}"
  81. cp .config .config.${DEVICE}
  82. if [ -f .config.${DEV} ];then cp .config.${DEV} .config; \
  83. cp .config.${DEV} .config.old; \
  84. echo "Setting configuration to device: ${DEV}"; \
  85. else echo "No old device config found";mv .config .config.bak;fi
  86. #############################################################
  87. #
  88. # Cleanup and misc junk
  89. #
  90. #############################################################
  91. root_clean:
  92. @$(TRACE) root_clean
  93. rm -rf $(TARGET_DIR)
  94. clean:
  95. @$(TRACE) clean
  96. $(MAKE) -C $(CONFIG) clean
  97. rm -rf $(BUILD_DIR) $(BIN_DIR) $(TARGET_DIR) ${TOPDIR}/.cfg
  98. rm -f ${TOPDIR}/package/*/info.mk
  99. cleankernel:
  100. @$(TRACE) cleankernel
  101. rm -rf $(TOOLCHAIN_BUILD_DIR)/linux* $(BUILD_DIR)/linux
  102. cleandir:
  103. @$(TRACE) cleandir
  104. $(MAKE) -C $(CONFIG) clean
  105. rm -rf $(BUILD_DIR_PFX) $(BIN_DIR_PFX) $(TARGET_DIR_PFX) ${TOPDIR}/.cfg
  106. rm -rf $(TOOLCHAIN_BUILD_DIR_PFX) $(STAGING_PARENT_PFX) $(TOOLS_BUILD_DIR)
  107. rm -f .tmpconfig.h ${TOPDIR}/package/*/info.mk
  108. cleandevice:
  109. @$(TRACE) cleandevice
  110. $(MAKE) -C $(CONFIG) clean
  111. rm -rf $(BUILD_DIR) $(BIN_DIR) $(TARGET_DIR) ${TOPDIR}/.cfg
  112. rm -rf $(TOOLCHAIN_BUILD_DIR) $(STAGING_PARENT)
  113. rm -f .tmpconfig.h ${TOPDIR}/package/*/info.mk
  114. distclean:
  115. @$(TRACE) distclean
  116. $(MAKE) -C $(CONFIG) clean
  117. rm -rf $(BUILD_DIR_PFX) $(BIN_DIR_PFX) $(TARGET_DIR_PFX) $(DISTDIR) ${TOPDIR}/.cfg
  118. rm -rf $(TOOLCHAIN_BUILD_DIR_PFX) $(STAGING_PARENT_PFX) $(TOOLS_BUILD_DIR)
  119. rm -f .config* .tmpconfig.h ${TOPDIR}/package/*/info.mk
  120. else # ifeq ($(strip $(ADK_HAVE_DOT_CONFIG)),y)
  121. include $(TOPDIR)/prereq.mk
  122. all: menuconfig
  123. @echo "Start the build with \"make\" or with \"make v\" to be verbose"
  124. # configuration
  125. # ---------------------------------------------------------------------------
  126. $(CONFIG)/conf:
  127. @$(MAKE) -C $(CONFIG) conf
  128. $(CONFIG)/mconf:
  129. @$(MAKE) -C $(CONFIG)
  130. menuconfig: $(CONFIG)/mconf
  131. @$(CONFIG)/mconf $(CONFIG_CONFIG_IN)
  132. ${POSTCONFIG}
  133. _config: $(CONFIG)/conf
  134. -@touch .config
  135. @$(CONFIG)/conf ${W} $(CONFIG_CONFIG_IN) >/dev/null
  136. ${POSTCONFIG}
  137. .NOTPARALLEL: _mconfig
  138. _mconfig: ${CONFIG}/conf _mconfig2 _config
  139. _mconfig2: ${CONFIG}/conf
  140. @${CONFIG}/conf -M ${RCONFIG} >/dev/null
  141. distclean:
  142. @$(MAKE) -C $(CONFIG) clean
  143. rm -rf $(BUILD_DIR) $(TOOLS_BUILD_DIR) $(BIN_DIR) $(DISTDIR) ${TOPDIR}/.cfg
  144. rm -rf $(TOOLCHAIN_BUILD_DIR) $(STAGING_PARENT) $(TARGET_DIR)
  145. rm -f .config* .tmpconfig.h ${TOPDIR}/package/*/info.mk
  146. endif # ifeq ($(strip $(ADK_HAVE_DOT_CONFIG)),y)