prereq-build.mk 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. include $(INCLUDE_DIR)/prereq.mk
  9. include $(INCLUDE_DIR)/host.mk
  10. define Require/non-root
  11. [ "$$(shell whoami)" != "root" ]
  12. endef
  13. $(eval $(call Require,non-root, \
  14. Please do not compile as root. \
  15. ))
  16. # Required for the toolchain
  17. define Require/working-make
  18. echo 'all: test' > $(TMP_DIR)/check.mk
  19. echo 'e0 = $$$$(foreach s,foobar,$$$$(eval $$$$s:))' >> $(TMP_DIR)/check.mk
  20. echo 'e1 = $$$$(foreach s,foobar, $$$$(eval $$$$s:))' >> $(TMP_DIR)/check.mk
  21. echo 'test: $$$$(strip $$$$(e0)) $$$$(strip $$$$(e1))' >> $(TMP_DIR)/check.mk
  22. $(NO_TRACE_MAKE) -f $(TMP_DIR)/check.mk
  23. endef
  24. $(eval $(call Require,working-make, \
  25. Please install GNU make v3.81 or later. (This version has bugs) \
  26. ))
  27. define Require/case-sensitive-fs
  28. rm -f $(TMP_DIR)/test.*
  29. touch $(TMP_DIR)/test.fs
  30. [ \! -f $(TMP_DIR)/test.FS ]
  31. endef
  32. $(eval $(call Require,case-sensitive-fs, \
  33. OpenWrt can only be built on a case-sensitive filesystem \
  34. ))
  35. define Require/working-gcc
  36. echo 'int main(int argc, char **argv) { return 0; }' | \
  37. gcc -x c -o $(TMP_DIR)/a.out -
  38. endef
  39. $(eval $(call Require,working-gcc, \
  40. Please install the GNU C Compiler (gcc). \
  41. ))
  42. define Require/working-g++
  43. echo 'int main(int argc, char **argv) { return 0; }' | \
  44. g++ -x c++ -o $(TMP_DIR)/a.out -lstdc++ -
  45. endef
  46. $(eval $(call Require,working-g++, \
  47. Please install the GNU C++ Compiler (g++). \
  48. ))
  49. define Require/ncurses
  50. echo 'int main(int argc, char **argv) { initscr(); return 0; }' | \
  51. gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out -lncurses -
  52. endef
  53. $(eval $(call Require,ncurses, \
  54. Please install ncurses. (Missing libncurses.so or ncurses.h) \
  55. ))
  56. define Require/zlib
  57. echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 0; }' | \
  58. gcc -include zlib.h -x c -o $(TMP_DIR)/a.out -lz -
  59. endef
  60. $(eval $(call Require,zlib, \
  61. Please install zlib. (Missing libz.so or zlib.h) \
  62. ))
  63. $(eval $(call RequireCommand,bison, \
  64. Please install GNU bison. \
  65. ))
  66. $(eval $(call RequireCommand,flex, \
  67. Please install flex. \
  68. ))
  69. $(eval $(call RequireCommand,unzip, \
  70. Please install unzip. \
  71. ))
  72. $(eval $(call RequireCommand,bzip2, \
  73. Please install bzip2. \
  74. ))
  75. $(eval $(call RequireCommand,patch, \
  76. Please install patch. \
  77. ))
  78. $(eval $(call RequireCommand,perl, \
  79. Please install perl. \
  80. ))
  81. $(eval $(call RequireCommand,wget, \
  82. Please install wget. \
  83. ))
  84. define Require/gnutar
  85. $(TAR) --version 2>&1 | grep GNU > /dev/null
  86. endef
  87. $(eval $(call Require,gnutar, \
  88. Please install GNU tar. \
  89. ))
  90. $(eval $(call RequireCommand,autoconf, \
  91. Please install GNU autoconf. \
  92. ))