Makefile 6.6 KB

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