build.mk 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  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 = adk/config
  10. DEFCONFIG= ADK_DEBUG=n \
  11. ADK_STATIC=n \
  12. ADK_WGET_TIMEOUT=180 \
  13. ADK_MAKE_PARALLEL=y \
  14. ADK_MAKE_JOBS=4 \
  15. ADK_LEAVE_ETC_ALONE=n \
  16. ADK_SIMPLE_NETWORK_CONFIG=n \
  17. ADK_USE_CCACHE=n \
  18. ADK_RUNTIME_START_SERVICES=n \
  19. ADK_PACKAGE_BASE_FILES=y \
  20. ADK_PACKAGE_E2FSCK_STATIC=n \
  21. ADK_PACKAGE_KEXECINIT=n \
  22. ADK_PACKAGE_LM_SENSORS_DETECT=n \
  23. ADK_PACKAGE_PACEMAKER=n \
  24. ADK_PACKAGE_PACEMAKER_MGMTD=n \
  25. ADK_PACKAGE_PACEMAKER_PYTHON_GUI=n \
  26. ADK_PACKAGE_CLASSPATH=n \
  27. ADK_PACKAGE_GRUB=n \
  28. ADK_PACKAGE_U_BOOT=n \
  29. ADK_PACKAGE_CRYPTINIT=n \
  30. ADK_PACKAGE_VIRTINST=n \
  31. ADK_PACKAGE_URLGRABBER=n \
  32. ADK_PACKAGE_LIBSSP=n \
  33. ADK_PACKAGE_OPENAFS=n \
  34. ADK_PKG_XORG=n \
  35. ADK_PKG_CONSOLE=n \
  36. ADK_PKG_TEST=n \
  37. ADK_PKG_MPDBOX=n \
  38. ADK_PKG_DEVELOPMENT=n \
  39. ADK_TOOLCHAIN_USE_SSP=n \
  40. ADK_TOOLCHAIN_USE_LTO=n \
  41. ADK_TOOLCHAIN_GOLD=n \
  42. ADK_TOOLCHAIN_USE_GOLD=n \
  43. BUSYBOX_IFPLUGD=n \
  44. BUSYBOX_EXTRA_COMPAT=n \
  45. BUSYBOX_FEATURE_IFCONFIG_SLIP=n \
  46. BUSYBOX_BBCONFIG=n \
  47. BUSYBOX_SELINUX=n \
  48. BUSYBOX_INSTALL_NO_USR=n \
  49. BUSYBOX_MODPROBE_SMALL=n \
  50. BUSYBOX_EJECT=n \
  51. BUSYBOX_UBIDETACH=n \
  52. BUSYBOX_UBIATTACH=n \
  53. BUSYBOX_BUILD_LIBBUSYBOX=n \
  54. BUSYBOX_FEATURE_2_4_MODULES=n \
  55. BUSYBOX_LOCALE_SUPPORT=n \
  56. BUSYBOX_FEATURE_PREFER_APPLETS=n \
  57. BUSYBOX_FEATURE_SUID=n \
  58. BUSYBOX_SELINUXENABLED=n \
  59. BUSYBOX_FEATURE_INSTALLER=n \
  60. BUSYBOX_PAM=n \
  61. BUSYBOX_FLASH_LOCK=n \
  62. BUSYBOX_FLASH_UNLOCK=n \
  63. BUSYBOX_FLASH_ERASEALL=n \
  64. BUSYBOX_PIE=n \
  65. BUSYBOX_TASKSET=n \
  66. BUSYBOX_DEBUG=n \
  67. BUSYBOX_NOMMU=n \
  68. BUSYBOX_WERROR=n \
  69. BUSYBOX_STATIC=n \
  70. BUSYBOX_FEATURE_AIX_LABEL=n \
  71. BUSYBOX_FEATURE_SUN_LABEL=n \
  72. BUSYBOX_FEATURE_OSF_LABEL=n \
  73. BUSYBOX_FEATURE_SGI_LABEL=n \
  74. BUSYBOX_FEATURE_INETD_RPC=n \
  75. BUSYBOX_FEATURE_MOUNT_NFS=n \
  76. BUSYBOX_FEATURE_VI_REGEX_SEARCH=n \
  77. ADK_KERNEL_RT2X00_DEBUG=n \
  78. ADK_KERNEL_ATH5K_DEBUG=n \
  79. ADK_KERNEL_BUG=n \
  80. ADK_KERNEL_DEBUG_WITH_KGDB=n
  81. noconfig_targets:= menuconfig \
  82. _config \
  83. _mconfig \
  84. distclean \
  85. defconfig \
  86. tags
  87. POSTCONFIG= -@\
  88. if [ -f .adkinit ];then rm .adkinit;\
  89. else \
  90. if [ -f .config.old ];then \
  91. $(TOPDIR)/adk/tools/pkgrebuild;\
  92. rebuild=0; \
  93. if [ "$$(grep ^BUSYBOX .config|md5sum)" != "$$(grep ^BUSYBOX .config.old|md5sum)" ];then \
  94. touch .rebuild.busybox;\
  95. rebuild=1;\
  96. fi; \
  97. for i in ADK_RUNTIME_PASSWORD ADK_RUNTIME_TMPFS_SIZE ADK_RUNTIME_HOSTNAME ADK_TARGET_ROOTFS ADK_RUNTIME_CONSOLE ADK_RUNTIME_GETTY ADK_RUNTIME_SHELL;do \
  98. if [ "$$(grep ^$$i .config|md5sum)" != "$$(grep ^$$i .config.old|md5sum)" ];then \
  99. touch .rebuild.base-files;\
  100. rebuild=1;\
  101. fi; \
  102. done; \
  103. if [ "$$(grep ^ADK_RUNTIME_TIMEZONE .config|md5sum)" != "$$(grep ^ADK_RUNTIME_TIMEZONE .config.old|md5sum)" ];then \
  104. touch .rebuild.musl .rebuild.uclibc .rebuild.glibc;\
  105. rebuild=1;\
  106. fi; \
  107. if [ "$$(grep ^ADK_RUNTIME_SSH_PUBKEY .config|md5sum)" != "$$(grep ^ADK_RUNTIME_SSH_PUBKEY .config.old|md5sum)" ];then \
  108. touch .rebuild.dropbear .rebuild.openssh;\
  109. rebuild=1;\
  110. fi; \
  111. if [ "$$(grep ^ADK_RUNTIME_KBD_LAYOUT .config|md5sum)" != "$$(grep ^ADK_RUNTIME_KBD_LAYOUT .config.old|md5sum)" ];then \
  112. touch .rebuild.bkeymaps;\
  113. rebuild=1;\
  114. fi; \
  115. if [ "$$(grep ^ADK_KERNEL_VERSION_ .config|md5sum)" != "$$(grep ^ADK_KERNEL_VERSION_ .config.old|md5sum)" ];then \
  116. make kernelclean;\
  117. fi; \
  118. if [ "$$(grep ^ADK_LINUX_ARM_WITH_THUMB .config|md5sum)" != "$$(grep ^ADK_LINUX_ARM_WITH_THUMB .config.old|md5sum)" ];then \
  119. echo "You should make cleandir, after changing thumb mode";\
  120. fi; \
  121. if [ $$rebuild -eq 1 ];then \
  122. cp .config .config.old;\
  123. fi; \
  124. fi; \
  125. fi
  126. # Pull in the user's configuration file
  127. ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
  128. -include $(TOPDIR)/.config
  129. endif
  130. ifeq ($(strip $(ADK_HAVE_DOT_CONFIG)),y)
  131. include $(TOPDIR)/rules.mk
  132. all: world
  133. ${TOPDIR}/package/Depends.mk: ${TOPDIR}/.config $(wildcard ${TOPDIR}/package/*/Makefile) $(TOPDIR)/adk/tools/depmaker
  134. $(TOPDIR)/adk/tools/depmaker > ${TOPDIR}/package/Depends.mk
  135. .NOTPARALLEL:
  136. .PHONY: all world clean cleandir cleantoolchain distclean image_clean
  137. world:
  138. mkdir -p $(DL_DIR) $(HOST_BUILD_DIR) $(BUILD_DIR) $(TARGET_DIR) $(FW_DIR) \
  139. $(STAGING_HOST_DIR) $(TOOLCHAIN_BUILD_DIR) $(STAGING_PKG_DIR)/stamps
  140. ${BASH} ${TOPDIR}/scripts/scan-pkgs.sh
  141. ${BASH} ${TOPDIR}/scripts/update-sys
  142. ${BASH} ${TOPDIR}/scripts/update-pkg
  143. ifeq ($(ADK_TOOLCHAIN),y)
  144. ifeq ($(ADK_TOOLCHAIN_ONLY),y)
  145. $(MAKE) -f mk/build.mk package/hostcompile toolchain/fixup package/compile
  146. else
  147. $(MAKE) -f mk/build.mk package/hostcompile toolchain/fixup package/compile root_clean package/install
  148. endif
  149. else
  150. $(MAKE) -f mk/build.mk package/hostcompile toolchain/fixup target/config-prepare target/compile package/compile root_clean package/install target/install package_index
  151. endif
  152. package_index:
  153. ifeq ($(ADK_TARGET_PACKAGE_IPKG),y)
  154. -cd ${PACKAGE_DIR} && \
  155. ${BASH} ${TOPDIR}/scripts/ipkg-make-index.sh . >Packages
  156. endif
  157. ${STAGING_TARGET_DIR} ${STAGING_TARGET_DIR}/etc ${STAGING_HOST_DIR}:
  158. mkdir -p ${STAGING_TARGET_DIR}/{bin,etc,lib,usr/bin,usr/include,usr/lib/pkgconfig} \
  159. ${STAGING_HOST_DIR}/{usr/bin,usr/lib,usr/include}
  160. for i in lib64 lib32 libx32;do \
  161. cd ${STAGING_TARGET_DIR}/; ln -sf lib $$i; \
  162. cd ${STAGING_TARGET_DIR}/usr; ln -sf lib $$i; \
  163. done
  164. ${STAGING_TARGET_DIR}/etc/ipkg.conf: ${STAGING_TARGET_DIR}/etc
  165. ifeq ($(ADK_TARGET_PACKAGE_IPKG),y)
  166. echo "dest root /" >${STAGING_TARGET_DIR}/etc/ipkg.conf
  167. echo "option offline_root ${TARGET_DIR}" >>$(STAGING_TARGET_DIR)/etc/ipkg.conf
  168. endif
  169. package/%: ${STAGING_TARGET_DIR}/etc/ipkg.conf ${TOPDIR}/package/Depends.mk
  170. $(MAKE) -C package $(patsubst package/%,%,$@)
  171. target/%:
  172. $(MAKE) -C target $(patsubst target/%,%,$@)
  173. toolchain/%: ${STAGING_TARGET_DIR}
  174. $(MAKE) -C toolchain $(patsubst toolchain/%,%,$@)
  175. image:
  176. $(MAKE) -C target image
  177. switch:
  178. if [ -f .config ];then \
  179. echo "Saving configuration for target system: ${ADK_TARGET_SYSTEM} with arch: ${ADK_TARGET_ARCH}";\
  180. cp -p .config .config.${ADK_TARGET_ARCH}_${ADK_TARGET_SYSTEM};\
  181. fi
  182. if [ -f .config.old ];then cp -p .config.old .config.old.${ADK_TARGET_ARCH}_${ADK_TARGET_SYSTEM};fi
  183. if [ -f .config.${ARCH}_${SYSTEM} ];then \
  184. cp -p .config.${ARCH}_${SYSTEM} .config; \
  185. cp -p .config.old.${ARCH}_${SYSTEM} .config.old; \
  186. $(MAKE) dep; rm .rebuild.* 2>/dev/null ; \
  187. echo "Setting configuration to target system: ${SYSTEM} with arch: ${ARCH}"; \
  188. else \
  189. echo "No old target config found" ;\
  190. mv .config .config.bak ; mv .config.old .config.old.bak; rm .rebuild.* 2>/dev/null ; \
  191. if [ ! -z "$(SYSTEM)" ];then \
  192. make ARCH=${ARCH} SYSTEM=${SYSTEM} menuconfig; \
  193. else \
  194. make menuconfig; \
  195. fi \
  196. fi
  197. kernelconfig:
  198. ${KERNEL_MAKE_ENV} ${MAKE} \
  199. ARCH=$(ARCH) \
  200. ${KERNEL_MAKE_OPTS} \
  201. -C $(BUILD_DIR)/linux menuconfig
  202. # create a new package from package/.template
  203. newpackage:
  204. @echo "Creating new package $(PKG)"
  205. $(CP) $(TOPDIR)/package/.template$(TYPE) $(TOPDIR)/package/$(PKG)
  206. pkg=$$(echo $(PKG)|tr '[:lower:]-' '[:upper:]_'); \
  207. $(SED) "s#@UPKG@#$$pkg#" $(TOPDIR)/package/$(PKG)/Makefile
  208. $(SED) 's#@PKG@#$(PKG)#' $(TOPDIR)/package/$(PKG)/Makefile
  209. $(SED) 's#@VER@#$(VER)#' $(TOPDIR)/package/$(PKG)/Makefile
  210. @echo "Edit package/$(PKG)/Makefile to complete"
  211. root_clean:
  212. @$(TRACE) root_clean
  213. rm -rf $(TARGET_DIR)
  214. mkdir -p $(TARGET_DIR)
  215. touch $(TARGET_DIR)/.adk
  216. # Do a per-package clean here, too. This way stale headers and
  217. # libraries from target_*/ get wiped away, which keeps
  218. # future package build's configure scripts from returning false
  219. # dependencies information.
  220. clean:
  221. @$(TRACE) clean
  222. $(MAKE) -C $(CONFIG) clean
  223. for f in $$(ls ${STAGING_PKG_DIR}/ 2>/dev/null |grep -v [A-Z]|grep -v stamps 2>/dev/null); do \
  224. while read file ; do \
  225. rm ${STAGING_TARGET_DIR}/$$file 2>/dev/null;\
  226. done < ${STAGING_PKG_DIR}/$$f ; \
  227. rm ${STAGING_PKG_DIR}/$$f ; \
  228. done
  229. rm -rf $(BUILD_DIR) $(FW_DIR) $(TARGET_DIR) \
  230. ${TOPDIR}/package/pkglist.d
  231. rm -f ${TOPDIR}/package/Depends.mk
  232. cleankernel:
  233. @$(TRACE) cleankernel
  234. rm -rf $(TOOLCHAIN_BUILD_DIR)/w-linux* $(BUILD_DIR)/linux
  235. cleandir:
  236. @$(TRACE) cleandir
  237. @$(MAKE) -C $(CONFIG) clean $(MAKE_TRACE)
  238. rm -rf $(BUILD_DIR_PFX) $(FW_DIR_PFX) $(TARGET_DIR_PFX) \
  239. ${TOPDIR}/package/pkglist.d ${TOPDIR}/package/pkgconfigs.d
  240. rm -rf $(TOOLCHAIN_DIR_PFX) $(STAGING_HOST_DIR_PFX)
  241. rm -rf $(STAGING_TARGET_DIR_PFX) $(STAGING_PKG_DIR_PFX)
  242. rm -f .menu .tmpconfig.h .rebuild* ${TOPDIR}/package/Depends.mk ${TOPDIR}/prereq.mk
  243. cleantoolchain:
  244. @$(TRACE) cleantoolchain
  245. @rm -rf $(BUILD_DIR_PFX) $(TARGET_DIR_PFX) \
  246. ${TOPDIR}/package/pkglist.d ${TOPDIR}/package/pkgconfigs.d
  247. @rm -rf $(TOOLCHAIN_DIR_PFX) $(STAGING_HOST_DIR_PFX)
  248. @rm -rf $(STAGING_TARGET_DIR_PFX) $(STAGING_PKG_DIR_PFX)
  249. @rm -f .menu .tmpconfig.h .rebuild* ${TOPDIR}/package/Depends.mk
  250. distclean:
  251. @$(TRACE) distclean
  252. @$(MAKE) -C $(CONFIG) clean $(MAKE_TRACE)
  253. @rm -rf $(BUILD_DIR_PFX) $(FW_DIR_PFX) $(TARGET_DIR_PFX) $(DL_DIR) \
  254. ${TOPDIR}/package/pkglist.d ${TOPDIR}/package/pkgconfigs.d
  255. @rm -rf $(TOOLCHAIN_DIR_PFX) $(STAGING_HOST_DIR_PFX)
  256. @rm -rf $(STAGING_TARGET_DIR_PFX) $(STAGING_PKG_DIR_PFX)
  257. @rm -f .adkinit .config* .defconfig .tmpconfig.h all.config ${TOPDIR}/prereq.mk \
  258. .menu ${TOPDIR}/package/Depends.mk .ADK_HAVE_DOT_CONFIG .rebuild.*
  259. else # ! ifeq ($(strip $(ADK_HAVE_DOT_CONFIG)),y)
  260. ifeq ($(filter-out distclean,${MAKECMDGOALS}),)
  261. include ${TOPDIR}/mk/vars.mk
  262. else
  263. include $(TOPDIR)/prereq.mk
  264. export BASH MAKE LANGUAGE LC_ALL OStype PATH CC_FOR_BUILD QEMU SHELL
  265. endif
  266. all: menuconfig
  267. @echo "Start the build with \"make\" or with \"make v\" to be verbose"
  268. # configuration
  269. # ---------------------------------------------------------------------------
  270. # force entering the subdir, as dependency checking is done there
  271. .PHONY: $(CONFIG)/conf $(CONFIG)/mconf
  272. $(CONFIG)/conf:
  273. @$(MAKE) -C $(CONFIG) conf
  274. $(CONFIG)/mconf:
  275. @$(MAKE) -C $(CONFIG)
  276. defconfig: .menu $(CONFIG)/conf
  277. @${BASH} ${TOPDIR}/scripts/update-sys
  278. @${BASH} ${TOPDIR}/scripts/update-pkg
  279. ifeq (${OStype},Linux)
  280. @echo ADK_HOST_LINUX=y > $(TOPDIR)/.defconfig
  281. endif
  282. ifeq (${OStype},FreeBSD)
  283. @echo ADK_HOST_FREEBSD=y > $(TOPDIR)/.defconfig
  284. endif
  285. ifeq (${OStype},MirBSD)
  286. @echo ADK_HOST_MIRBSD=y > $(TOPDIR)/.defconfig
  287. endif
  288. ifeq (${OStype},OpenBSD)
  289. @echo ADK_HOST_OPENBSD=y > $(TOPDIR)/.defconfig
  290. endif
  291. ifeq (${OStype},NetBSD)
  292. @echo ADK_HOST_NETBSD=y > $(TOPDIR)/.defconfig
  293. endif
  294. ifeq (${OStype},Darwin)
  295. @echo ADK_HOST_DARWIN=y > $(TOPDIR)/.defconfig
  296. endif
  297. ifneq (,$(filter CYGWIN%,${OStype}))
  298. @echo ADK_HOST_CYGWIN=y > $(TOPDIR)/.defconfig
  299. endif
  300. @echo 'source "target/config/Config.in.arch.default"' > target/config/Config.in.arch
  301. @echo 'source "target/config/Config.in.arch.choice"' >> target/config/Config.in.arch
  302. @echo 'source "target/config/Config.in.system.default"' > target/config/Config.in.system
  303. @echo 'source "target/config/Config.in.system.choice"' >> target/config/Config.in.system
  304. @if [ ! -z "$(ARCH)" ];then \
  305. grep "^config" target/config/Config.in.arch.choice \
  306. |grep -i "$(ARCH)"\$$ \
  307. |sed -e "s#^config \(.*\)#\1=y#" \
  308. >> $(TOPDIR)/.defconfig; \
  309. fi
  310. @for symbol in ${DEFCONFIG}; do \
  311. echo $$symbol >> $(TOPDIR)/.defconfig; \
  312. done
  313. @if [ ! -z "$(FS)" ];then \
  314. grep "^config" target/config/Config.in \
  315. |grep -i "$(FS)" \
  316. |sed -e "s#^config \(.*\)#\1=y#" \
  317. >> $(TOPDIR)/.defconfig; \
  318. fi
  319. @if [ ! -z "$(COLLECTION)" ];then \
  320. grep -h "^config" target/packages/pkg-available/* \
  321. |grep -i "$(COLLECTION)" \
  322. |sed -e "s#^config \(.*\)#\1=y#" \
  323. >> $(TOPDIR)/.defconfig; \
  324. fi
  325. @if [ ! -z "$(CLIB)" ];then \
  326. grep "^config" target/config/Config.in \
  327. |grep -i "$(CLIB)" \
  328. |sed -e "s#^config \(.*\)#\1=y#" \
  329. >> $(TOPDIR)/.defconfig; \
  330. fi
  331. @if [ ! -z "$(SYSTEM)" ];then \
  332. system=$$(echo "$(SYSTEM)" |sed -e "s/-/_/g"); \
  333. grep -h "^config" target/*/Config.in.systems \
  334. |grep -i "$$system$$" \
  335. |sed -e "s#^config \(.*\)#\1=y#" \
  336. >> $(TOPDIR)/.defconfig; \
  337. fi
  338. @if [ ! -z "$(SYSTEM)" ];then \
  339. $(CONFIG)/conf -D .defconfig $(CONFIG_CONFIG_IN); \
  340. fi
  341. modconfig:
  342. ifeq (${OStype},Linux)
  343. @echo ADK_HOST_LINUX=y > $(TOPDIR)/all.config
  344. endif
  345. ifeq (${OStype},FreeBSD)
  346. @echo ADK_HOST_FREEBSD=y > $(TOPDIR)/all.config
  347. endif
  348. ifeq (${OStype},MirBSD)
  349. @echo ADK_HOST_MIRBSD=y > $(TOPDIR)/all.config
  350. endif
  351. ifeq (${OStype},OpenBSD)
  352. @echo ADK_HOST_OPENBSD=y > $(TOPDIR)/all.config
  353. endif
  354. ifeq (${OStype},NetBSD)
  355. @echo ADK_HOST_NETBSD=y > $(TOPDIR)/all.config
  356. endif
  357. ifeq (${OStype},Darwin)
  358. @echo ADK_HOST_DARWIN=y > $(TOPDIR)/all.config
  359. endif
  360. ifneq (,$(filter CYGWIN%,${OStype}))
  361. @echo ADK_HOST_CYGWIN=y > $(TOPDIR)/all.config
  362. endif
  363. @echo 'source "target/config/Config.in.arch.default"' > target/config/Config.in.arch
  364. @echo 'source "target/config/Config.in.arch.choice"' >> target/config/Config.in.arch
  365. @echo 'source "target/config/Config.in.system.default"' > target/config/Config.in.system
  366. @echo 'source "target/config/Config.in.system.choice"' >> target/config/Config.in.system
  367. @if [ ! -z "$(ARCH)" ];then \
  368. grep "^config" target/config/Config.in.arch.choice \
  369. |grep -i "$(ARCH)"\$$ \
  370. |sed -e "s#^config \(.*\)#\1=y#" \
  371. >> $(TOPDIR)/all.config; \
  372. fi
  373. @for symbol in ${DEFCONFIG}; do \
  374. echo $$symbol >> $(TOPDIR)/all.config; \
  375. done
  376. @if [ ! -z "$(FS)" ];then \
  377. grep "^config" target/config/Config.in \
  378. |grep -i "$(FS)" \
  379. |sed -e "s#^config \(.*\)#\1=y#" \
  380. >> $(TOPDIR)/all.config; \
  381. fi
  382. @if [ ! -z "$(CLIB)" ];then \
  383. grep "^config" target/config/Config.in \
  384. |grep -i "$(CLIB)" \
  385. |sed -e "s#^config \(.*\)#\1=y#" \
  386. >> $(TOPDIR)/all.config; \
  387. fi
  388. @if [ ! -z "$(SYSTEM)" ];then \
  389. system=$$(echo "$(SYSTEM)" |sed -e "s/-/_/g"); \
  390. grep -h "^config" target/*/Config.in.systems \
  391. |grep -i "$$system" \
  392. |sed -e "s#^config \(.*\)#\1=y#" \
  393. >> $(TOPDIR)/all.config; \
  394. fi
  395. menuconfig: $(CONFIG)/mconf defconfig .menu package/Config.in.auto
  396. @${BASH} ${TOPDIR}/scripts/update-sys
  397. @${BASH} ${TOPDIR}/scripts/update-pkg
  398. @if [ ! -f .config ];then \
  399. $(CONFIG)/conf -D .defconfig $(CONFIG_CONFIG_IN); \
  400. fi
  401. @$(CONFIG)/mconf $(CONFIG_CONFIG_IN)
  402. ${POSTCONFIG}
  403. _config: $(CONFIG)/conf .menu package/Config.in.auto
  404. -@touch .config
  405. @$(CONFIG)/conf ${W} $(CONFIG_CONFIG_IN)
  406. ${POSTCONFIG}
  407. .NOTPARALLEL: _mconfig
  408. _mconfig: ${CONFIG}/conf _mconfig2 _config
  409. _mconfig2: ${CONFIG}/conf modconfig .menu
  410. @${CONFIG}/conf -m ${RCONFIG} >/dev/null
  411. distclean:
  412. @$(MAKE) -C $(CONFIG) clean
  413. @rm -rf $(BUILD_DIR_PFX) $(FW_DIR_PFX) $(TARGET_DIR_PFX) $(DL_DIR) \
  414. ${TOPDIR}/package/pkglist.d ${TOPDIR}/package/pkgconfigs.d
  415. @rm -rf $(TOOLCHAIN_DIR_PFX) $(STAGING_TARGET_DIR_PFX)
  416. @rm -rf $(STAGING_HOST_DIR_PFX) $(STAGING_TARGET_DIR_PFX) $(STAGING_PKG_DIR_PFX)
  417. @rm -f .adkinit .config* .defconfig .tmpconfig.h all.config ${TOPDIR}/prereq.mk \
  418. .menu .rebuild.* ${TOPDIR}/package/Depends.mk .ADK_HAVE_DOT_CONFIG
  419. endif # ! ifeq ($(strip $(ADK_HAVE_DOT_CONFIG)),y)
  420. # build all target architecture and libc combinations (toolchain only)
  421. bulktoolchain:
  422. @if [ -z "$(CLIB)" ];then \
  423. libc="glibc uclibc musl"; \
  424. else \
  425. libc="$(CLIB)"; \
  426. fi; \
  427. for libc in $$libc;do \
  428. while read arch; do \
  429. mkdir -p ${TOPDIR}/firmware; \
  430. ( \
  431. tarch=$$(echo $$arch|sed -e "s#sh4.*#sh#" -e "s#el##" -e "s#eb##" -e "s#mips64.*#mips#" -e "s#hf##" -e "s#x86_64.*#x86_64#" ); \
  432. carch=$$(echo $$arch|sed -e "s#hf##" -e "s#mips64n.*#mips64#" -e "s#mips64el.*#mips64el#" -e 's#x86$$#i686#' -e "s#x86_64.*#x86_64#" ); \
  433. echo === building $$tarch $$libc toolchain-$$arch on $$(date); \
  434. $(GMAKE) ARCH=$$tarch SYSTEM=toolchain-$$arch CLIB=$$libc defconfig; \
  435. tabi=$$(grep ^ADK_TARGET_ABI= .config|cut -d \" -f 2);\
  436. if [ $$arch = "armhf" ];then arch=arm; else arch=$$arch;fi; \
  437. if [ -z $$tabi ];then abi="";else abi=_$$tabi;fi; \
  438. if [ -f ${TOPDIR}/firmware/toolchain_$${carch}_$${libc}$${abi}.tar.xz ];then exit;fi; \
  439. $(GMAKE) VERBOSE=1 all; if [ $$? -ne 0 ]; then touch .exit; break;fi; \
  440. tar -cvJf ${TOPDIR}/firmware/toolchain_$${carch}_$${libc}$${abi}.tar.xz toolchain_${GNU_HOST_NAME} target_$${carch}_$${libc}$${abi}; \
  441. $(GMAKE) cleantoolchain; \
  442. rm .config; \
  443. ) 2>&1 | tee -a $(TOPDIR)/firmware/toolchain_build.log; \
  444. if [ -f .exit ];then break;fi \
  445. done <${TOPDIR}/toolchain/$$libc/tarch.lst ;\
  446. if [ -f .exit ];then echo "Bulk build failed!"; rm .exit; exit 1;fi \
  447. done
  448. test-framework:
  449. @if [ -z "$(CLIB)" ];then \
  450. libc="glibc uclibc musl"; \
  451. else \
  452. libc="$(CLIB)"; \
  453. fi; \
  454. for libc in $$libc;do \
  455. ( \
  456. mkdir -p $(TOPDIR)/firmware/; \
  457. for arch in $$(grep -v "\(m68k\|aarch64\)" toolchain/$$libc/tarch.lst|xargs);do \
  458. tarch=$$(echo $$arch|sed -e "s#el##" -e "s#eb##" -e "s#mips64.*#mips#" -e "s#i686#x86#" -e "s#sh4#sh#" -e "s#hf##" -e "s#x86_64.*#x86_64#"); \
  459. arch=$$(echo $$arch|sed -e 's#x86$$#i686#'); \
  460. echo === building qemu-$$arch for $$libc with $$tarch on $$(date); \
  461. $(GMAKE) ARCH=$$tarch SYSTEM=qemu-$$arch CLIB=$$libc FS=initramfsarchive COLLECTION=test defconfig; \
  462. $(GMAKE) VERBOSE=1 all; if [ $$? -ne 0 ]; then touch .exit; exit 1;fi; \
  463. tabi=$$(grep ^ADK_TARGET_ABI= .config|cut -d \" -f 2);\
  464. if [ -z $$tabi ];then abi="";else abi=_$$tabi;fi; \
  465. qarch=$$(echo $$arch|sed -e "s#armhf#arm#" -e 's#mips64n.*$$#mips64#' -e 's#mips64eln.*$$#mips64el#' -e "s#x86_64.*#x86_64#"); \
  466. cp -a root_qemu_$${qarch}_$${libc}$${abi} root; \
  467. mkdir -p $(TOPDIR)/firmware/qemu/$$arch; \
  468. tar cJvf $(TOPDIR)/firmware/qemu/$$arch/root.tar.xz root; \
  469. if [ -d root ];then rm -rf root;fi; \
  470. cp $(TOPDIR)/firmware/qemu_$${qarch}_$${libc}$${abi}/qemu-$${qarch}-initramfsarchive-kernel \
  471. $(TOPDIR)/firmware/qemu/$$arch/kernel; \
  472. rm .config; \
  473. done; \
  474. ) 2>&1 | tee $(TOPDIR)/firmware/test-framework-build.log; \
  475. if [ -f .exit ];then echo "Bulk build failed!"; break;fi \
  476. done
  477. if [ -f .exit ];then rm .exit;exit 1;fi
  478. release:
  479. for libc in uclibc glibc musl;do \
  480. ( \
  481. echo === building $$libc on $$(date); \
  482. $(GMAKE) prereq && \
  483. $(GMAKE) ARCH=$(ARCH) SYSTEM=$(SYSTEM) CLIB=$$libc FS=archive allmodconfig; \
  484. $(GMAKE) VERBOSE=1 all; if [ $$? -ne 0 ]; then touch .exit; exit 1;fi; \
  485. rm .config; \
  486. ) 2>&1 | tee $(TOPDIR)/firmware/release-build.log; \
  487. if [ -f .exit ];then echo "Bulk build failed!"; break;fi \
  488. done
  489. if [ -f .exit ];then rm .exit;exit 1;fi
  490. # build all target architecture, target systems and libc combinations
  491. bulk:
  492. for libc in uclibc glibc musl;do \
  493. while read arch; do \
  494. systems=$$(./scripts/getsystems $$arch|grep -v toolchain); \
  495. for system in $$systems;do \
  496. mkdir -p $(TOPDIR)/firmware; \
  497. ( \
  498. echo === building $$arch $$system $$libc on $$(date); \
  499. $(GMAKE) prereq && \
  500. $(GMAKE) ARCH=$$arch SYSTEM=$$system CLIB=$$libc FS=archive defconfig; \
  501. $(GMAKE) VERBOSE=1 all; if [ $$? -ne 0 ]; then touch .exit; exit 1;fi; \
  502. rm .config; \
  503. ) 2>&1 | tee $(TOPDIR)/firmware/bulkbuild.log; \
  504. if [ -f .exit ]; then break;fi \
  505. done; \
  506. if [ -f .exit ]; then break;fi \
  507. done <${TOPDIR}/target/arch.lst ;\
  508. if [ -f .exit ];then echo "Bulk build failed!"; rm .exit; exit 1;fi \
  509. done
  510. bulkall:
  511. for libc in uclibc glibc musl;do \
  512. while read arch; do \
  513. systems=$$(./scripts/getsystems $$arch| grep -v toolchain); \
  514. for system in $$systems;do \
  515. mkdir -p $(TOPDIR)/firmware; \
  516. ( \
  517. echo === building $$arch $$system $$libc on $$(date); \
  518. $(GMAKE) prereq && \
  519. $(GMAKE) ARCH=$$arch SYSTEM=$$system CLIB=$$libc FS=archive allconfig; \
  520. $(GMAKE) VERBOSE=1 all; if [ $$? -ne 0 ]; then touch .exit; exit 1;fi; \
  521. rm .config; \
  522. ) 2>&1 | tee $(TOPDIR)/firmware/bulkallbuild.log; \
  523. if [ -f .exit ]; then break;fi \
  524. done; \
  525. if [ -f .exit ]; then break;fi \
  526. done <${TOPDIR}/target/arch.lst ;\
  527. if [ -f .exit ];then echo "Bulk build failed!"; rm .exit; exit 1;fi \
  528. done
  529. bulkallmod:
  530. for libc in uclibc glibc musl;do \
  531. while read arch; do \
  532. systems=$$(./scripts/getsystems $$arch| grep -v toolchain); \
  533. for system in $$systems;do \
  534. mkdir -p $(TOPDIR)/firmware; \
  535. ( \
  536. echo === building $$arch $$system $$libc on $$(date); \
  537. $(GMAKE) prereq && \
  538. $(GMAKE) ARCH=$$arch SYSTEM=$$system CLIB=$$libc FS=archive allmodconfig; \
  539. $(GMAKE) VERBOSE=1 all; if [ $$? -ne 0 ]; then echo $$system-$$libc >.exit; exit 1;fi; \
  540. $(GMAKE) clean; \
  541. rm .config; \
  542. ) 2>&1 | tee $(TOPDIR)/firmware/bulkallmodbuild.log; \
  543. if [ -f .exit ]; then break;fi \
  544. done; \
  545. if [ -f .exit ]; then break;fi \
  546. done <${TOPDIR}/target/arch.lst ;\
  547. if [ -f .exit ];then echo "Bulk build failed!"; cat .exit;rm .exit; exit 1;fi \
  548. done
  549. $(TOPDIR)/adk/tools/pkgmaker: $(TOPDIR)/adk/tools/pkgmaker.c $(TOPDIR)/adk/tools/sortfile.c $(TOPDIR)/adk/tools/strmap.c
  550. @$(CC_FOR_BUILD) -g -o $@ adk/tools/pkgmaker.c adk/tools/sortfile.c adk/tools/strmap.c
  551. $(TOPDIR)/adk/tools/pkgrebuild: $(TOPDIR)/adk/tools/pkgrebuild.c $(TOPDIR)/adk/tools/strmap.c
  552. @$(CC_FOR_BUILD) -g -o $@ adk/tools/pkgrebuild.c adk/tools/strmap.c
  553. package/Config.in.auto menu .menu: $(wildcard ${TOPDIR}/package/*/Makefile) $(TOPDIR)/adk/tools/pkgmaker $(TOPDIR)/adk/tools/pkgrebuild
  554. @echo "Generating menu structure ..."
  555. @$(TOPDIR)/adk/tools/pkgmaker
  556. @:>.menu
  557. $(TOPDIR)/adk/tools/depmaker: $(TOPDIR)/adk/tools/depmaker.c
  558. $(CC_FOR_BUILD) -g -o $@ $(TOPDIR)/adk/tools/depmaker.c
  559. dep: $(TOPDIR)/adk/tools/depmaker
  560. @echo "Generating dependencies ..."
  561. @$(TOPDIR)/adk/tools/depmaker > ${TOPDIR}/package/Depends.mk
  562. .PHONY: menu dep
  563. include $(TOPDIR)/toolchain/gcc/Makefile.inc
  564. check-dejagnu:
  565. @-rm adk/tests/adk.exp adk/tests/master.exp >/dev/null 2>&1
  566. @sed -e "s#@ADK_TARGET_IP@#$(ADK_TARGET_IP)#" \
  567. -e "s#@ADK_TARGET_PORT@#$(ADK_TARGET_PORT)#" \
  568. adk/tests/adk.exp.in > adk/tests/adk.exp
  569. @sed -e "s#@TOPDIR@#$(TOPDIR)#" adk/tests/master.exp.in > \
  570. adk/tests/master.exp
  571. check-gcc: check-dejagnu
  572. env DEJAGNU=$(TOPDIR)/adk/tests/master.exp \
  573. $(MAKE) -C $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/$(PKG_NAME)-$(PKG_VERSION)-final/gcc check-gcc
  574. check-g++: check-dejagnu
  575. env DEJAGNU=$(TOPDIR)/adk/tests/master.exp \
  576. $(MAKE) -C $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/$(PKG_NAME)-$(PKG_VERSION)-final/gcc check-g++
  577. check: check-gcc check-g++