Makefile 6.6 KB

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