Makefile 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. _UNLIMIT= ulimit -dS $(shell ulimit -dH >/dev/null 2>/dev/null ) >/dev/null 2>/dev/null;
  4. all: .prereq_done
  5. @${_UNLIMIT} ${GMAKE_INV} all
  6. v: .prereq_done
  7. @(echo; echo "Build started on $$(LC_ALL=C LANGUAGE=C date)"; \
  8. set -x; ${_UNLIMIT} ${GMAKE_FMK} VERBOSE=1 all) 2>&1 | tee -a make.log
  9. help:
  10. @echo 'Common targets:'
  11. @echo ' switch TARGET=targetname - Backup current config and copy old saved target config'
  12. @echo ' download - fetches all needed distfiles'
  13. @echo 'Cleaning targets:'
  14. @echo ' clean - Remove bin and build_dir directories'
  15. @echo ' cleantarget - Same as "clean", but also remove toolchain for target'
  16. @echo ' cleandir - Same as "clean", but also remove all built toolchains'
  17. @echo ' cleankernel - Remove kernel dir, useful if you changed any kernel patches'
  18. @echo ' distclean - Same as "cleandir", but also remove downloaded'
  19. @echo ' distfiles and .config'
  20. @echo ''
  21. @echo 'Configuration targets:'
  22. @echo ' config - Update current config utilising a line-oriented program'
  23. @echo ' menuconfig - Update current config utilising a menu based program'
  24. @echo ' (default when .config does not exist)'
  25. @echo ' oldconfig - Update current config utilising a provided .configs base'
  26. @echo ' wconfig - Same as "oldconfig", but also writes out hidden symbols'
  27. @echo ' allmodconfig - New config selecting all packages as modules when possible'
  28. @echo ' allconfig - New config selecting all packages when possible'
  29. @echo ' allnoconfig - New config where all options are answered with no'
  30. @echo ' kernelconfig - Modify the target kernel configuration'
  31. @echo ''
  32. @echo 'Help targets:'
  33. @echo ' help - Print this help text'
  34. @echo ' pkg-help - Print help about selectively compiling single packages'
  35. @echo ' dev-help - Print help for developers / package maintainers'
  36. @echo ''
  37. @echo 'Other generic targets:'
  38. @echo ' all - Build everything as specified in .config'
  39. @echo ' (default if .config exists)'
  40. @echo ' v - Same as "all" but with logging to make.log enabled'
  41. pkg-help:
  42. @echo 'Package specific targets (use with "package=<pkg-name>" parameter):'
  43. @echo ' fetch - Download the necessary distfile'
  44. @echo ' extract - Same as "fetch", but also extract the distfile'
  45. @echo ' patch - Same as "extract", but also patch the source'
  46. @echo ' build - Same as "patch", but also build the binaries'
  47. @echo ' fake - Same as "build", but also install the binaries'
  48. @echo ' package - Same as "fake", but also create the package'
  49. @echo ' clean - Deinstall and remove the build area'
  50. @echo ' distclean - Same as "clean", but also remove the distfiles'
  51. @echo ''
  52. @echo 'Short package rebuilding guide:'
  53. @echo ' run "make package=<pkgname> clean" to remove all generated binaries'
  54. @echo ' run "make package=<pkgname> package" to build everything and create the package(s)'
  55. @echo ''
  56. @echo 'This does not automatically resolve package dependencies!'
  57. dev-help:
  58. @echo 'Regenerate menu information via "make menu"'
  59. @echo 'Regenerate dependency information via "make dep"'
  60. @echo
  61. @echo 'Fast way of updating package patches:'
  62. @echo ' run "make package=<pkgname> clean" to start with a good base'
  63. @echo ' run "make package=<pkgname> patch" to fetch, unpack and patch the source'
  64. @echo ' edit the package sources at build_dir/w-<pkgname>-*/<pkgname>-<version>'
  65. @echo ' run "make package=<pkgname> update-patches" to regenerate patch files'
  66. @echo ''
  67. @echo 'All changed patches will be opened with your $$EDITOR,'
  68. @echo 'so you can add a description and verify the modifications.'
  69. @echo ''
  70. @echo 'Adding a new package:'
  71. @echo 'make PKG=foo VER=1.0 newpackage'
  72. clean: .prereq_done
  73. -@rm -f nohup.out
  74. @${GMAKE_INV} clean
  75. config: .prereq_done
  76. @${GMAKE_INV} _config W=
  77. oldconfig: .prereq_done
  78. @${GMAKE_INV} _config W=-o
  79. wconfig: .prereq_done
  80. @${GMAKE_INV} _config W=-A
  81. download: .prereq_done
  82. @${GMAKE_INV} toolchain/download
  83. @${GMAKE_INV} package/download
  84. cleankernel kernelclean: .prereq_done
  85. -@${GMAKE_INV} cleankernel
  86. cleandir dirclean: .prereq_done
  87. -@${GMAKE_INV} cleandir
  88. @-rm -f make.log .prereq_done
  89. cleantarget targetclean: .prereq_done
  90. -@${GMAKE_INV} cleantarget
  91. @-rm -f make.log
  92. distclean cleandist:
  93. -@${GMAKE_INV} distclean
  94. @-rm -f make.log .prereq_done
  95. image: .prereq_done
  96. @${GMAKE_INV} image
  97. switch: .prereq_done
  98. @${GMAKE_INV} switch
  99. kernelconfig: .prereq_done
  100. @${GMAKE_INV} kernelconfig
  101. newpackage: .prereq_done
  102. @${GMAKE_INV} newpackage
  103. image_clean imageclean cleanimage: .prereq_done
  104. @${GMAKE_INV} image_clean
  105. menuconfig: .prereq_done
  106. @${GMAKE_INV} menuconfig
  107. defconfig: .prereq_done
  108. @${GMAKE_INV} defconfig
  109. allnoconfig: .prereq_done
  110. @${GMAKE_INV} _config W=-n
  111. allconfig: .prereq_done
  112. @${GMAKE_INV} _mconfig W=-y RCONFIG=Config.in
  113. allmodconfig: .prereq_done
  114. @${GMAKE_INV} _mconfig W=-o RCONFIG=Config.in
  115. package_index: .prereq_done
  116. @${GMAKE_INV} package_index
  117. bulk: .prereq_done
  118. @${GMAKE_INV} bulk
  119. bulkall: .prereq_done
  120. @${GMAKE_INV} bulkall
  121. bulkallmod: .prereq_done
  122. @${GMAKE_INV} bulkallmod
  123. menu: .prereq_done
  124. @${GMAKE_INV} menu
  125. dep: .prereq_done
  126. @${GMAKE_INV} dep
  127. world: .prereq_done
  128. @${GMAKE_INV} world
  129. prereq:
  130. @rm -f .prereq_done
  131. @${GMAKE} .prereq_done
  132. prereq-noerror:
  133. @rm -f .prereq_done
  134. @${GMAKE} .prereq_done NO_ERROR=1
  135. NO_ERROR=0
  136. .prereq_done:
  137. @-rm -rf .prereq_done
  138. @if ! bash --version 2>&1 | fgrep 'GNU bash' >/dev/null 2>&1; then \
  139. echo "GNU bash needs to be installed."; \
  140. exit 1; \
  141. fi
  142. @if ! mksh -c 'echo $$KSH_VERSION' 2>&1 | fgrep 'MIRBSD' >/dev/null 2>&1; then \
  143. echo "MirBSD ksh (mksh) needs to be installed."; \
  144. exit 1; \
  145. else \
  146. if [ $$(mksh -c 'echo $$KSH_VERSION' |cut -d ' ' -f 3|sed "s#R##") -le 34 ]; then \
  147. echo "MirBSD ksh is too old. R35 or higher needed."; \
  148. exit 1; \
  149. fi \
  150. fi
  151. @if test x"$$(umask 2>/dev/null | sed 's/00*22/OK/')" != x"OK"; then \
  152. echo >&2 Error: you must build with umask 022, sorry.; \
  153. exit 1; \
  154. fi
  155. @echo "TOPDIR:=$$(readlink -nf . 2>/dev/null || pwd -P)" >prereq.mk
  156. @echo "BASH:=$$(which bash)" >>prereq.mk
  157. @if [ -z "$$(which gmake 2>/dev/null )" ]; then \
  158. echo "GMAKE:=$$(which make)" >>prereq.mk ;\
  159. else \
  160. echo "GMAKE:=$$(which gmake)" >>prereq.mk ;\
  161. fi
  162. @echo "GNU_HOST_NAME:=$$(${CC} -dumpmachine)" >>prereq.mk
  163. @echo "HOST_ARCH:=$$(${CC} -dumpmachine | sed -e s'/-.*//' \
  164. -e 's/sparc.*/sparc/' \
  165. -e 's/arm.*/arm/g' \
  166. -e 's/m68k.*/m68k/' \
  167. -e 's/ppc/powerpc/g' \
  168. -e 's/v850.*/v850/g' \
  169. -e 's/sh[234]/sh/' \
  170. -e 's/mips-.*/mips/' \
  171. -e 's/mipsel-.*/mipsel/' \
  172. -e 's/cris.*/cris/' \
  173. -e 's/i[3-9]86/i386/' \
  174. )" >>prereq.mk
  175. @echo 'HOSTCC:=${CC}' >>prereq.mk
  176. @echo 'HOSTCFLAGS:=-O2' >>prereq.mk
  177. @echo 'LANGUAGE:=C' >>prereq.mk
  178. @echo 'LC_ALL:=C' >>prereq.mk
  179. @echo 'MAKE:=$${GMAKE}' >>prereq.mk
  180. @echo "OStype:=$$(env uname)" >>prereq.mk
  181. @echo "_PATH:=$$PATH" >>prereq.mk
  182. @echo "PATH:=\$${TOPDIR}/scripts:$$PATH" >>prereq.mk
  183. @echo "SHELL:=$$(which bash)" >>prereq.mk
  184. @env NO_ERROR=${NO_ERROR} BASH="$$(which bash)" \
  185. CC='${CC}' CPPFLAGS='${CPPFLAGS}' \
  186. bash scripts/scan-tools.sh
  187. @echo '===> Prerequisites checked successfully.'
  188. @touch $@
  189. .PHONY: prereq prereq-noerror