build.mk 25 KB

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