1
0

Makefile 6.3 KB

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