build.mk 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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_*/w-busybox*/busybox*/.configure_done ];then \
  32. rm build_*/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. mv .cfg .cfg.${DEVICE}
  83. if [ -f .config.${DEV} ];then cp .config.${DEV} .config; \
  84. cp .config.${DEV} .config.old; \
  85. mv .cfg.${DEV} .cfg; \
  86. echo "Setting configuration to device: ${DEV}"; \
  87. else echo "No old device config found";mv .config .config.bak;fi
  88. #############################################################
  89. #
  90. # Cleanup and misc junk
  91. #
  92. #############################################################
  93. root_clean:
  94. @$(TRACE) root_clean
  95. rm -rf $(TARGET_DIR)
  96. # Do a per-package clean here, too. This way stale headers and
  97. # libraries from cross_*/target/ get wiped away, which keeps
  98. # future package build's configure scripts from returning false
  99. # dependencies information.
  100. clean:
  101. @$(TRACE) clean
  102. $(MAKE) -C $(CONFIG) clean
  103. for d in ${STAGING_PARENT_PFX}; do \
  104. echo "clean: entering $$d" ; \
  105. for f in $$(ls $$d/pkg/[a-z]* 2>/dev/null); do \
  106. echo "clean: cleaning for $$f" ; \
  107. while read file ; do \
  108. rm $$d/target/$$file ; \
  109. done < $$f ; \
  110. rm $$f ; \
  111. done \
  112. done
  113. rm -rf $(BUILD_DIR) $(BIN_DIR) $(TARGET_DIR) ${TOPDIR}/.cfg
  114. rm -f ${TOPDIR}/package/*/info.mk
  115. cleankernel:
  116. @$(TRACE) cleankernel
  117. rm -rf $(TOOLCHAIN_BUILD_DIR)/linux* $(BUILD_DIR)/linux
  118. cleandir:
  119. @$(TRACE) cleandir
  120. $(MAKE) -C $(CONFIG) clean
  121. rm -rf $(BUILD_DIR_PFX) $(BIN_DIR_PFX) $(TARGET_DIR_PFX) ${TOPDIR}/.cfg
  122. rm -rf $(TOOLCHAIN_BUILD_DIR_PFX) $(STAGING_PARENT_PFX) $(TOOLS_BUILD_DIR)
  123. rm -f .tmpconfig.h ${TOPDIR}/package/*/info.mk
  124. cleandevice:
  125. @$(TRACE) cleandevice
  126. $(MAKE) -C $(CONFIG) clean
  127. rm -rf $(BUILD_DIR) $(BIN_DIR) $(TARGET_DIR) ${TOPDIR}/.cfg
  128. rm -rf $(TOOLCHAIN_BUILD_DIR) $(STAGING_PARENT)
  129. rm -f .tmpconfig.h ${TOPDIR}/package/*/info.mk
  130. distclean:
  131. @$(TRACE) distclean
  132. $(MAKE) -C $(CONFIG) clean
  133. rm -rf $(BUILD_DIR_PFX) $(BIN_DIR_PFX) $(TARGET_DIR_PFX) $(DISTDIR) ${TOPDIR}/.cfg
  134. rm -rf $(TOOLCHAIN_BUILD_DIR_PFX) $(STAGING_PARENT_PFX) $(TOOLS_BUILD_DIR)
  135. rm -f .config* .tmpconfig.h ${TOPDIR}/package/*/info.mk
  136. else # ifeq ($(strip $(ADK_HAVE_DOT_CONFIG)),y)
  137. include $(TOPDIR)/prereq.mk
  138. all: menuconfig
  139. @echo "Start the build with \"make\" or with \"make v\" to be verbose"
  140. # configuration
  141. # ---------------------------------------------------------------------------
  142. # force entering the subdir, as dependency checking is done there
  143. .PHONY: $(CONFIG)/conf $(CONFIG)/mconf
  144. $(CONFIG)/conf:
  145. @$(MAKE) -C $(CONFIG) conf
  146. $(CONFIG)/mconf:
  147. @$(MAKE) -C $(CONFIG)
  148. menuconfig: $(CONFIG)/mconf
  149. @$(CONFIG)/mconf $(CONFIG_CONFIG_IN)
  150. ${POSTCONFIG}
  151. _config: $(CONFIG)/conf
  152. -@touch .config
  153. @$(CONFIG)/conf ${W} $(CONFIG_CONFIG_IN) >/dev/null
  154. ${POSTCONFIG}
  155. .NOTPARALLEL: _mconfig
  156. _mconfig: ${CONFIG}/conf _mconfig2 _config
  157. _mconfig2: ${CONFIG}/conf
  158. @${CONFIG}/conf -m ${RCONFIG} >/dev/null
  159. distclean:
  160. @$(MAKE) -C $(CONFIG) clean
  161. rm -rf $(BUILD_DIR) $(TOOLS_BUILD_DIR) $(BIN_DIR) $(DISTDIR) ${TOPDIR}/.cfg
  162. rm -rf $(TOOLCHAIN_BUILD_DIR) $(STAGING_PARENT) $(TARGET_DIR)
  163. rm -f .config* .tmpconfig.h ${TOPDIR}/package/*/info.mk
  164. endif # ifeq ($(strip $(ADK_HAVE_DOT_CONFIG)),y)