prereq-build.mk 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #
  2. # Copyright (C) 2006 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. TMP_DIR:=$(TOPDIR)/tmp
  9. include $(INCLUDE_DIR)/prereq.mk
  10. include $(INCLUDE_DIR)/host.mk
  11. define Require/non-root
  12. [ "$$(shell whoami)" != "root" ]
  13. endef
  14. $(eval $(call Require,non-root, \
  15. Please do not compile as root. \
  16. ))
  17. # Required for the toolchain
  18. define Require/working-make
  19. echo 'all: test' > $(TMP_DIR)/check.mk
  20. echo 'e0 = $$$$(foreach s,foobar,$$$$(eval $$$$s:))' >> $(TMP_DIR)/check.mk
  21. echo 'e1 = $$$$(foreach s,foobar, $$$$(eval $$$$s:))' >> $(TMP_DIR)/check.mk
  22. echo 'test: $$$$(strip $$$$(e0)) $$$$(strip $$$$(e1))' >> $(TMP_DIR)/check.mk
  23. $(NO_TRACE_MAKE) -f $(TMP_DIR)/check.mk
  24. endef
  25. $(eval $(call Require,working-make, \
  26. Please install GNU make v3.81 or later. (This version has bugs) \
  27. ))
  28. define Require/working-gcc
  29. echo 'int main(int argc, char **argv) { return 0; }' | \
  30. gcc -x c -o $(TMP_DIR)/a.out -
  31. endef
  32. $(eval $(call Require,working-gcc, \
  33. Please install the GNU C Compiler (gcc). \
  34. ))
  35. define Require/working-g++
  36. echo 'int main(int argc, char **argv) { return 0; }' | \
  37. g++ -x c++ -o $(TMP_DIR)/a.out -lstdc++ -
  38. endef
  39. $(eval $(call Require,working-g++, \
  40. Please install the GNU C++ Compiler (g++). \
  41. ))
  42. define Require/ncurses
  43. echo 'int main(int argc, char **argv) { initscr(); return 0; }' | \
  44. gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out -lncurses -
  45. endef
  46. $(eval $(call Require,ncurses, \
  47. Please install ncurses. (Missing libncurses.so or ncurses.h) \
  48. ))
  49. define Require/zlib
  50. echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 0; }' | \
  51. gcc -include zlib.h -x c -o $(TMP_DIR)/a.out -lz -
  52. endef
  53. $(eval $(call Require,zlib, \
  54. Please install zlib. (Missing libz.so or zlib.h) \
  55. ))
  56. $(eval $(call RequireCommand,bison, \
  57. Please install GNU bison. \
  58. ))
  59. $(eval $(call RequireCommand,flex, \
  60. Please install flex. \
  61. ))
  62. $(eval $(call RequireCommand,python, \
  63. Please install python. \
  64. ))
  65. $(eval $(call RequireCommand,unzip, \
  66. Please install unzip. \
  67. ))
  68. $(eval $(call RequireCommand,bzip2, \
  69. Please install bzip2. \
  70. ))
  71. $(eval $(call RequireCommand,patch, \
  72. Please install patch. \
  73. ))
  74. $(eval $(call RequireCommand,perl, \
  75. Please install perl. \
  76. ))
  77. define Require/gnutar
  78. $(TAR) --version 2>&1 | grep GNU > /dev/null
  79. endef
  80. $(eval $(call Require,gnutar, \
  81. Please install GNU tar. \
  82. ))