Makefile 6.3 KB

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