build.mk 22 KB

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